|
1 # -*- coding: utf-8 -*- |
|
2 """ |
|
3 pygments.formatters._mapping |
|
4 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|
5 |
|
6 Formatter mapping definitions. This file is generated by itself. Everytime |
|
7 you change something on a builtin formatter definition, run this script from |
|
8 the formatters folder to update it. |
|
9 |
|
10 Do not alter the FORMATTERS dictionary by hand. |
|
11 |
|
12 :copyright: Copyright 2006-2017 by the Pygments team, see AUTHORS. |
|
13 :license: BSD, see LICENSE for details. |
|
14 """ |
|
15 |
|
16 from __future__ import print_function |
|
17 |
|
18 FORMATTERS = { |
|
19 'BBCodeFormatter': ('pygments.formatters.bbcode', 'BBCode', ('bbcode', 'bb'), (), 'Format tokens with BBcodes. These formatting codes are used by many bulletin boards, so you can highlight your sourcecode with pygments before posting it there.'), |
|
20 'BmpImageFormatter': ('pygments.formatters.img', 'img_bmp', ('bmp', 'bitmap'), ('*.bmp',), 'Create a bitmap image from source code. This uses the Python Imaging Library to generate a pixmap from the source code.'), |
|
21 'GifImageFormatter': ('pygments.formatters.img', 'img_gif', ('gif',), ('*.gif',), 'Create a GIF image from source code. This uses the Python Imaging Library to generate a pixmap from the source code.'), |
|
22 'HtmlFormatter': ('pygments.formatters.html', 'HTML', ('html',), ('*.html', '*.htm'), "Format tokens as HTML 4 ``<span>`` tags within a ``<pre>`` tag, wrapped in a ``<div>`` tag. The ``<div>``'s CSS class can be set by the `cssclass` option."), |
|
23 'IRCFormatter': ('pygments.formatters.irc', 'IRC', ('irc', 'IRC'), (), 'Format tokens with IRC color sequences'), |
|
24 'ImageFormatter': ('pygments.formatters.img', 'img', ('img', 'IMG', 'png'), ('*.png',), 'Create a PNG image from source code. This uses the Python Imaging Library to generate a pixmap from the source code.'), |
|
25 'JpgImageFormatter': ('pygments.formatters.img', 'img_jpg', ('jpg', 'jpeg'), ('*.jpg',), 'Create a JPEG image from source code. This uses the Python Imaging Library to generate a pixmap from the source code.'), |
|
26 'LatexFormatter': ('pygments.formatters.latex', 'LaTeX', ('latex', 'tex'), ('*.tex',), 'Format tokens as LaTeX code. This needs the `fancyvrb` and `color` standard packages.'), |
|
27 'NullFormatter': ('pygments.formatters.other', 'Text only', ('text', 'null'), ('*.txt',), 'Output the text unchanged without any formatting.'), |
|
28 'RawTokenFormatter': ('pygments.formatters.other', 'Raw tokens', ('raw', 'tokens'), ('*.raw',), 'Format tokens as a raw representation for storing token streams.'), |
|
29 'RtfFormatter': ('pygments.formatters.rtf', 'RTF', ('rtf',), ('*.rtf',), 'Format tokens as RTF markup. This formatter automatically outputs full RTF documents with color information and other useful stuff. Perfect for Copy and Paste into Microsoft(R) Word(R) documents.'), |
|
30 'SvgFormatter': ('pygments.formatters.svg', 'SVG', ('svg',), ('*.svg',), 'Format tokens as an SVG graphics file. This formatter is still experimental. Each line of code is a ``<text>`` element with explicit ``x`` and ``y`` coordinates containing ``<tspan>`` elements with the individual token styles.'), |
|
31 'Terminal256Formatter': ('pygments.formatters.terminal256', 'Terminal256', ('terminal256', 'console256', '256'), (), 'Format tokens with ANSI color sequences, for output in a 256-color terminal or console. Like in `TerminalFormatter` color sequences are terminated at newlines, so that paging the output works correctly.'), |
|
32 'TerminalFormatter': ('pygments.formatters.terminal', 'Terminal', ('terminal', 'console'), (), 'Format tokens with ANSI color sequences, for output in a text console. Color sequences are terminated at newlines, so that paging the output works correctly.'), |
|
33 'TerminalTrueColorFormatter': ('pygments.formatters.terminal256', 'TerminalTrueColor', ('terminal16m', 'console16m', '16m'), (), 'Format tokens with ANSI color sequences, for output in a true-color terminal or console. Like in `TerminalFormatter` color sequences are terminated at newlines, so that paging the output works correctly.'), |
|
34 'TestcaseFormatter': ('pygments.formatters.other', 'Testcase', ('testcase',), (), 'Format tokens as appropriate for a new testcase.') |
|
35 } |
|
36 |
|
37 |
|
38 if __name__ == '__main__': # pragma: no cover |
|
39 import sys |
|
40 import os |
|
41 |
|
42 # lookup formatters |
|
43 found_formatters = [] |
|
44 imports = [] |
|
45 sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..', '..')) |
|
46 from pygments.util import docstring_headline |
|
47 |
|
48 for root, dirs, files in os.walk('.'): |
|
49 for filename in files: |
|
50 if filename.endswith('.py') and not filename.startswith('_'): |
|
51 module_name = 'pygments.formatters%s.%s' % ( |
|
52 root[1:].replace('/', '.'), filename[:-3]) |
|
53 print(module_name) |
|
54 module = __import__(module_name, None, None, ['']) |
|
55 for formatter_name in module.__all__: |
|
56 formatter = getattr(module, formatter_name) |
|
57 found_formatters.append( |
|
58 '%r: %r' % (formatter_name, |
|
59 (module_name, |
|
60 formatter.name, |
|
61 tuple(formatter.aliases), |
|
62 tuple(formatter.filenames), |
|
63 docstring_headline(formatter)))) |
|
64 # sort them to make the diff minimal |
|
65 found_formatters.sort() |
|
66 |
|
67 # extract useful sourcecode from this file |
|
68 with open(__file__) as fp: |
|
69 content = fp.read() |
|
70 # replace crnl to nl for Windows. |
|
71 # |
|
72 # Note that, originally, contributers should keep nl of master |
|
73 # repository, for example by using some kind of automatic |
|
74 # management EOL, like `EolExtension |
|
75 # <https://www.mercurial-scm.org/wiki/EolExtension>`. |
|
76 content = content.replace("\r\n", "\n") |
|
77 header = content[:content.find('FORMATTERS = {')] |
|
78 footer = content[content.find("if __name__ == '__main__':"):] |
|
79 |
|
80 # write new file |
|
81 with open(__file__, 'w') as fp: |
|
82 fp.write(header) |
|
83 fp.write('FORMATTERS = {\n %s\n}\n\n' % ',\n '.join(found_formatters)) |
|
84 fp.write(footer) |
|
85 |
|
86 print ('=== %d formatters processed.' % len(found_formatters)) |