changeset 1516:57feab73c783

Remove :api: role, do not generate epydoc by default
author Pascal Lamblin <lamblinp@iro.umontreal.ca>
date Mon, 05 Mar 2012 17:35:15 -0500
parents 1de26774035f
children a6e634b83d88
files doc/conf.py doc/ext.py doc/scripts/docgen.py
diffstat 3 files changed, 6 insertions(+), 79 deletions(-) [+]
line wrap: on
line diff
--- a/doc/conf.py	Wed Feb 29 12:43:07 2012 -0500
+++ b/doc/conf.py	Mon Mar 05 17:35:15 2012 -0500
@@ -23,7 +23,7 @@
 
 # Add any Sphinx extension module names here, as strings. They can be extensions
 # coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
-extensions = ['sphinx.ext.autodoc', 'sphinx.ext.todo', 'ext', 'taglist']
+extensions = ['sphinx.ext.autodoc', 'sphinx.ext.todo', 'taglist']
 
 todo_include_todos = True
 
--- a/doc/ext.py	Wed Feb 29 12:43:07 2012 -0500
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,75 +0,0 @@
-
-import sys
-import re
-import os
-from docutils import nodes, utils
-from docutils.parsers.rst import roles
-import epydoc.docwriter.xlink as xlink
-
-#def role_fn(name, rawtext, text, lineno, inliner,
-#            options={}, content=[]):
-#    node = nodes.reference(rawtext, text, refuri = "http://pylearn.org/theano/wiki/%s" % text)
-#    return [node], []
-
-
-_TARGET_RE = re.compile(r'^(.*?)\s*<(?:URI:|URL:)?([^<>]+)>$') 
-def create_api_role(name, problematic):
-    """
-    Create and register a new role to create links for an API documentation.
-
-    Create a role called `name`, which will use the URL resolver registered as
-    ``name`` in `api_register` to create a link for an object.
-
-    :Parameters:
-      `name` : `str`
-        name of the role to create.
-      `problematic` : `bool`
-        if True, the registered role will create problematic nodes in
-        case of failed references. If False, a warning will be raised
-        anyway, but the output will appear as an ordinary literal.
-    """
-    def resolve_api_name(n, rawtext, text, lineno, inliner,
-                options={}, content=[]):
-
-        # Check if there's separate text & targets 
-        m = _TARGET_RE.match(text) 
-        if m: text, target = m.groups() 
-        else: target = text 
-        
-        # node in monotype font
-        text = utils.unescape(text)
-        node = nodes.literal(rawtext, text, **options)
-
-        # Get the resolver from the register and create an url from it.
-        try:
-            url = xlink.api_register[name].get_url(target)
-        except IndexError, exc:
-            msg = inliner.reporter.warning(str(exc), line=lineno)
-            if problematic:
-                prb = inliner.problematic(rawtext, text, msg)
-                return [prb], [msg]
-            else:
-                return [node], []
-
-        if url is not None:
-            node = nodes.reference(rawtext, '', node, refuri=url, **options)
-        return [node], []
-
-    roles.register_local_role(name, resolve_api_name)
-
-
-def setup(app):
-
-    try:
-        xlink.set_api_file('api', os.path.join(app.outdir, 'api', 'api-objects.txt'))
-        apiroot = os.getenv('PYLEARN_API_ROOT')
-        if not apiroot:
-            apiroot = os.path.join(os.path.realpath('api'), '')
-        xlink.set_api_root('api', apiroot)
-        #xlink.create_api_role('api', True)
-        create_api_role('api', True)
-    except IOError:
-        print >>sys.stderr, 'WARNING: Could not find api file! API links will not work.'
-
-    #app.add_role("wiki", role_fn)
-
--- a/doc/scripts/docgen.py	Wed Feb 29 12:43:07 2012 -0500
+++ b/doc/scripts/docgen.py	Mon Mar 05 17:35:15 2012 -0500
@@ -28,7 +28,9 @@
         print '  --help: this help'
         sys.exit(0)
 
-    options['--all'] = not (bool(options['--epydoc']) ^ bool(options['--rst']))
+    if not (options['--epydoc'] or options['--rst']):
+        # Default is now rst
+        options['--rst'] = True
 
     def mkdir(path):
         try:
@@ -39,8 +41,6 @@
     outdir = options['-o'] or (pylearn_root + '/html')
     mkdir(outdir)
     os.chdir(outdir)
-    mkdir("doc")
-    mkdir("api")
 
     # Make sure the appropriate 'theano' directory is in the PYTHONPATH
     pythonpath = os.environ.get('PYTHONPATH', '')
@@ -48,6 +48,7 @@
     os.environ['PYTHONPATH'] = pythonpath
 
     if options['--all'] or options['--epydoc']:
+        mkdir("api")
         from epydoc.cli import cli
         sys.path[0:0] = [pylearn_root]
 
@@ -63,6 +64,7 @@
         # TODO
 
     if options['--all'] or options['--rst']:
+        mkdir("doc")
         import sphinx
         sys.path[0:0] = [os.path.join(pylearn_root, 'doc')]
         sphinx.main(['', '-E', os.path.join(pylearn_root, 'doc'), '.'])