def cmd_list_formatters(ctx, param, value):
    if not value or ctx.resilient_parsing:
        return
    for key, (cl, label, names, ext, desc) in FORMATTERS.items():
        click.echo(
            '\x1b[1m{}\x1b[0m \x1b[36m{}\x1b[0m \x1b[38;5;245m({})\x1b[0m\n'
            '{}\n'.format(
                label, ' '.join(names), ', '.join(ext),
                textwrap.indent(textwrap.fill(desc, width=66), '    ')))
    ctx.exit()
Exemple #2
0
    def document_formatters(self):
        from pygments.formatters import FORMATTERS

        out = []
        for cls, data in sorted(FORMATTERS.items(), key=lambda x: x[0].__name__):
            self.filenames.add(sys.modules[cls.__module__].__file__)
            docstring = cls.__doc__
            if isinstance(docstring, bytes):
                docstring = docstring.decode("utf8")
            heading = cls.__name__
            out.append(
                FMTERDOC
                % (heading, ", ".join(data[1]) or "None", ", ".join(data[2]).replace("*", "\\*") or "None", docstring)
            )
        return "".join(out)
Exemple #3
0
    def document_formatters(self):
        from pygments.formatters import FORMATTERS

        out = []
        for cls, data in sorted(FORMATTERS.items(),
                                key=lambda x: x[0].__name__):
            self.filenames.add(sys.modules[cls.__module__].__file__)
            docstring = cls.__doc__
            if isinstance(docstring, bytes):
                docstring = docstring.decode('utf8')
            heading = cls.__name__
            out.append(FMTERDOC % (heading, ', '.join(data[1]) or 'None',
                                   ', '.join(data[2]).replace('*', '\\*') or 'None',
                                   docstring))
        return ''.join(out)
Exemple #4
0
def generate_formatter_docs():
    from pygments.formatters import FORMATTERS

    out = []
    for cls, data in sorted(FORMATTERS.iteritems(),
                            key=lambda x: x[0].__name__):
        heading = cls.__name__
        out.append('`' + heading + '`\n' + '-'*(2+len(heading)) + '\n')
        out.append(cls.__doc__)
        out.append('''
    :Short names: %s
    :Filename patterns: %s


''' % (', '.join(data[1]) or 'None', ', '.join(data[2]).replace('*', '\\*') or 'None'))
    return ''.join(out).decode('utf-8')
Exemple #5
0
def generate_formatter_docs():
    from pygments.formatters import FORMATTERS

    out = []
    for cls, data in sorted(FORMATTERS.iteritems(),
                            key=lambda x: x[0].__name__):
        heading = cls.__name__
        out.append('`' + heading + '`\n' + '-'*(2+len(heading)) + '\n')
        out.append(cls.__doc__)
        out.append('''
    :Short names: %s
    :Filename patterns: %s


''' % (', '.join(data[1]) or 'None', ', '.join(data[2]).replace('*', '\\*') or 'None'))
    return ''.join(out).decode('utf-8')
Exemple #6
0
    def document_formatters(self):
        from pygments.formatters import FORMATTERS

        out = []
        for classname, data in sorted(FORMATTERS.items(), key=lambda x: x[0]):
            module = data[0]
            mod = __import__(module, None, None, [classname])
            self.filenames.add(mod.__file__)
            cls = getattr(mod, classname)
            docstring = cls.__doc__
            if isinstance(docstring, bytes):
                docstring = docstring.decode('utf8')
            heading = cls.__name__
            out.append(FMTERDOC % (heading, ', '.join(data[1]) or 'None',
                                   ', '.join(data[2]).replace('*', '\\*') or 'None',
                                   docstring))
        return ''.join(out)
Exemple #7
0
def generate_formatter_docs():
    from pygments.formatters import FORMATTERS

    out = []
    for cls, data in sorted(FORMATTERS.iteritems(), key=lambda x: x[0].__name__):
        heading = cls.__name__
        out.append("`" + heading + "`\n" + "-" * (2 + len(heading)) + "\n")
        out.append(cls.__doc__)
        out.append(
            """
    :Short names: %s
    :Filename patterns: %s


"""
            % (", ".join(data[1]) or "None", ", ".join(data[2]).replace("*", "\\*") or "None")
        )
    return "".join(out).decode("utf-8")