Exemple #1
0
 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])
Exemple #2
0
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)
Exemple #3
0
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)
Exemple #4
0
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'])
Exemple #5
0
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)
Exemple #6
0
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)])
Exemple #7
0
def run_apidoc(_):
    import os
    from sphinx.apidoc import main
    sys.path.append(os.path.join(os.path.dirname(__file__), '..'))
    cur_dir = os.path.abspath(os.path.dirname(__file__))
    out_dir = os.path.join(cur_dir, "apidoc")
    module = os.path.join(cur_dir, "../src/framed")
    main(['-e', '-o', out_dir, module])
Exemple #8
0
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])
Exemple #9
0
 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)
Exemple #10
0
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])
Exemple #11
0
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'])
Exemple #12
0
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'])
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"])
Exemple #14
0
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'])
Exemple #15
0
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])
Exemple #16
0
    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)
def sphinx_api_build(source_directory, out_directory):
    """

    :param source_directory:
    :param out_directory:
    :return:
    """

    # delete files of old build
    if os.path.exists(out_directory):
        shutil.rmtree(out_directory)

    apidoc.main(argv=['', '-o', out_directory, source_directory])
Exemple #18
0
    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=txt"] + apidoc_args + ["fipy"])
        apidoc.main(
            ["sphinx-apidoc", "--output-dir=documentation/tutorial/package/generated", "--suffix=txt"]
            + apidoc_args
            + ["documentation/tutorial/package"]
        )

        if self.html:
            sphinx.main(["sphinx-build", "-b", "redirecting_html"] + sphinx_args + ["documentation/_build/html/"])

        if self.pdf:
            sphinx.main(["sphinx-build", "-b", "latex"] + sphinx_args + ["documentation/_build/latex/"])

            outdir = os.path.join("documentation", "_build", "latex")

            from docutils.core import publish_file

            for xtra in ("LICENSE", "DISCLAIMER"):
                publish_file(
                    source_path="%s.txt" % 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)
Exemple #19
0
 def run(self):
     # metadata contains information supplied in setup()
     metadata = self.distribution.metadata
     src_dir = os.path.join(os.getcwd(),  'genomics')
     # Run sphinx by calling the main method, '--full' also adds a conf.py
     from sphinx import apidoc
     apidoc.main(
         ['', '-f', '-H', 'Python Genomics', '-A', metadata.author,
          '-V', metadata.version, '-R', metadata.version,
          '-o', os.path.join('doc', 'api'), src_dir])
     # build the doc sources
     os.chdir('doc')
     os.system('make html')
     os.chdir('..')
Exemple #20
0
def run_apidoc(_):
    modules = ['ufl']

    # Get location of Sphinx files
    sphinx_source_dir = os.path.abspath(os.path.dirname(__file__))
    repo_dir = os.path.abspath(os.path.join(sphinx_source_dir, os.path.pardir,
                                            os.path.pardir, os.path.pardir))
    apidoc_dir = os.path.join(sphinx_source_dir, "api-doc")

    from sphinx.apidoc import main
    for module in modules:
        # Generate .rst files ready for autodoc
        module_dir = os.path.join(repo_dir, module)
        main(["-f", "-d", "1", "-o", apidoc_dir, module_dir])
Exemple #21
0
 def run(self):
   metadata = self.distribution.metadata
   from sphinx.apidoc import main
   """Run command."""
   sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
   exit = main(['sphinx-apidoc', '-F', '-H', metadata.name, '-A', metadata.author, '-V', metadata.version, '-o', './docs', './app'])
   self.run_command('build_sphinx')
Exemple #22
0
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__))
    package = os.path.join(cur_dir, "..")
    main([
        None,
        '-o',
        cur_dir,
        '--force',
        package,
        package + "/tests/*",
        package + "/setup.py",
        package + '/.eggs/*',
    ])
 def run(self):
     import sphinx.ext.doctest as doctest
     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(" "))
     if self.builder == "doctest":
         # Capture the DocTestBuilder class in order to return the total
         # number of failures when exiting
         ref = capture_objs(doctest.DocTestBuilder)
         BuildDoc.run(self)
         errno = ref[-1].total_failures
         sys.exit(errno)
     else:
         BuildDoc.run(self)
Exemple #24
0
def run_apidoc(_):
    from sphinx.apidoc import main
    import os
    import sys
    import shutil
    sys.path.append(os.path.join(os.path.dirname(__file__), '..'))
    cur_dir = os.path.abspath(os.path.dirname(__file__))
    api_dir = os.path.join(cur_dir, 'api')
    shutil.rmtree(api_dir)  # clear out anything old
    try:
        os.mkdir(api_dir)  # make it if not exists
    except:
        pass
    module = os.path.abspath(os.path.join(cur_dir, '..', 'bibliopixel'))
    args = ['-e', '-o', api_dir, module]
    for ex in API_EXCLUDES:
        args.append(os.path.join(module, ex))

    main(args)
Exemple #25
0
def test_pep_0420_disabled(tempdir):
    codedir = rootdir / 'root' / 'pep_0420'
    outdir = tempdir / 'out'
    args = ['sphinx-apidoc', '-o', outdir, '-F', codedir]
    apidoc.main(args)

    assert (outdir / 'conf.py').isfile()
    assert not (outdir / 'a.b.c.rst').exists()
    assert not (outdir / 'a.b.x.rst').exists()

    @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)
Exemple #26
0
def test_simple(tempdir):
    codedir = rootdir / 'root'
    outdir = tempdir / 'out'
    args = ['sphinx-apidoc', '-o', outdir, '-F', codedir]
    apidoc.main(args)

    assert (outdir / 'conf.py').isfile()
    assert (outdir / 'autodoc_fodder.rst').isfile()
    assert (outdir / 'index.rst').isfile()

    @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)
Exemple #27
0
def run_apidoc(*args):

    from sphinx import apidoc
    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, "..", '..', "classylss")
    output_path = os.path.join(cur_dir, 'api')

    # find directories to exclude
    exclude_dirs = []
    bad = ['tests']
    for dirpath, dirnames, filenames in os.walk(module):
        for b in bad:
            if b in dirnames:
                exclude_dirs.append(os.path.join(dirpath, b))
                dirnames.remove(b)

    # options that will be passed to sphinx-apidoc
    apidoc.OPTIONS = ['members', 'undoc-members', 'inherited-members', 'show-inheritance']

    # call sphinx-apidoc
    apidoc.main(['sphinx-apidoc', '-e', '-o', output_path, module] + exclude_dirs)
Exemple #28
0
def test_multibyte_parameters(tempdir):
    codedir = rootdir / 'root'
    outdir = tempdir / 'out'
    args = ['sphinx-apidoc', '-o', outdir, '-F', codedir,
            '--doc-project', u'プロジェクト名'.encode('utf-8'),
            '--doc-author', u'著者名'.encode('utf-8'),
            '--doc-version', u'バージョン'.encode('utf-8'),
            '--doc-release', u'リリース'.encode('utf-8')]
    apidoc.main(args)

    assert (outdir / 'conf.py').isfile()
    assert (outdir / 'autodoc_fodder.rst').isfile()
    assert (outdir / 'index.rst').isfile()

    conf_py = (outdir / 'conf.py').text()
    if PY2:
        assert u"project = u'プロジェクト名'" in conf_py
        assert u"author = u'著者名'" in conf_py
        assert u"version = u'バージョン'" in conf_py
        assert u"release = u'リリース'" in conf_py
    else:
        assert u"project = 'プロジェクト名'" in conf_py
        assert u"author = '著者名'" in conf_py
        assert u"version = 'バージョン'" in conf_py
        assert u"release = 'リリース'" in conf_py

    @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)
Exemple #29
0
    import inspect
    from sphinx import apidoc

    __location__ = os.path.join(os.getcwd(), os.path.dirname(
        inspect.getfile(inspect.currentframe())))

    output_dir = os.path.join(__location__, "..", "docs", "api")
    module_dir = os.path.join(__location__, "..", "qrl")
    cmd_line_template = "sphinx-apidoc -f -o {outputdir} {moduledir}"
    cmd_line = cmd_line_template.format(outputdir=output_dir, moduledir=module_dir)

    autodoc_mock_imports = ['leveldb', 'ntplib', 'twisted',
                            'colorlog', 'simplejson', 'grpcio', 'grpcio-tools',
                            'service_identity', 'pyopenssl', 'pyqrllib', 'six']

    apidoc.main(cmd_line.split(" "))

# -- General configuration -----------------------------------------------------

# If your documentation needs a minimal Sphinx version, state it here.
# needs_sphinx = '1.0'

# 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.intersphinx',
              'sphinx.ext.todo',
              'sphinx.ext.autosummary',
              'sphinx.ext.viewcode',
              'sphinx.ext.coverage',
              'sphinx.ext.doctest',
Exemple #30
0
 def _sphinx_tree(self):
         source_dir = self._get_source_dir()
         cmd = ['apidoc', '.', '-H', 'Modules', '-o', source_dir]
         apidoc.main(cmd + self.autodoc_tree_excludes)