예제 #1
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)
예제 #2
0
파일: conf.py 프로젝트: KarrLab/gdoc2text
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)])
예제 #3
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])
예제 #4
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)
예제 #5
0
파일: conf.py 프로젝트: gpiantoni/phypno
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'])
예제 #6
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)
예제 #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])
예제 #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])
예제 #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)
예제 #10
0
파일: conf.py 프로젝트: udapi/udapi-python
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'])
예제 #11
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__))
    module = os.path.join(cur_dir, "..", "cumulusci")
    main(["-E", "-P", "-o", os.path.join(cur_dir, "api"), module, "--force"])
예제 #12
0
파일: conf.py 프로젝트: askomics/askomics
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])
예제 #13
0
파일: conf.py 프로젝트: almcc/cinder-data
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'])
예제 #14
0
파일: conf.py 프로젝트: nickpowersys/CaaR
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'])
예제 #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])
예제 #16
0
def run_apidoc(app):
    global run_already
    if run_already:
        return
    run_already = True

    package_dir = path.abspath(path.join(app.srcdir, '..', '..', 'pycadf'))
    source_dir = path.join(app.srcdir, 'api')
    apidoc.main(['apidoc', package_dir, '-f',
                 '-H', 'pyCADF Modules',
                 '-o', source_dir])
예제 #17
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
     ])
예제 #18
0
 def run(self):
     args = list(
         itertools.chain(
             ["-f"],  # force re-generation
             ["-P"],  # include private modules
             ["--implicit-namespaces"],  # respect PEP420
             ["-o", str(ROOT / "docs" / "api" / "gluonts")],  # out path
             [str(SRC / "gluonts")],  # in path
             ["setup*", "test", "docs", "*pycache*"],  # excluded paths
         ))
     apidoc.main(args)
     super(BuildApiDoc, self).run()
예제 #19
0
 def run(self):
     from sphinx.apidoc import main
     main([
         'sphinx-apidoc',
         '--force',  # Overwrite existing files
         '--module-first',  # Put module documentation before submodule documentation
         '--separate',  # Put documentation for each module on its own page
         '-o',
         './docs/_autosummary',
         'msl',
     ])
     sys.exit(0)
예제 #20
0
def run_apidoc(_):
    try:
        import sphinx.apidoc as apidoc
    except ImportError:
        import sphinx.ext.apidoc as apidoc  # newer Sphinx versions
    clampy_dir = os.path.abspath(
        os.path.join(os.path.dirname(__file__), '..', 'clampy'))
    reference_dir = os.path.abspath(
        os.path.join(os.path.dirname(__file__), 'reference'))
    if not os.path.exists(reference_dir):
        os.mkdir(reference_dir)
    apidoc.main(argv=['-F', '-e', '-M', '-o', reference_dir, clampy_dir])
예제 #21
0
def run_apidoc(_):
    cwd = os.path.abspath(os.path.dirname(__file__))
    source_pathname = os.path.join(cwd, "../..")
    package_names = ["starling"]

    for package_name in package_names:
        output_pathname = os.path.join(cwd, "api", package_name)

        main([
            "--separate", "-o", output_pathname,
            os.path.join(source_pathname, package_name), "--force"
        ])
예제 #22
0
파일: conf.py 프로젝트: pfjaeger/trixi
def run_apidoc(_):
    from sphinx.apidoc import main
    parentFolder = os.path.join(os.path.dirname(__file__), '..')
    cur_dir = os.path.abspath(os.path.dirname(__file__))
    sys.path.append(parentFolder)
    # change "backend" to your module name
    module = os.path.join(parentFolder, 'trixi')
    output_path = os.path.join(cur_dir, 'api')
    main(['-e', '-f', '-o', output_path, module, "-d", "1"])
    file = open(os.path.join(output_path, "modules.rst"), 'a')
    file.write("   ../class_diagram\n")
    file.close()
예제 #23
0
def run_apidoc(_):
    cur_dir = os.path.abspath(os.path.dirname(__file__))
    out_dir = os.path.join(cur_dir, 'contributor', 'modules')
    module = os.path.join(cur_dir, '..', '..', 'octavia')
    # Keep the order of arguments same as the sphinx-apidoc help, otherwise it
    # would cause unexpected errors:
    # sphinx-apidoc [options] -o <output_path> <module_path>
    # [exclude_pattern, ...]
    apidoc.main([
        '--force', '-o', out_dir, module, 'octavia/tests',
        'octavia/db/migration'
    ])
예제 #24
0
파일: setup.py 프로젝트: Rhys314/fipy
    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])
예제 #26
0
파일: apidoc.py 프로젝트: opensds/proposals
def run_apidoc(app):
    global run_already
    if run_already:
        return
    run_already = True

    package_dir = path.abspath(
        path.join(app.srcdir, '..', '..', 'keystonemiddleware'))
    source_dir = path.join(app.srcdir, 'api')
    apidoc.main([
        'apidoc', package_dir, '-f', '-H', 'keystonemiddleware Modules', '-o',
        source_dir
    ])
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])
예제 #28
0
파일: setup.py 프로젝트: Teslos/fipy
    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)
예제 #29
0
def run_apidoc(app):
    global run_already
    if run_already:
        return
    run_already = True

    package_dir = path.abspath(
        path.join(app.srcdir, '..', '..', 'keystoneclient'))
    source_dir = path.join(app.srcdir, 'api')
    ignore_dir = path.join(package_dir, 'tests')
    apidoc.main([
        'apidoc', package_dir, '-f', '-H', 'keystoneclient Modules', '-o',
        source_dir, ignore_dir
    ])
예제 #30
0
def list_module(module_name, exclude=None):
    if os.path.exists(module_name):
        for name in os.listdir(module_name):
            path = os.path.join(module_name, name)
            os.remove(path)
    else:
        os.mkdir(module_name)
    module = __import__(module_name)
    source = os.path.dirname(module.__file__)
    if exclude is None:
        apidoc.main([None, '-o', module_name, source])
    else:
        exclude_path = os.path.join(source, exclude)
        apidoc.main([None, '-o', module_name, source, exclude_path])
예제 #31
0
def run_apidoc(_):
    from sphinx.apidoc import main
    cur_dir = os.path.abspath(os.path.dirname(__file__))
    output_dir = os.path.join(cur_dir, 'apidocs')

    libmuscle_dir = os.path.join(cur_dir, '..', '..', 'libmuscle', 'python',
                                 'libmuscle')
    exclude_pattern = '*/test/*'
    sys.path.append(libmuscle_dir)

    main([
        'sphinx-apidoc', '-e', '--force', '-o', output_dir, libmuscle_dir,
        exclude_pattern
    ])
예제 #32
0
def run_apidoc(_):
    modules = ['FIAT']

    # 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])
예제 #33
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('..')
예제 #34
0
파일: conf.py 프로젝트: FEniCS/ufl
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])
예제 #35
0
def run_apidoc(_):
    ignore_paths = [os.path.abspath('../setup.py')]

    argv = [
        "-f",
        "-e",
        "-P",
        "-o",
        os.path.abspath("."),
        os.path.abspath(".."),
    ] + ignore_paths

    from sphinx.ext import apidoc
    apidoc.main(argv)
예제 #36
0
def run_apidoc(_):
    cur_dir = os.path.abspath(os.path.dirname(__file__))
    out_dir = os.path.join(cur_dir, 'contributor', 'modules')
    module = os.path.join(cur_dir, '..', '..', 'octavia_dashboard')
    # Keep the order of arguments same as the sphinx-apidoc help, otherwise it
    # would cause unexpected errors:
    # sphinx-apidoc [options] -o <output_path> <module_path>
    # [exclude_pattern, ...]
    apidoc.main([
        '--force', '-o', out_dir, module, 'octavia_dashboard/tests',
        'octavia_dashboard/enabled', 'octavia_dashboard/locale',
        'octavia_dashboard/static', 'octavia_dashboard/post_install.sh',
        'octavia_dashboard/karma.conf.js'
    ])
예제 #37
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('..')
예제 #38
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')
예제 #39
0
def run_apidoc(_):
    """
    These two functions are pretty much copy paste from this thread
    https://github.com/rtfd/readthedocs.org/issues/1139 to get the
    automatic docomuntation generation working(with some minor adjustments.)
    """
    from sphinx.apidoc import main
    import os
    import sys
    base_path = (os.path.join(os.path.dirname(__file__), '../..'))
    sys.path.append(base_path)

    module = base_path + '/'+PROJECT
    current_directory = os.path.abspath(os.path.dirname(__file__))
    output_path = os.path.join(current_directory, 'source')
    main(['-e', '-o', output_path, module, '--force'])
예제 #40
0
def run_apidoc(_):
    from sphinx import apidoc

    docs_path = os.path.dirname(__file__)
    apidoc_path = os.path.join(docs_path, "api")
    module_path = os.path.join(docs_path, "..", "semantic_release")

    apidoc.main([
        "--force",
        "--module-first",
        "--separate",
        "-d",
        "3",
        "-o",
        apidoc_path,
        module_path,
    ])
예제 #41
0
파일: conf.py 프로젝트: zhengger/py-evm
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/*',
    ])
예제 #42
0
 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)
예제 #43
0
파일: conf.py 프로젝트: zhushijie112/pdsim
def run_prebuild(_):

    # Run sphinx.apidoc programmatically to autogenerate documentation for PDSim
    from sphinx.apidoc import main
    cur_dir = os.path.abspath(os.path.dirname(__file__))
    output_path = os.path.join(cur_dir, 'PDSim_apidoc')
    main(['-e', '-o', output_path, os.path.dirname(PDSim.__file__), '--force'])

    # Convert the notebooks to RST
    nb_dir = os.path.join(os.path.abspath(os.path.dirname(__file__)),
                          'notebooks')
    nb_index_fname = os.path.join(nb_dir, 'index.rst')
    if not os.path.exists(nb_index_fname):
        print('converting jupyter notebooks to RST')
        sys.path.append(nb_dir)
        import compile_notebooks
        compile_notebooks.convert_notebooks()
예제 #44
0
    def run(self):
        command = [
            None,  # in Sphinx < 1.7.0 the first command-line argument was parsed, in 1.7.0 it became argv[1:]
            '--force',  # overwrite existing files
            '--module-first',  # put module documentation before submodule documentation
            '--separate',  # put documentation for each module on its own page
            '-o', './docs/_autosummary',  # where to save the output files
            'msl',  # the path to the Python package to document
        ]

        import sphinx
        if sphinx.version_info[:2] < (1, 7):
            from sphinx.apidoc import main
        else:
            from sphinx.ext.apidoc import main
            command.pop(0)

        main(command)
예제 #45
0
def run_apidoc(_):
    from sphinx.apidoc import main
    import os
    import shutil
    cur_dir = os.path.dirname(__file__)
    module = os.path.join(cur_dir, '../../razorback')
    output_path = os.path.join(cur_dir, '_build/api')
    shutil.rmtree(output_path, ignore_errors=True)
    main([
        'progname',
        '--separate',
        '--module-first',
        '--no-toc',
        '--force',
        '-o',
        output_path,
        module,
    ])
예제 #46
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)
예제 #47
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)
예제 #48
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')
예제 #49
0
def run_apidoc(_):
    print("Running sphinx-apidoc")
    from sphinx.apidoc import main
    apidoc_dir = 'apidoc'
    module_name = 'aardvark_py'
    sys.path.append(os.path.join(os.path.dirname(__file__), '..'))
    cur_dir = os.path.abspath(os.path.dirname(__file__))
    output_dir = os.path.join(cur_dir, apidoc_dir)
    module_path = os.path.join(cur_dir, '..', module_name)
    main(
        [
            '-T',
            '-f',
            '-o', output_dir,
            module_path,
            os.path.join(module_path, 'aardvark', 'darwin'),
            os.path.join(module_path, 'aardvark', 'linux'),
            os.path.join(module_path, 'aardvark', 'windows'),
        ]
    )
예제 #50
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)
예제 #51
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)
예제 #52
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)
예제 #53
0
파일: conf.py 프로젝트: cehnjun/cytoflow
def run_apidoc(app):
    if app.builder.name == 'embedded_help':  # @UndefinedVariable
        os.environ['SPHINX_APIDOC_OPTIONS'] = 'members'

    from sphinx.apidoc import main
    sys.path.append(os.path.join(os.path.dirname(__file__), '..'))
    cur_dir = os.path.abspath(os.path.dirname(__file__))

    try:
        filelist = glob.glob(os.path.join(cur_dir, "cytoflow*.rst"))
        for f in filelist:
            os.unlink(f)
    except FileNotFoundError:
        pass

    if app.builder.name == 'embedded_help':  # @UndefinedVariable
        module = os.path.join(cur_dir, "..", "cytoflowgui")
        main([None, '-T', '-e', '-E', '-f', '-o', cur_dir, module])
    else:
        module = os.path.join(cur_dir, "..", "cytoflow")
        main([None, '-T', '-e', '-E', '-f', '-o', cur_dir, module])
예제 #54
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)
예제 #55
0
파일: conf.py 프로젝트: i-spark/openpyxl
def run_apidoc(_):
    from sphinx.apidoc import main
    sys.path.append(os.path.join(os.path.dirname(__file__), '..'))
    cur_dir = os.path.abspath(os.path.dirname(__file__))
    modules = [
        '../openpyxl', '../openpyxl/cell/tests', '../openpyxl/chart/tests',
        '../openpyxl/chartsheet/tests', '../openpyxl/comments/tests',
        '../openpyxl/descriptors/tests', '../openpyxl/descriptors/slots.py',
        '../openpyxl/develop/', '../openpyxl/formula/',
        '../openpyxl/formatting/tests/', '../openpyxl/styles/tests',
        '../openpyxl/worksheet/tests', '../openpyxl/writer/tests/',
        '../openpyxl/xml/tests', '../openpyxl/conftest.py',
        '../openpyxl/tests', '../openpyxl/compat', '../openpyxl/reader/tests',
        '../openpyxl/packaging/tests', '../openpyxl/drawing/tests',
        '../openpyxl/utils/tests', '../openpyxl/utils/formulas.py',
        '../openpyxl/workbook/tests',
        '../openpyxl/workbook/external_link/tests',
        '../openpyxl/worksheet/pivot.py',
        '../openpyxl/writer/dump_worksheet.py'
    ]
    output_path = os.path.join(cur_dir, 'api')
    main([None, '-f', '-T', '-e', '-M', '-o', output_path] + modules)
예제 #56
0
파일: conf.py 프로젝트: nickhand/classylss
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)
예제 #57
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)
예제 #58
0
파일: conf.py 프로젝트: fanff/QRL
    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',
예제 #59
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)