提交 5b1c0b3b authored 作者: Arnaud Bergeron's avatar Arnaud Bergeron

Add a --cache option to docgen to make it not disable the doctree cache.

This helps immensly when writing or editing documenation by massively speeding up documentation rebuilds (as in 2-3s versus 60-90s before).
上级 c01948b6
...@@ -65,10 +65,11 @@ if __name__ == '__main__': ...@@ -65,10 +65,11 @@ if __name__ == '__main__':
options.update(dict([x, y or True] for x, y in options.update(dict([x, y or True] for x, y in
getopt.getopt(sys.argv[1:], getopt.getopt(sys.argv[1:],
'o:', 'o:',
['epydoc', 'rst', 'help', 'nopdf'])[0])) ['epydoc', 'rst', 'help', 'nopdf', 'cache'])[0]))
if options['--help']: if options['--help']:
print 'Usage: %s [OPTIONS]' % sys.argv[0] print 'Usage: %s [OPTIONS]' % sys.argv[0]
print ' -o <dir>: output the html files in the specified dir' print ' -o <dir>: output the html files in the specified dir'
print ' --cache: use the doctree cache'
print ' --rst: only compile the doc (requires sphinx)' print ' --rst: only compile the doc (requires sphinx)'
print ' --nopdf: do not produce a PDF file from the doc, only HTML' print ' --nopdf: do not produce a PDF file from the doc, only HTML'
print ' --epydoc: only compile the api documentation', print ' --epydoc: only compile the api documentation',
...@@ -114,16 +115,22 @@ if __name__ == '__main__': ...@@ -114,16 +115,22 @@ if __name__ == '__main__':
if options['--all'] or options['--rst']: if options['--all'] or options['--rst']:
mkdir("doc") mkdir("doc")
import sphinx
sys.path[0:0] = [os.path.join(throot, 'doc')] sys.path[0:0] = [os.path.join(throot, 'doc')]
sphinx.main(['', '-E', os.path.join(throot, 'doc'), '.']) def call_sphinx(builder, workdir, extraopts=None):
import sphinx
if extraopts is None:
extraopts = []
if not options['--cache']:
extraopts.append('-E')
sphinx.main(['', '-b', builder] + extraopts +
[os.path.join(throot, 'doc'), workdir])
call_sphinx('html', '.')
if not options['--nopdf']: if not options['--nopdf']:
# Generate latex file in a temp directory # Generate latex file in a temp directory
import tempfile import tempfile
workdir = tempfile.mkdtemp() workdir = tempfile.mkdtemp()
sphinx.main(['', '-E', '-b', 'latex', call_sphinx('latex', workdir)
os.path.join(throot, 'doc'), workdir])
# Compile to PDF # Compile to PDF
os.chdir(workdir) os.chdir(workdir)
os.system('make') os.system('make')
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论