comparison MoinMoin/support/pygments/formatters/_mapping.py @ 6097:815981fad7fd

upgrade pygments from 1.6 to 2.1.3
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Mon, 05 Sep 2016 23:55:33 +0200
parents b48a69886ca4
children
comparison
equal deleted inserted replaced
6096:86a41c2bedec 6097:815981fad7fd
1 # -*- coding: utf-8 -*- 1 # -*- coding: utf-8 -*-
2 """ 2 """
3 pygments.formatters._mapping 3 pygments.formatters._mapping
4 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
5 5
6 Formatter mapping defintions. This file is generated by itself. Everytime 6 Formatter mapping definitions. This file is generated by itself. Everytime
7 you change something on a builtin formatter defintion, run this script from 7 you change something on a builtin formatter definition, run this script from
8 the formatters folder to update it. 8 the formatters folder to update it.
9 9
10 Do not alter the FORMATTERS dictionary by hand. 10 Do not alter the FORMATTERS dictionary by hand.
11 11
12 :copyright: Copyright 2006-2013 by the Pygments team, see AUTHORS. 12 :copyright: Copyright 2006-2015 by the Pygments team, see AUTHORS.
13 :license: BSD, see LICENSE for details. 13 :license: BSD, see LICENSE for details.
14 """ 14 """
15 15
16 # start 16 from __future__ import print_function
17 from pygments.formatters.bbcode import BBCodeFormatter
18 from pygments.formatters.html import HtmlFormatter
19 from pygments.formatters.img import BmpImageFormatter
20 from pygments.formatters.img import GifImageFormatter
21 from pygments.formatters.img import ImageFormatter
22 from pygments.formatters.img import JpgImageFormatter
23 from pygments.formatters.latex import LatexFormatter
24 from pygments.formatters.other import NullFormatter
25 from pygments.formatters.other import RawTokenFormatter
26 from pygments.formatters.rtf import RtfFormatter
27 from pygments.formatters.svg import SvgFormatter
28 from pygments.formatters.terminal import TerminalFormatter
29 from pygments.formatters.terminal256 import Terminal256Formatter
30 17
31 FORMATTERS = { 18 FORMATTERS = {
32 BBCodeFormatter: ('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.'), 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.'),
33 BmpImageFormatter: ('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.'), 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.'),
34 GifImageFormatter: ('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.'), 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.'),
35 HtmlFormatter: ('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."), 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."),
36 ImageFormatter: ('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.'), 23 'IRCFormatter': ('pygments.formatters.irc', 'IRC', ('irc', 'IRC'), (), 'Format tokens with IRC color sequences'),
37 JpgImageFormatter: ('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.'), 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.'),
38 LatexFormatter: ('LaTeX', ('latex', 'tex'), ('*.tex',), 'Format tokens as LaTeX code. This needs the `fancyvrb` and `color` standard packages.'), 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.'),
39 NullFormatter: ('Text only', ('text', 'null'), ('*.txt',), 'Output the text unchanged without any formatting.'), 26 'LatexFormatter': ('pygments.formatters.latex', 'LaTeX', ('latex', 'tex'), ('*.tex',), 'Format tokens as LaTeX code. This needs the `fancyvrb` and `color` standard packages.'),
40 RawTokenFormatter: ('Raw tokens', ('raw', 'tokens'), ('*.raw',), 'Format tokens as a raw representation for storing token streams.'), 27 'NullFormatter': ('pygments.formatters.other', 'Text only', ('text', 'null'), ('*.txt',), 'Output the text unchanged without any formatting.'),
41 RtfFormatter: ('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\xc2\xae Word\xc2\xae documents.'), 28 'RawTokenFormatter': ('pygments.formatters.other', 'Raw tokens', ('raw', 'tokens'), ('*.raw',), 'Format tokens as a raw representation for storing token streams.'),
42 SvgFormatter: ('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.'), 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.'),
43 Terminal256Formatter: ('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.'), 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.'),
44 TerminalFormatter: ('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.') 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.')
45 } 35 }
46 36
47 if __name__ == '__main__': 37 if __name__ == '__main__': # pragma: no cover
48 import sys 38 import sys
49 import os 39 import os
50 40
51 # lookup formatters 41 # lookup formatters
52 found_formatters = [] 42 found_formatters = []
53 imports = [] 43 imports = []
54 sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..', '..')) 44 sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..', '..'))
55 from pygments.util import docstring_headline 45 from pygments.util import docstring_headline
56 46
57 for filename in os.listdir('.'): 47 for root, dirs, files in os.walk('.'):
58 if filename.endswith('.py') and not filename.startswith('_'): 48 for filename in files:
59 module_name = 'pygments.formatters.%s' % filename[:-3] 49 if filename.endswith('.py') and not filename.startswith('_'):
60 print module_name 50 module_name = 'pygments.formatters%s.%s' % (
61 module = __import__(module_name, None, None, ['']) 51 root[1:].replace('/', '.'), filename[:-3])
62 for formatter_name in module.__all__: 52 print(module_name)
63 imports.append((module_name, formatter_name)) 53 module = __import__(module_name, None, None, [''])
64 formatter = getattr(module, formatter_name) 54 for formatter_name in module.__all__:
65 found_formatters.append( 55 formatter = getattr(module, formatter_name)
66 '%s: %r' % (formatter_name, 56 found_formatters.append(
67 (formatter.name, 57 '%r: %r' % (formatter_name,
68 tuple(formatter.aliases), 58 (module_name,
69 tuple(formatter.filenames), 59 formatter.name,
70 docstring_headline(formatter)))) 60 tuple(formatter.aliases),
71 # sort them, that should make the diff files for svn smaller 61 tuple(formatter.filenames),
62 docstring_headline(formatter))))
63 # sort them to make the diff minimal
72 found_formatters.sort() 64 found_formatters.sort()
73 imports.sort()
74 65
75 # extract useful sourcecode from this file 66 # extract useful sourcecode from this file
76 f = open(__file__) 67 with open(__file__) as fp:
77 try: 68 content = fp.read()
78 content = f.read() 69 # replace crnl to nl for Windows.
79 finally: 70 #
80 f.close() 71 # Note that, originally, contributers should keep nl of master
81 header = content[:content.find('# start')] 72 # repository, for example by using some kind of automatic
73 # management EOL, like `EolExtension
74 # <https://www.mercurial-scm.org/wiki/EolExtension>`.
75 content = content.replace("\r\n", "\n")
76 header = content[:content.find('FORMATTERS = {')]
82 footer = content[content.find("if __name__ == '__main__':"):] 77 footer = content[content.find("if __name__ == '__main__':"):]
83 78
84 # write new file 79 # write new file
85 f = open(__file__, 'w') 80 with open(__file__, 'w') as fp:
86 f.write(header) 81 fp.write(header)
87 f.write('# start\n') 82 fp.write('FORMATTERS = {\n %s\n}\n\n' % ',\n '.join(found_formatters))
88 f.write('\n'.join(['from %s import %s' % imp for imp in imports])) 83 fp.write(footer)
89 f.write('\n\n') 84
90 f.write('FORMATTERS = {\n %s\n}\n\n' % ',\n '.join(found_formatters)) 85 print ('=== %d formatters processed.' % len(found_formatters))
91 f.write(footer)
92 f.close()