diff options
author | Christopher Lenz <cmlenz@gmail.com> | 2007-06-06 11:02:48 +0000 |
---|---|---|
committer | Christopher Lenz <cmlenz@gmail.com> | 2007-06-06 11:02:48 +0000 |
commit | c1d8f1128abcf64990c830800950ea690ee579f0 (patch) | |
tree | b008ce163ace673c01836effc06e556968a59e51 /setup.py | |
parent | 34005c1b9e0cd56e8758bdc4d27ad642d5e11131 (diff) | |
download | babel-c1d8f1128abcf64990c830800950ea690ee579f0.tar.gz |
Syntax highlighting for the docs.
Diffstat (limited to 'setup.py')
-rwxr-xr-x | setup.py | 20 |
1 files changed, 20 insertions, 0 deletions
@@ -35,9 +35,29 @@ class build_doc(Command): def run(self): from docutils.core import publish_cmdline + from docutils.nodes import raw + from docutils.parsers import rst + docutils_conf = os.path.join('doc', 'docutils.conf') epydoc_conf = os.path.join('doc', 'epydoc.conf') + try: + from pygments import highlight + from pygments.lexers import get_lexer_by_name + from pygments.formatters import HtmlFormatter + + def code_block(name, arguments, options, content, lineno, + content_offset, block_text, state, state_machine): + lexer = get_lexer_by_name(arguments[0]) + html = highlight('\n'.join(content), lexer, HtmlFormatter()) + return [raw('', html, format='html')] + code_block.arguments = (1, 0, 0) + code_block.options = {'language' : rst.directives.unchanged} + code_block.content = 1 + rst.directives.register_directive('code-block', code_block) + except ImportError: + print 'Pygments not installed, syntax highlighting disabled' + for source in glob('doc/*.txt'): dest = os.path.splitext(source)[0] + '.html' if not os.path.exists(dest) or \ |