提交 0696cbd2 authored 作者: lamblinp@lgcm's avatar lamblinp@lgcm

Generate PDF from sphinx doc.

上级 58374668
import sys import sys
import os import os
import shutil
import inspect import inspect
from epydoc import docintrospecter from epydoc import docintrospecter
...@@ -98,13 +99,36 @@ if __name__ == '__main__': ...@@ -98,13 +99,36 @@ if __name__ == '__main__':
if options['--all'] or options['--epydoc']: if options['--all'] or options['--epydoc']:
from epydoc.cli import cli from epydoc.cli import cli
sys.path[0:0] = throot sys.path[0:0] = throot
#Generate HTML doc
#os.system("epydoc --config doc/api/epydoc.conf -o html/api")
sys.argv[:] = ['', '--config', '%s/doc/api/epydoc.conf' % throot, '-o', '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")
# Generate PDF doc
# TODO
if options['--all'] or options['--rst']: if options['--all'] or options['--rst']:
import sphinx 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'), '.']) sphinx.main(['', '-E', os.path.join(throot, 'doc'), '.'])
# Generate latex file in a temp directory
import tempfile
workdir = tempfile.mkdtemp()
sphinx.main(['', '-E', '-b', 'latex',
os.path.join(throot, 'doc'), workdir])
# Compile to PDF
currentdir = os.getcwd()
os.chdir(workdir)
os.system('make')
try:
shutil.copy(os.path.join(workdir, 'theano.pdf'), currentdir)
os.chdir(currentdir)
shutil.rmtree(workdir)
except OSError, e:
print 'OSError:', e
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论