[Checkins] SVN: Sandbox/ulif/grok-reference-with-rest3/doc/ Build entrypoints for latex generators.

Uli Fouquet uli at gnufix.de
Tue Feb 26 22:27:21 EST 2008


Log message for revision 84314:
  Build entrypoints for latex generators.

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

-=-
Modified: Sandbox/ulif/grok-reference-with-rest3/doc/build/grokdocs.py
===================================================================
--- Sandbox/ulif/grok-reference-with-rest3/doc/build/grokdocs.py	2008-02-27 03:07:32 UTC (rev 84313)
+++ Sandbox/ulif/grok-reference-with-rest3/doc/build/grokdocs.py	2008-02-27 03:27:20 UTC (rev 84314)
@@ -117,7 +117,7 @@
 
 
 def grokdocs(argv=sys.argv, srcdir=SRCDIR_ALL, htmldir=HTMLDIR_ALL,
-             latexdir=LATEX_ALL):
+             latexdir=LATEX_ALL, do_latex=False):
     """Generate the whole docs, including howtos, reference, etc.
     """
     if srcdir == SRCDIR_ALL:
@@ -131,7 +131,6 @@
     except getopt.error:
         # sphinx will handle that errors
         pass
-
     if len(args) < 1:
         argv.append(srcdir)
     if len(args) < 2:
@@ -141,24 +140,29 @@
         sphinx.usage(argv, msg=None)
         return 1
 
+    format = 'html'
+    if do_latex:
+        format = 'latex'
     if opts and '-b' in [x for x,y in opts]:
         val = filter(lambda x: x[0] == '-b', opts)
-        val = val[-1][1]
-        if val == 'latex':
-            # disable code-block directive by substituting it with a
-            # LaTeX-specialized version...
-            directives.register_directive('sourcecode',
-                                          pygments_latex_directive)
-            directives.register_directive('code-block',
-                                          pygments_latex_directive)
+        format = val[-1][1]
 
-            # Set default sourcedir...
-            if len(args) < 2:
-                argv[-1] = latexdir
-            # Copy fncychap.sty to targetdir...
-            if os.path.isdir(argv[-1]):
-                copyfile(os.path.join(HERE, 'texinputs', 'fncychap.sty'),
-                         os.path.join(argv[-1], 'fncychap.sty'))
+    if format == 'latex':
+        # disable code-block directive by substituting it with a
+        # LaTeX-specialized version...
+        directives.register_directive('sourcecode', pygments_latex_directive)
+        directives.register_directive('code-block', pygments_latex_directive)
+
+        # Set default sourcedir...
+        if len(args) < 2:
+            argv[-1] = latexdir
+        # Copy fncychap.sty to targetdir...
+        if os.path.isdir(argv[-1]):
+            copyfile(os.path.join(HERE, 'texinputs', 'fncychap.sty'),
+                     os.path.join(argv[-1], 'fncychap.sty'))
+        # Let sphinx know, we want LaTeX...
+        argv.insert(1, ('latex'))
+        argv.insert(1, ('-b'))
             
     args = argv                 
 
@@ -170,14 +174,23 @@
 
     print "Generated docs are in %s." % os.path.abspath(argv[-1])
 
+def grokdocs_latex(argv=sys.argv):
+    """Generate all docs in LaTeX.
+    """
+    return grokdocs(argv, do_latex=True)
 
-def grokref(argv=sys.argv):
+def grokref(argv=sys.argv, do_latex=False):
     """Generate the reference docs.
     """
     sphinx.usage = usage_grokref
     return grokdocs(argv, srcdir=SRCDIR_REF, htmldir=HTMLDIR_REF,
-                    latexdir=LATEX_ALL)
+                    latexdir=LATEX_ALL, do_latex=do_latex)
 
+def grokref_latex(argv=sys.argv):
+    """Generate reference in LaTeX format.
+    """
+    return grokref(argv, do_latex=True)
+
 def sphinxquickstart(argv=sys.argv):
     from sphinx import quickstart
     quickstart.main(argv)

Modified: Sandbox/ulif/grok-reference-with-rest3/doc/setup.py
===================================================================
--- Sandbox/ulif/grok-reference-with-rest3/doc/setup.py	2008-02-27 03:07:32 UTC (rev 84313)
+++ Sandbox/ulif/grok-reference-with-rest3/doc/setup.py	2008-02-27 03:27:20 UTC (rev 84314)
@@ -12,8 +12,9 @@
     py_modules = ['grok2html', 'grokdocs'],
     entry_points="""
     [console_scripts]
-    grok2html = grok2html:main
     grokdocs2html = grokdocs:grokdocs
+    grokdocs2latex = grokdocs:grokdocs_latex
     grokref2html = grokdocs:grokref
+    grokref2latex = grokdocs:grokref_latex
     """
     )



More information about the Checkins mailing list