summaryrefslogtreecommitdiff
path: root/setup.py
diff options
context:
space:
mode:
authorChristopher Lenz <cmlenz@gmail.com>2007-06-06 11:02:48 +0000
committerChristopher Lenz <cmlenz@gmail.com>2007-06-06 11:02:48 +0000
commitc1d8f1128abcf64990c830800950ea690ee579f0 (patch)
treeb008ce163ace673c01836effc06e556968a59e51 /setup.py
parent34005c1b9e0cd56e8758bdc4d27ad642d5e11131 (diff)
downloadbabel-c1d8f1128abcf64990c830800950ea690ee579f0.tar.gz
Syntax highlighting for the docs.
Diffstat (limited to 'setup.py')
-rwxr-xr-xsetup.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/setup.py b/setup.py
index 2e685f9..d5efbf5 100755
--- a/setup.py
+++ b/setup.py
@@ -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 \