提交 970f985d authored 作者: Olivier Breuleux's avatar Olivier Breuleux

options for scripts/docgen

上级 03971aa6
...@@ -13,9 +13,6 @@ modules: theano ...@@ -13,9 +13,6 @@ modules: theano
# of: html, text, latex, dvi, ps, pdf. # of: html, text, latex, dvi, ps, pdf.
output: html output: html
# The path to the output directory. May be relative or absolute.
target: html/api/
# An integer indicating how verbose epydoc should be. The default # An integer indicating how verbose epydoc should be. The default
# value is 0; negative values will supress warnings and errors; # value is 0; negative values will supress warnings and errors;
# positive values will give more verbose output. # positive values will give more verbose output.
......
import sys
import re import re
import os import os
from docutils import nodes, utils from docutils import nodes, utils
...@@ -59,9 +60,12 @@ def create_api_role(name, problematic): ...@@ -59,9 +60,12 @@ def create_api_role(name, problematic):
def setup(app): def setup(app):
try:
xlink.set_api_file('api', os.path.join(app.outdir, 'api', 'api-objects.txt')) xlink.set_api_file('api', os.path.join(app.outdir, 'api', 'api-objects.txt'))
xlink.set_api_root('api', os.path.join(app.outdir, 'api', '')) xlink.set_api_root('api', os.path.join(app.outdir, 'api', ''))
#xlink.create_api_role('api', True) #xlink.create_api_role('api', True)
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) app.add_role("wiki", role_fn)
...@@ -54,11 +54,25 @@ docintrospecter.register_introspecter( ...@@ -54,11 +54,25 @@ docintrospecter.register_introspecter(
priority=-1) priority=-1)
import getopt
from collections import defaultdict
if __name__ == '__main__': if __name__ == '__main__':
throot = "/".join(sys.path[0].split("/")[:-1]) throot = "/".join(sys.path[0].split("/")[:-1])
options = defaultdict(bool)
options.update(dict([x, y or True] for x, y in getopt.getopt(sys.argv[1:], 'o:', ['epydoc', 'rst', 'help'])[0]))
if options['--help']:
print 'Usage: %s [OPTIONS]' % sys.argv[0]
print ' -o <dir>: output the html files in the specified dir'
print ' --rst: only compile the doc (requires sphinx)'
print ' --epydoc: only compile the api documentation (requires epydoc)'
print ' --help: this help'
sys.exit(0)
options['--all'] = not (bool(options['--epydoc']) ^ bool(options['--rst']))
import gen_oplist import gen_oplist
print 'Generating oplist...' print 'Generating oplist...'
gen_oplist.print_file(open('%s/doc/doc/oplist.txt' % throot, 'w')) gen_oplist.print_file(open('%s/doc/doc/oplist.txt' % throot, 'w'))
...@@ -69,28 +83,28 @@ if __name__ == '__main__': ...@@ -69,28 +83,28 @@ if __name__ == '__main__':
gen_typelist.print_file(open('%s/doc/doc/typelist.txt' % throot, 'w')) gen_typelist.print_file(open('%s/doc/doc/typelist.txt' % throot, 'w'))
print 'typelist done!' print 'typelist done!'
os.chdir(throot)
def mkdir(path): def mkdir(path):
try: try:
os.mkdir(path) os.mkdir(path)
except OSError: except OSError:
pass pass
mkdir("html") outdir = options['-o'] or (throot + '/html')
mkdir("html/doc") mkdir(outdir)
mkdir("html/api") os.chdir(outdir)
mkdir("doc")
mkdir("api")
if len(sys.argv) == 1 or sys.argv[1] != 'rst': if options['--all'] or options['--epydoc']:
from epydoc.cli import cli from epydoc.cli import cli
sys.path[0:0] = os.path.realpath('.') sys.path[0:0] = throot
sys.argv[:] = ['', '--config', 'doc/api/epydoc.conf', '-o', 'html/api'] sys.argv[:] = ['', '--config', '%s/doc/api/epydoc.conf' % throot, '-o', 'api']
cli() cli()
# os.system("epydoc --config doc/api/epydoc.conf -o html/api") # os.system("epydoc --config doc/api/epydoc.conf -o html/api")
if len(sys.argv) == 1 or sys.argv[1] != 'epydoc': if options['--all'] or options['--rst']:
import sphinx import sphinx
sys.path[0:0] = [os.path.realpath('doc')] sys.path[0:0] = [os.path.join(throot, 'doc')]
sphinx.main(['', '-E', 'doc', 'html']) sphinx.main(['', '-E', os.path.join(throot, 'doc'), '.'])
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论