[Checkins] SVN: Sandbox/ulif/grok-reference-with-rest3/doc/build/grokdocs.py Make use of new directive.

Uli Fouquet uli at gnufix.de
Mon Feb 25 21:23:15 EST 2008


Log message for revision 84253:
  Make use of new directive.

Changed:
  U   Sandbox/ulif/grok-reference-with-rest3/doc/build/grokdocs.py

-=-
Modified: Sandbox/ulif/grok-reference-with-rest3/doc/build/grokdocs.py
===================================================================
--- Sandbox/ulif/grok-reference-with-rest3/doc/build/grokdocs.py	2008-02-26 01:52:09 UTC (rev 84252)
+++ Sandbox/ulif/grok-reference-with-rest3/doc/build/grokdocs.py	2008-02-26 02:23:14 UTC (rev 84253)
@@ -25,6 +25,7 @@
 from ulif.rest import pygments_directive
 import sphinx
 from sphinx.util.console import nocolor
+from sphinx.latexwriter import LaTeXTranslator
 
 HERE = os.path.dirname(__file__)
 
@@ -156,9 +157,17 @@
         val = val[0][1]
         if val == 'latex':
             # disable code-block directive by substituting it with a
-            # simple version...
-            directives.register_directive('sourcecode', simple_directive)
-            directives.register_directive('code-block', simple_directive)
+            # LaTeX-specialized version...
+            directives.register_directive('sourcecode',
+                                          pygments_latex_directive)
+            directives.register_directive('code-block',
+                                          pygments_latex_directive)
+            # Inject a translator handler (sphinx lacks one by default).
+            def visit_raw(self, node):
+                if 'latex' in node.get('format', '').split():
+                    self.body.append(r'%s' % node.astext())
+                raise nodes.SkipNode
+            LaTeXTranslator.visit_raw = visit_raw
 
     if len(args) < 1:
         argv.append(srcdir)



More information about the Checkins mailing list