Example #1
0
def run_apidoc(_):
    from sphinx.ext.apidoc import main

    args = ['-M', '--no-toc', '-o', './synapse/autodocs', '../synapse', ]
    ignores = ['../synapse/tests']
    args.extend(ignores)
    main(args)
Example #2
0
def run_apidoc(_):
    from sphinx.ext.apidoc import main

    cur_dir = os.path.normpath(os.path.dirname(__file__))
    output_path = os.path.join(cur_dir, 'api')
    modules = os.path.normpath(os.path.join(cur_dir, "../hyperspy"))
    main(['-e', '-f', '-P', '-o', output_path, modules])
Example #3
0
def run_apidoc(_):
    ignore_paths = []
    argv = ["-f", "-T", "-e", "-M", "-o", ".", ".."] + ignore_paths
    try: # Sphinx 1.7+
        from sphinx.ext import apidoc
        apidoc.main(argv)
    except ImportError:  # Sphinx 1.6 (and earlier)
        from sphinx import apidoc
        argv.insert(0, apidoc.__file__)
        apidoc.main(argv)
Example #4
0
def run_apidoc(_):
    from sphinx.ext.apidoc import main

    cur_dir = os.path.normpath(os.path.dirname(__file__))
    output_path = os.path.join(cur_dir, '_apidoc')
    modules = os.path.normpath(os.path.join(cur_dir, "../modules"))
    exclusions = [
        '../modules/isogeo_pysdk',
        '../ui',
        '../test',
    ]
    main(['-e', '-f', '-M', '-o', output_path, modules] + exclusions)
Example #5
0
def run_apidoc(_):
    root = os.path.join('..', 'ample')
    ignore_paths = [os.path.join(root, '*', 'tests')]
    argv = ['-f', '-T', '-e', '-M', '-o', os.path.join('api', 'generated'), root] + ignore_paths
    try:
        # Sphinx 1.7+
        from sphinx.ext import apidoc
        apidoc.main(argv)
    except ImportError:
        # Sphinx 1.6 (and earlier)
        from sphinx import apidoc
        argv.insert(0, apidoc.__file__)
        apidoc.main(argv)
Example #6
0
def run_apidoc(_):
    """Run apidoc."""
    try:
        from sphinx.ext.apidoc import main  # sphinx => 1.7.0b1
    except ImportError:
        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, "..", project)
    params = ['-e', '--force', '--separate', '--private', '--follow-links',
              '-o', cur_dir, module]
    main(params)
Example #7
0
def run_apidoc(_):
    """This method is required by the setup method below."""
    ignore_paths = ['opentimelineio_contrib.adapters', 'tests', 'setup.py']
    # https://github.com/sphinx-doc/sphinx/blob/master/sphinx/ext/apidoc.py
    argv = [
        '--force',
        '--no-toc',
        # '--separate',
        '--module-first',
        '--output-dir',
        './api/modules',
        '../opentimelineio'
     ] + ignore_paths

    from sphinx.ext import apidoc
    apidoc.main(argv)
Example #8
0
def run_apidoc():
    """Run sphinx-apidoc"""

    # 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))
    apidoc_dir = os.path.join(sphinx_source_dir, "api-doc")

    # Include these modules
    modules = ['fenapack']

    for module in modules:
        # Generate .rst files ready for autodoc
        module_dir = os.path.join(repo_dir, module)
        argv = [
            "-f",             # Overwrite existing files
            #"-T",             # Don't create a table of contents file
            #"-P",             # Include "_private" modules
            #"-M",             # Put module doc before submodule doc
            "-d", "1",        # Maximum depth of submodules to show in the TOC
            "-o", apidoc_dir, # Directory to place all output
            module_dir        # Module directory
        ]

        try:
            # Sphinx 1.7+
            from sphinx.ext import apidoc
        except ImportError:
            # Sphinx 1.6 (and earlier)
            from sphinx import apidoc
            argv.insert(0, apidoc.__file__)

        apidoc.OPTIONS = [
            "members",
            "special-members",
            #"private-members",
            #"undoc-members",
            "show-inheritance"
        ]
        apidoc.main(argv)
Example #9
0
def run_apidoc(_):
    import os
    print('run_apidoc: current dir is %s' % os.getcwd())

    ignore_paths = [
        os.path.join('oapackage', 'markup.py'),
        'get_artifacts.py',
        'untitled*.py', 'doxy2swig.py', 'setup.py'
    ]
    ignore_paths = [os.path.join('..', file) for file in ignore_paths]
    

    argv = [
        "-f",
        #        "-T",
        #        "-e",
        "-M",
        "-o", ".",
        os.path.join("..")
        #os.path.join("..", 'oapackage')
    ] + ignore_paths

    sphinxcmd = 'sphinx-apidoc ' + ' '.join(argv)
    if rtd:
        print(sphinxcmd)

    
    if 1:
        try:
            # Sphinx 1.7+
            from sphinx.ext import apidoc
            apidoc.main(argv)
        except ImportError as ex:
            # Sphinx 1.6 (and earlier)
            from sphinx import apidoc
            argv.insert(0, apidoc.__file__)
            apidoc.main(argv)
    else:
        subprocess.call('dir' , shell=True)
        subprocess.call(sphinxcmd, shell=True)
Example #10
0
def run_apidoc(_):

    current_dir = os.path.abspath(os.path.dirname(__file__))
    module = os.path.join(current_dir, "..", "dipper")

    argv = [
        "-f",
        "-T",
        "-e",
        "-M",
        "-o", current_dir,
        module
    ]

    try:
        # Sphinx 1.7+
        from sphinx.ext import apidoc
        apidoc.main(argv)
    except ImportError:
        # Sphinx 1.6 (and earlier)
        from sphinx import apidoc
        argv.insert(0, apidoc.__file__)
        apidoc.main(argv)
Example #11
0
    shutil.rmtree(output_dir)
except FileNotFoundError:
    pass

try:
    import sphinx
    from distutils.version import LooseVersion

    cmd_line_template = "sphinx-apidoc -f -o {outputdir} {moduledir}"
    cmd_line = cmd_line_template.format(outputdir=output_dir, moduledir=module_dir)

    args = cmd_line.split(" ")
    if LooseVersion(sphinx.__version__) >= LooseVersion('1.7'):
        args = args[1:]

    apidoc.main(args)
except Exception as e:
    print("Running `sphinx-apidoc` failed!\n{}".format(e))

# -- 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', 'sphinx.ext.ifconfig', 'sphinx.ext.mathjax',
              'sphinx.ext.napoleon']
Example #12
0
def run_apidoc(app):
    from sphinx.ext.apidoc import main
    module = os.path.abspath(os.path.join(app.srcdir, '..', 'labgrid'))
    output = os.path.abspath(os.path.join(app.srcdir, 'modules'))
    cmd = [module, '-a', '-M', '-H', 'Modules', '-o', output]
    main(cmd)
def run_apidoc(_):
    output_path = os.path.join(repo_root, 'docs', 'source', 'api')
    apidoc.main(['-o', output_path, '-f', pkg_root])
Example #14
0
caldera_root_dir = pathlib.Path('../../..').absolute()
sys.path.insert(0, str(caldera_root_dir))

from plugins.fieldmanual.utils.ability_csv import generate_ability_csv

# Call sphinx-apidoc to generate stub files from our source code.
# -o generated: output rst stubs to this directory
# --implicit-namespaces: will find modules in packages without explicit __init__.py
# --force: overwrite existing generated stubs
# ../app/: this is the directory where caldera lives
apidocs_argv = [
    '-o', '_generated', '--implicit-namespaces', '--force',
    str(caldera_root_dir / 'app')
]
apidoc.main(apidocs_argv)

# Export csv info to csv:
generate_ability_csv(caldera_root_dir, "_generated/abilities.csv")

# -- Project information -----------------------------------------------------

project = 'caldera'
copyright = '2020, The MITRE Corporation'
author = 'The MITRE Corporation'
master_doc = 'index'

# -- General configuration ---------------------------------------------------
extensions = [
    'sphinx.ext.autodoc',
    'recommonmark',
Example #15
0
def RunSphinxAPIDoc(_):
    """Runs sphinx-apidoc to auto-generate documentation."""
    current_directory = os.path.abspath(os.path.dirname(__file__))
    module = os.path.join(current_directory, '..', 'l2tscaffolder')
    api_directory = os.path.join(current_directory, 'sources', 'api')
    apidoc.main(['-o', api_directory, module, '--force'])
Example #16
0
def filtered_files(base, unfiltered_files_filename):
    with open(unfiltered_files_filename) as f:
        lines = [line.rstrip() for line in f]
    # Skip comments and empty lines to get list of files we DON'T want to
    # filter out; this is definitely complicated
    unfiltered = set(
        line for line in lines if not line.startswith("#") and line != "")
    for root, _dirs, files in os.walk(base):
        for filename in files:
            if filename.endswith(".py") and not filename.startswith("_"):
                full = root + "/" + filename
                if full not in unfiltered:
                    yield full


_output_dir = os.path.abspath(".")
_unfiltered_files = os.path.abspath("../unfiltered-files.txt")

# Do the rst generation; remove files which aren't in git first!
for fl in os.listdir("."):
    if (os.path.isfile(fl) and fl.endswith(".rst") and
            fl not in ("index.rst", "modules.rst")):
        os.remove(fl)
os.chdir("../..")  # WARNING! RELATIVE FILENAMES CHANGE MEANING HERE!
apidoc.main([
    '-o', _output_dir, _package_base,
    "spinnman/messages/spinnaker_boot/boot_data/*",
    # Special case: Don't want that empty package at all.
    *filtered_files(_package_base, _unfiltered_files)])
Example #17
0
import datetime
from pathlib import Path
from sphinx.ext import apidoc

copyright = f"{datetime.datetime.now().year}, Evrone"

# Auto generate documentation
if False:
    apidoc.main([
        '-f',  # force overwrite
        '-T',  # no modules.rst toc
        '-e',  # Each module on it's own page
        '-o',
        str(Path(__file__).parent),  # Output dir relative to "Sphinx root"
        str(Path(__file__).parent.parent / 'toggl_python')  # Source code root
    ])
Example #18
0
def run_api_doc(_):
    """
    Automatic API generator

    This method is used to generate API automatically by importing all the
    modules and sub-modules inside a package.

    It is equivalent to run:
    >>> sphinx-apidoc --force --no-toc --separate --module --output-dir api/ ../../ ../../cal_service

    It is useful because it creates .rst files on the file.

    NOTE
    ----
        This does not work with PyCharm default build. If you want to trigger
        this function, use the standard `$ make html` in the command line.
        The .rst files will be generated. After that, you can use PyCharm's
        build helper.
    """
    build_packages = [
        'astrodata',
        'gemini_instruments'
    ]

    current_path = os.getcwd()
    relative_path = "../../../"

    print("Current Path:", current_path)

    for p in build_packages:

        build_path = os.path.join(current_path, relative_path, p)

        ignore_paths = [
            'doc',
            'test',
        ]

        ignore_paths = [os.path.join(build_path, i) for i in ignore_paths]

        argv = [
                   "--force",
                   "--no-toc",
                   # "--separate",
                   "--module",
                   "--output-dir", "api/",
                   build_path
               ] + ignore_paths

        sys.path.insert(0, build_path)

        try:
            # Sphinx 1.7+
            from sphinx.ext import apidoc
            apidoc.main(argv)

        except ImportError:
            # Sphinx 1.6 (and earlier)
            from sphinx import apidoc
            argv.insert(0, apidoc.__file__)
            apidoc.main(argv)
Example #19
0
def run_apidoc(_):
    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, "api")
    module = os.path.join(cur_dir, "..", "src", "fastoad")
    apidoc.main(["-d", "1", "-e", "-o", output_dir, module, "--force"])
Example #20
0
def run_apidoc(_):
    from sphinx.ext.apidoc import main
    main(['-feTM', '-o', '_api', '../ckipnlp'])
Example #21
0
def run_apidoc(_):
    from sphinx.ext.apidoc import main
    main(['-feTM', '-t', './_templates', '-o', '_api', '../ehn'])
Example #22
0
     'pyiron', 'One line description of project.', 'Miscellaneous'),
]

# Documents to append as an appendix to all manuals.
# texinfo_appendices = []

# If false, no module index is generated.
# texinfo_domain_indices = True

# How to display URL addresses: 'footnote', 'no', or 'inline'.
# texinfo_show_urls = 'footnote'

# If true, do not generate a @detailmenu in the "Top" node's menu.
# texinfo_no_detailmenu = False

main(['-e', '-o', 'apidoc', '../pyiron', '--force'])

curdir = os.path.dirname(os.path.abspath(__file__))
if os.path.exists(os.path.join(curdir, 'source/notebooks')):
    shutil.rmtree(os.path.join(curdir, 'source/notebooks'))

shutil.copytree(os.path.join(curdir, '..', 'notebooks'),
                os.path.join(curdir, 'source/notebooks'))

if 'readthedocs.org' in curdir:  # write config for readthedocs.org
    with open(os.path.join(os.path.expanduser('~/.pyiron')), 'w') as f:
        f.writelines([
            '[DEFAULT]', 'TOP_LEVEL_DIRS = ' + os.path.join(curdir, '..'),
            'RESOURCE_PATHS = ' + os.path.join(curdir, '..') + '/tests/static'
        ])
Example #23
0
def builder_inited(app):
    # type: (Sphinx) -> None
    module_dir = app.config.apidoc_module_dir
    output_dir = path.join(app.srcdir, app.config.apidoc_output_dir)
    excludes = app.config.apidoc_excluded_paths
    separate_modules = app.config.apidoc_separate_modules
    toc_file = app.config.apidoc_toc_file
    module_first = app.config.apidoc_module_first
    extra_args = app.config.apidoc_extra_args

    if toc_file and sphinx.version_info < (1, 8, 0):
        logger.warning("'apidoc_toc_file' is only supported by Sphinx "
                       "1.8+; skipping API doc generation")
        return

    if not module_dir:
        logger.warning("No 'apidoc_module_dir' specified; skipping API doc "
                       "generation")
        return

    # if the path is relative, make it relative to the 'conf.py' directory
    if not path.isabs(module_dir):
        module_dir = path.abspath(path.join(app.srcdir, module_dir))

    if not path.exists(module_dir):
        logger.warning(
            "The path defined in 'apidoc_module_dir' does not "
            "exist; skipping API doc generation; %s", module_dir)
        return

    # refactor this module so that we can call 'recurse_tree' like a sane
    # person - at present there is way too much passing around of the
    # 'optparse.Value' instance returned by 'optparse.parse_args'
    def cmd_opts():
        if _ignore_first_arg:
            yield 'sphinxcontrib-apidoc'

        yield '--force'

        if separate_modules:
            yield '--separate'

        if isinstance(toc_file, bool) and toc_file is False:
            yield '--no-toc'
        elif toc_file:
            yield '--tocfile'
            yield toc_file

        if module_first:
            yield '--module-first'

        yield '--output-dir'
        yield output_dir

        for arg in extra_args:
            yield arg

        yield module_dir

        for exc in excludes:
            yield path.abspath(path.join(module_dir, exc))

    apidoc.main(list(cmd_opts()))
Example #24
0
on_rtd = os.environ.get('READTHEDOCS', None) == 'True'
if on_rtd:
    os.environ['SPHINX_APIDOC_OPTIONS'] = ','.join(
        ['members', 'undoc-members', 'inherited-members', 'show-inheritance'])
    import sphinx.ext.apidoc as 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__, "../pytesmo")
    cmd_line_template = "sphinx-apidoc -f -o {outputdir} {moduledir}"
    cmd_line = cmd_line_template.format(outputdir=output_dir,
                                        moduledir=module_dir)
    print(cmd_line)
    apidoc.main(cmd_line.split(" ")[1:])

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

package = "pytesmo"
namespace = []
namespace_pkg = ".".join([namespace[-1], package]) if namespace else package

# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
# sys.path.insert(0, os.path.abspath('.'))

# -- General configuration -----------------------------------------------
Example #25
0
import os
import shlex
import django

# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
sys.path.insert(0, os.path.abspath('..'))
os.environ['DJANGO_SETTINGS_MODULE'] = 'example.settings'
django.setup()

# Auto-generate API documentation.
from sphinx.ext.apidoc import main

main([
    'sphinx-apidoc', '-e', '-T', '-M', '-f', '-o', 'apidoc',
    '../rest_framework_json_api'
])

# -- 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']
autodoc_member_order = 'bysource'
autodoc_inherit_docstrings = False

# Add any paths that contain templates here, relative to this directory.
Example #26
0
def run_api_doc(_):
    """
    Automatic API generator

    This method is used to generate API automatically by importing all the
    modules and sub-modules inside a package.

    It is equivalent to run:
    >>> sphinx-apidoc --force --no-toc --separate --module --output-dir api/ ../../ ../../cal_service

    It is useful because it creates .rst files on the fly.

    NOTE
    ----
        This does not work with PyCharm default build. If you want to trigger
        this function, use the standard `$ make html` in the command line.
        The .rst files will be generated. After that, you can use PyCharm's
        build helper.
    """
    build_packages = [
        #'gempy',
        #'geminidr',
        'recipe_system',
    ]

    is_running_in_pycharm = "PYCHARM_HOSTED" in os.environ

    if is_running_in_pycharm:
        current_path = os.path.split(__file__)[0]
    else:
        current_path = os.getcwd()

    relative_path = "../../../"

    print("\n Am I running on PyCharm? {}".format(is_running_in_pycharm))
    print(" Current Path: {}\n".format(current_path))

    for p in build_packages:

        build_path = os.path.normpath(
            os.path.join(current_path, relative_path, p)
        )

        print('\n Building API using the following build_path: {}\n'.format(
            build_path))

        ignore_paths = [
            'doc',
            'test',
        ]

        ignore_paths = [os.path.join(build_path, i) for i in ignore_paths]
        api_path = os.path.normpath(os.path.join(current_path, 'api'))

        argv = [
                   "--force",
                   "--no-toc",
                   "--module",
                   "--output-dir", api_path,
                   build_path
               ] + ignore_paths

        sys.path.insert(0, build_path)

        try:
            # Sphinx 1.7+
            from sphinx.ext import apidoc
            apidoc.main(argv)

        except ImportError:
            # Sphinx 1.6 (and earlier)
            from sphinx import apidoc
            argv.insert(0, apidoc.__file__)
            apidoc.main(argv)
Example #27
0
def run_apidoc(_):
    from sphinx.ext.apidoc import main
    main(['../pytest_kafka', '-o', 'source/', '-fMe'])
Example #28
0
 def _sphinx_tree(self):
     source_dir = self._get_source_dir()
     cmd = ['-H', 'Modules', '-o', source_dir, '.']
     if apidoc_use_padding:
         cmd.insert(0, 'apidoc')
     apidoc.main(cmd + self.autodoc_tree_excludes)
Example #29
0
def run_apidoc(_):
    """Adds the sphinx-apidoc command as a callback during the build process."""
    main([
        "-MTfe", "-t", f"{CURR_DIR}/template/api", "-o", f"{CURR_DIR}/api",
        f"{ROOT_DIR}/{TOOL_CONFIG['name']}"
    ])
Example #30
0

def filtered_files(base, unfiltered_files_filename):
    with open(unfiltered_files_filename) as f:
        lines = [line.rstrip() for line in f]
    # Skip comments and empty lines to get list of files we DON'T want to
    # filter out; this is definitely complicated
    unfiltered = set(line for line in lines
                     if not line.startswith("#") and line != "")
    for root, _dirs, files in os.walk(base):
        for filename in files:
            if filename.endswith(".py") and not filename.startswith("_"):
                full = root + "/" + filename
                if full not in unfiltered:
                    yield full


_output_dir = os.path.abspath(".")
_unfiltered_files = os.path.abspath("../unfiltered-files.txt")

# Do the rst generation; remove files which aren't in git first!
for fl in os.listdir("."):
    if (os.path.isfile(fl) and fl.endswith(".rst")
            and fl not in ("index.rst", "modules.rst")):
        os.remove(fl)
os.chdir("../..")  # WARNING! RELATIVE FILENAMES CHANGE MEANING HERE!
apidoc.main([
    '-o', _output_dir, _package_base,
    *filtered_files(_package_base, _unfiltered_files)
])
Example #31
0
def run_apidoc(_):
    ignore_paths = []
    argv = [
        "--force", "--module-first", "-o", "./modules", "../../our_package"
    ] + ignore_paths
    apidoc.main(argv)
Example #32
0
from kartothek import __version__ as version

package = "kartothek"

nitpicky = True

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

# Generate module references
output_dir = os.path.abspath(os.path.join(__location__, "../docs/_rst"))
module_dir = os.path.abspath(os.path.join(__location__, "..", package))

apidoc_parameters = ["-f", "-e", "-o", output_dir, module_dir]
apidoc.main(apidoc_parameters)

# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
sys.path.append(
    os.path.abspath(os.path.join(os.path.dirname(__file__), "sphinxext")))

# Add any Sphinx extension module names here, as strings. They can be extensions
# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
extensions = [
    "ignore_missing_refs",
    "sphinx.ext.autodoc",
    "sphinx.ext.intersphinx",
    "sphinx.ext.todo",
    "sphinx.ext.autosummary",
Example #33
0
    module_cmd_line_template = "sphinx-apidoc -f -o {outputdir} {moduledir}"
    module_cmd_line = module_cmd_line_template.format(outputdir=output_dir,
                                                      moduledir=module_dir)
    module_args = module_cmd_line.split(" ")

    test_cmd_line_template = "sphinx-apidoc -f -o {outputdir} {testdir} --tocfile tests"
    test_cmd_line = test_cmd_line_template.format(outputdir=output_dir,
                                                  testdir=test_dir)
    test_args = test_cmd_line.split(" ")

    if parse_version(sphinx.__version__) >= parse_version('1.7'):
        module_args = module_args[1:]
        test_args = test_args[1:]

    apidoc.main(module_args)
    apidoc.main(test_args)
except Exception as e:
    print("Running `sphinx-apidoc` failed!\n{}".format(e))

# -- 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', 'sphinx.ext.ifconfig', 'sphinx.ext.mathjax',
Example #34
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
    Sphinx - Python documentation toolchain
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    :copyright: Copyright 2007-2017 by the Sphinx team, see AUTHORS.
    :license: BSD, see LICENSE for details.
"""

import sys

if __name__ == '__main__':
    from sphinx.ext.apidoc import main
    sys.exit(main(sys.argv[1:]))
Example #35
0
except FileNotFoundError:
    pass

try:
    import sphinx
    from pkg_resources import parse_version

    cmd_line_template = "sphinx-apidoc -f -o {outputdir} {moduledir}"
    cmd_line = cmd_line_template.format(
        outputdir=output_dir, moduledir=module_dir)

    args = cmd_line.split(" ")
    if parse_version(sphinx.__version__) >= parse_version('1.7'):
        args = args[1:]

    apidoc.main(args)
except Exception as e:
    print("Running `sphinx-apidoc` failed!\n{}".format(e))

# -- 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', 'sphinx.ext.ifconfig',
              'sphinx.ext.mathjax', 'sphinx.ext.napoleon',
Example #36
0
def run_apidoc(_):
    main([
        "-f", "-o", "doc/source/reference", "octant/", "octant/tests/*.py",
        "octant/front/parser.py"
    ])
Example #37
0
File: conf.py Project: hibtc/madgui
def setup(app):
    from sphinx.ext import apidoc
    app.connect('builder-inited', lambda _: apidoc.main([
        '-o', './api', '-d2', '-feMT', '../src/madgui',
    ]))
import sys

import django
from sphinx.ext.apidoc import main

from rest_framework_json_api import VERSION

# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
sys.path.insert(0, os.path.abspath(".."))
os.environ["DJANGO_SETTINGS_MODULE"] = "example.settings"
django.setup()

# Auto-generate API documentation.
main(["-o", "apidoc", "-f", "-e", "-T", "-M", "../rest_framework_json_api"])

# -- 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", "recommonmark"]
autodoc_member_order = "bysource"
autodoc_inherit_docstrings = False

# Add any paths that contain templates here, relative to this directory.
templates_path = ["_templates"]
Example #39
0
def run_apidoc(_):
    """Generate API Documentation"""
    ignore_paths = []
    argv = ["-f", "-e", "-o", "apidoc", "../ceph"] + ignore_paths
    apidoc.main(argv)
Example #40
0
def run_api_doc(_):
    """
    Automatic API generator

    This method is used to generate API automatically by importing all the
    modules and sub-modules inside a package.

    It is equivalent to run:
    >>> sphinx-apidoc --force --no-toc --separate --module --output-dir api/ ../../ ../../cal_service

    It is useful because it creates .rst files on the fly.

    NOTE
    ----
        This does not work with PyCharm default build. If you want to trigger
        this function, use the standard `$ make html` in the command line.
        The .rst files will be generated. After that, you can use PyCharm's
        build helper.
    """
    build_packages = [
        # 'gempy',
        # 'geminidr',
        'recipe_system',
    ]

    is_running_in_pycharm = "PYCHARM_HOSTED" in os.environ

    if is_running_in_pycharm:
        current_path = os.path.split(__file__)[0]
    else:
        current_path = os.getcwd()

    relative_path = "../../../"

    print(("\n Am I running on PyCharm? {}".format(is_running_in_pycharm)))
    print((" Current Path: {}\n".format(current_path)))

    for p in build_packages:

        build_path = os.path.normpath(
            os.path.join(current_path, relative_path, p))

        print(('\n Building API using the following build_path: {}\n'.format(
            build_path)))

        ignore_paths = [
            'doc',
            'test',
        ]

        ignore_paths = [os.path.join(build_path, i) for i in ignore_paths]
        api_path = os.path.normpath(os.path.join(current_path, 'api'))

        argv = [
            "--force", "--no-toc", "--module", "--output-dir", api_path,
            build_path
        ] + ignore_paths

        sys.path.insert(0, build_path)

        try:
            # Sphinx 1.7+
            from sphinx.ext import apidoc
            apidoc.main(argv)

        except ImportError:
            # Sphinx 1.6 (and earlier)
            from sphinx import apidoc
            argv.insert(0, apidoc.__file__)
            apidoc.main(argv)
Example #41
0
def run_apidoc(_):
    from sphinx.ext.apidoc import main

    shutil.rmtree("api", ignore_errors=True)
    main(["-f", "-o", "api", "../python/rikai"])
Example #42
0
    def createDocs(self,
                   docs_path: str = "",
                   mode: str = "build"):  # pragma: no cover
        """Dokumentation erzeugen oder erneuern.

        Parameters
        ----------
        docs_path : str, optional
            Pfad nach ui-docs. The default is "".
        mode : str, optional
            Mit rebuild komplett neu erzeugen sonst nur erneuern. The default is "build".

        Returns
        -------
        bool
            ``True`` wenn erzeugt wurde, sonst ``False``.

        """
        import sphinx.ext.apidoc as apidoc
        import sphinx.cmd.build as build

        if mode == "rebuild" and osp.isdir(docs_path):
            from shutil import rmtree
            try:
                rmtree(docs_path)
            except:
                return False

        # ohne docs_path vorlage aus helper/docs kopieren
        if not osp.isdir(docs_path) or not osp.isdir(
                osp.join(docs_path, "build")):
            # conf und _static kopieren
            from distutils.dir_util import copy_tree

            # vorlage kopieren
            #
            from_path = osp.join(osp.dirname(osp.abspath(__file__)), "helper",
                                 "sphinx")
            if not osp.isdir(docs_path):
                os.mkdir(docs_path)
                # das soll eigentlich copy_tree machen
                os.mkdir(osp.join(docs_path, "source"))
                os.mkdir(osp.join(docs_path, "source", "_ext"))
                os.mkdir(osp.join(docs_path, "source", "_static"))

            try:
                copy_tree(from_path, docs_path)
            except:
                logger.debug("ERROR copy_tree {} {}".format(
                    from_path, docs_path))
                print("ERROR copy_tree {} {}".format(from_path, docs_path))
                return False

            # original docs auch kopieren
            #
            org_docs_from_path = osp.join(self._config.get("BASE_DIR", ""),
                                          'docs')

            if osp.isdir(org_docs_from_path):
                org_docs_to = osp.join(docs_path, "source", "docs")
                try:
                    copy_tree(org_docs_from_path, org_docs_to)
                except:
                    logger.debug("ERROR copy_tree {} {}".format(
                        org_docs_from_path, docs_path))

        # es wurde nichts angelegt - Fehlermeldung ausgeben
        if not osp.isdir(docs_path):
            print("### createDocs no path", docs_path)
            return False

        # ausführungs Pfad auf docs_path ändern
        os.chdir(docs_path)

        # ---- 1. rst Dateien in source erzeugen
        api_cmd = [
            '--force',  # force
            '-osource/',  # destdir
            '../',  # module_path
            '../tests*',  # exclude_pattern tests
            '../ui*'  # weitere exclude_pattern
        ]

        apidoc.main(api_cmd)

        # ---- 2. html aus rst Dateien in build erzeugen
        #

        # get project information from main version file
        import version as v

        build_cmd = [
            'source', 'build', '-Dcopyright={}'.format(v.__copyright__),
            '-Dauthor={}'.format(v.__author__), '-Dproject={}'.format(
                self._config.get("server.webserver.title", v.__project__)),
            '-Dversion={}'.format(v.__version__),
            '-Drelease={}'.format(v.__version__)
        ]

        build.main(build_cmd)

        return True
Example #43
0
 def _sphinx_tree(self):
         source_dir = self._get_source_dir()
         cmd = ['-H', 'Modules', '-o', source_dir, '.']
         if apidoc_use_padding:
             cmd.insert(0, 'apidoc')
         apidoc.main(cmd + self.autodoc_tree_excludes)
Example #44
0
    # Since some parameters are sadly hardcoded, it follows some dirty editing:
    conf_py = os.path.join(OUT_DIR, "conf.py")
    with open(conf_py, "r+") as f:  # open in read/write mode:
        lines = f.readlines()
    os.remove(conf_py)
    # remove line, append text at beginning and at end:
    try:
        lines.pop(lines.index(REMOVE_LINE))
    except ValueError:
        print("WARNING: EXPECTED LINE DIDN'T EXIST:", REMOVE_LINE)
    lines.insert(1, EXTRA_BEGIN + "\n")
    lines.append(EXTRA_END + "\n")
    # rewrite edited file to its original path
    with open(conf_py, "w") as f:
        f.writelines(lines)

    # Another dirty hack: the cleanest way to create a fresh apidoc is removing
    # the existing index.rst and running apidoc:
    os.remove(os.path.join(OUT_DIR, "index.rst"))
    apidoc_argv = ["-F", PACKAGE_NAME, "-o", OUT_DIR]
    sphinx_apidoc.main(argv=apidoc_argv)

    # Finally call sphinx build (in its make-mode variant):
    build_output = os.path.join(OUT_DIR, "_build")
    build_html_args = ["html", OUT_DIR, build_output]
    sphinx_build.run_make_mode(args=build_html_args)
    if BUILD_PDF:
        build_pdf_args = ["latexpdf", OUT_DIR, build_output]
        sphinx_build.run_make_mode(args=build_pdf_args)
Example #45
0
def run_api_doc(_):
    """
    Automatic API generator

    This method is used to generate API automatically by importing all the
    modules and sub-modules inside a package.

    It is equivalent to run:
    >>> sphinx-apidoc --force --no-toc --separate --module --output-dir api/ ../../ ../../cal_service

    It is useful because it creates .rst files on the file.

    NOTE
    ----
        This does not work with PyCharm default build. If you want to trigger
        this function, use the standard `$ make html` in the command line.
        The .rst files will be generated. After that, you can use PyCharm's
        build helper.
    """
    build_packages = [
        'astrodata',
        'gemini_instruments'
    ]

    current_path = os.getcwd()
    relative_path = "../../../"

    print("Current Path:", current_path)

    for p in build_packages:

        build_path = os.path.join(current_path, relative_path, p)

        ignore_paths = [
            'doc',
            'test',
        ]

        ignore_paths = [os.path.join(build_path, i) for i in ignore_paths]

        argv = [
                   "--force",
                   "--no-toc",
                   # "--separate",
                   "--module",
                   "--output-dir", "api/",
                   build_path
               ] + ignore_paths

        sys.path.insert(0, build_path)

        try:
            # Sphinx 1.7+
            from sphinx.ext import apidoc
            apidoc.main(argv)

        except ImportError:
            # Sphinx 1.6 (and earlier)
            from sphinx import apidoc
            argv.insert(0, apidoc.__file__)
            apidoc.main(argv)
Example #46
0
]

# Documents to append as an appendix to all manuals.
# texinfo_appendices = []

# If false, no module index is generated.
# texinfo_domain_indices = True

# How to display URL addresses: 'footnote', 'no', or 'inline'.
# texinfo_show_urls = 'footnote'

# If true, do not generate a @detailmenu in the "Top" node's menu.
# texinfo_no_detailmenu = False

# use apidoc to generate developer doc
try:
    from sphinx.ext.apidoc import main
except ImportError:
    from sphinx.apidoc import main

destdir = os.path.abspath(os.path.join(project_root, "doc", "_dvlpt"))

if not os.path.isdir(destdir):
    os.makedirs(destdir)

main([
    '-e', '-o', destdir, '-d', '4', '-s', source_suffix[1:], '--force', src_dir
])

# #}