本文整理汇总了Python中sphinx.apidoc.main函数的典型用法代码示例。如果您正苦于以下问题:Python main函数的具体用法?Python main怎么用?Python main使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了main函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _generate_api_docs
def _generate_api_docs(self):
package_source_dir = os.path.join(PACKAGE_TOPDIR, self.distribution.package_dir[''], 'taucmdr')
sphinx_apidoc.main(['-M', # Put module documentation before submodule documentation
'-P', # Include "_private" modules
'-f', # Overwrite existing files
'-e', # Put documentation for each module on its own page
'-o', self.source_dir, package_source_dir])
示例2: test_pep_0420_disabled_top_level_verify
def test_pep_0420_disabled_top_level_verify(tempdir):
codedir = rootdir / 'root' / 'pep_0420' / 'a' / 'b'
outdir = tempdir / 'out'
args = ['sphinx-apidoc', '-o', outdir, '-F', codedir]
apidoc.main(args)
assert (outdir / 'conf.py').isfile()
assert (outdir / 'c.rst').isfile()
assert not (outdir / 'x.rst').exists()
with open(outdir / 'c.rst') as f:
rst = f.read()
assert "c package\n" in rst
assert "automodule:: c.d\n" in rst
assert "automodule:: c\n" in rst
@with_app('text', srcdir=outdir)
def assert_build(app, status, warning):
app.build()
print(status.getvalue())
print(warning.getvalue())
sys.path.append(codedir)
try:
assert_build()
finally:
sys.path.remove(codedir)
示例3: test_pep_0420_enabled
def test_pep_0420_enabled(tempdir):
codedir = rootdir / 'root' / 'pep_0420'
outdir = tempdir / 'out'
args = ['sphinx-apidoc', '-o', outdir, '-F', codedir, "--implicit-namespaces"]
apidoc.main(args)
assert (outdir / 'conf.py').isfile()
assert (outdir / 'a.b.c.rst').isfile()
assert (outdir / 'a.b.x.rst').isfile()
with open(outdir / 'a.b.c.rst') as f:
rst = f.read()
assert "a.b.c package\n" in rst
assert "automodule:: a.b.c.d\n" in rst
assert "automodule:: a.b.c\n" in rst
with open(outdir / 'a.b.x.rst') as f:
rst = f.read()
assert "a.b.x namespace\n" in rst
assert "automodule:: a.b.x.y\n" in rst
assert "automodule:: a.b.x\n" not in rst
@with_app('text', srcdir=outdir)
def assert_build(app, status, warning):
app.build()
print(status.getvalue())
print(warning.getvalue())
sys.path.append(codedir)
try:
assert_build()
finally:
sys.path.remove(codedir)
示例4: run_apidoc
def run_apidoc(_):
chdir(cur_dir) # use same dir as readthedocs, which is docs/source
from sphinx.apidoc import main
output_path = join(cur_dir, 'api')
# here use paths relative to docs/source
main(['', '-f', '-e', '--module-first', '-o', output_path, '../../phypno',
'../../phypno/viz'])
示例5: apidoc
def apidoc(options):
if not has_sphinx:
raise BuildFailure('Install sphinx to build html docs')
outputdir = options.get('apidoc_outputdir', '')
if not outputdir:
docroot = options.get('docroot', 'docs')
if not os.path.exists(docroot):
raise BuildFailure('Doc root dir (%s) does not exist' % docroot)
outputdir = os.path.join(docroot, options.get('sourcedir', ''))
if not os.path.exists(outputdir):
raise BuildFailure('Doc source dir (%s) does not exist' % outputdir)
moduledir = options.get('apidoc_moduledir', '.')
if not os.path.exists(moduledir):
raise BuildFailure('Module dir (%s) does not exist' % moduledir)
excludes = options.get('apidoc_excludes', [])
if isinstance(excludes, basestring):
excludes = [excludes]
if options.get('apidoc_overwrite', True):
args = ['sphinx-apidoc', '-f']
else:
args = ['sphinx-apidoc']
from sphinx.apidoc import main
args.extend(['-o', outputdir, moduledir] + excludes)
print(' '.join(args))
main(args)
示例6: run_apidoc
def run_apidoc(app):
this_dir = os.path.dirname(__file__)
parser = ConfigParser()
parser.read(os.path.join(this_dir, '..', 'setup.cfg'))
packages = parser.get('sphinx-apidocs', 'packages').strip().split('\n')
for package in packages:
apidoc.main(argv=['sphinx-apidoc', '-f', '-o', os.path.join(this_dir, 'source'), os.path.join(this_dir, '..', package)])
示例7: run_apidoc
def run_apidoc(*args):
from sphinx.apidoc import main
cur_dir = os.path.abspath(os.path.dirname(__file__))
output_path = os.path.join(cur_dir, 'api')
module_path = os.path.join(cur_dir, '../../icinga2client')
main(['-T', '-e', '-o', output_path, module_path])
示例8: run
def run(self):
output_dir = os.path.join(__location__, "docs/_rst")
module_dir = os.path.join(__location__, MAIN_PACKAGE)
cmd_line_template = "sphinx-apidoc -f -o {outputdir} {moduledir}"
cmd_line = cmd_line_template.format(outputdir=output_dir,
moduledir=module_dir)
apidoc.main(cmd_line.split(" "))
BuildDoc.run(self)
示例9: run_apidoc
def run_apidoc(_):
from sphinx.apidoc import main
parent_folder = os.path.join(os.path.dirname(__file__), '..')
cur_dir = os.path.abspath(os.path.dirname(__file__))
sys.path.append(parent_folder)
module = os.path.join(parent_folder, 'askomics')
output_path = os.path.join(cur_dir, 'api')
main(['-e', '-f', '-o', output_path, module])
示例10: run_apidoc
def run_apidoc(_):
"""Heler function for run apidoc as part of the build."""
current_directory = os.path.abspath(os.path.dirname(__file__))
output_path = os.path.join(current_directory, 'source')
cmd_path = 'sphinx-apidoc'
if hasattr(sys, 'real_prefix'): # Check to see if we are in a virtualenv
# If we are, assemble the path manually
cmd_path = os.path.abspath(os.path.join(sys.prefix, 'bin', 'sphinx-apidoc'))
main([cmd_path, '-e', '-o', output_path, '../cinder_data', '--force'])
示例11: run_apidoc
def run_apidoc(_):
cur_dir = os.path.abspath(os.path.dirname(__file__))
print(cur_dir)
module = os.path.abspath(os.path.join(cur_dir, "..", "udapi"))
print(module)
from sphinx.apidoc import main
main(['--separate', '-o', cur_dir, module, '--force'])
示例12: run_apidoc
def run_apidoc(_):
from sphinx.apidoc import main
import os
import sys
sys.path.append(os.path.join(os.path.dirname(__file__), ".."))
cur_dir = os.path.abspath(os.path.dirname(__file__))
module = os.path.join(cur_dir, "..", "cumulusci")
main(["-E", "-P", "-o", os.path.join(cur_dir, "api"), module, "--force"])
示例13: run_apidoc
def run_apidoc(_):
modules = ['caar']
for module in modules:
cur_dir = os.path.abspath(os.path.dirname(__file__))
output_path = os.path.join(cur_dir, 'docs')
cmd_path = 'sphinx-apidoc'
if hasattr(sys, 'real_prefix'): # Check to see if we are in a virtualenv
# If we are, assemble the path manually
cmd_path = os.path.abspath(os.path.join(sys.prefix, 'bin', 'sphinx-apidoc'))
main(['-e', '-o', output_path, module, '--force'])
示例14: run_apidoc
def run_apidoc(app):
global run_already
if run_already:
return
run_already = True
package_dir = path.abspath(path.join(app.srcdir, '..', '..', 'keystone'))
source_dir = path.join(app.srcdir, 'api')
apidoc.main(['apidoc', package_dir, '-f',
'-H', 'Keystone Modules',
'-o', source_dir])
示例15: run
def run (self):
import sphinx
from sphinx import apidoc
sphinx_args = ['-P', '-n', '-c', 'documentation/', '.']
apidoc_args = []
if self.cathartic:
sphinx_args = ['-a', '-E'] + sphinx_args
apidoc_args = ['--force'] + apidoc_args
apidoc.main(['sphinx-apidoc', '--output-dir=fipy/generated', '--suffix=rst']
+ apidoc_args + ['fipy'])
apidoc.main(['sphinx-apidoc', '--output-dir=documentation/tutorial/package/generated', '--suffix=rst']
+ apidoc_args + ['documentation/tutorial/package'])
if self.html:
sphinx.main(['sphinx-build', '-b', 'redirecting_html'] + sphinx_args + ['documentation/_build/html/'])
if self.pdf:
try:
sphinx.main(['sphinx-build', '-b', 'latex'] + sphinx_args + ['documentation/_build/latex/'])
except SystemExit:
pass
outdir = os.path.join('documentation', '_build', 'latex')
from docutils.core import publish_file
for xtra in ("LICENSE", "DISCLAIMER"):
publish_file(source_path="%s.rst" % xtra,
destination_path=os.path.join(outdir, "%s.tex" % xtra),
reader_name='standalone',
parser_name='restructuredtext',
writer_name='latex',
settings_overrides= {
'template': 'documentation/_templates/empty.tex'
})
savedir = os.getcwd()
os.chdir(outdir)
os.system("pdflatex fipy")
os.system("pdflatex fipy")
os.system("pdflatex fipy")
os.system("makeindex -s python.ist fipy")
os.system("makeindex -s python.ist modfipy")
os.system("pdflatex fipy")
os.system("pdflatex fipy")
os.chdir(savedir)