コード例 #1
0
def writeapi(package, outdir, source_version, other_defines=True):
    # Check that the package is available. If not, the API documentation is not
    # (re)generated and existing API documentation sources will be used.

    try:
        __import__(package)
    except ImportError:
        abort("Can not import " + package)

    module = sys.modules[package]

    # Check that the source version is equal to the installed
    # version. If the versions mismatch the API documentation sources
    # are not (re)generated. This avoids automatic generation of documentation
    # for older or newer versions if such versions are installed on the system.

    installed_version = V(module.__version__)
    if source_version != installed_version:
        abort("Installed version does not match source version")

    docwriter = ApiDocWriter(package,
                             rst_extension='.rst',
                             other_defines=other_defines)

    docwriter.package_skip_patterns += [
        r'\.%s$' % package, r'\.utils.*$', r'.*test.*$', r'.*_fixes.*$',
        r'\.version.*$'
    ]
    docwriter.write_api_docs(outdir)
    docwriter.write_index(outdir, 'index', relative_to=outdir)
    print('%d files written' % len(docwriter.written_modules))
コード例 #2
0
def writeapi(package, outdir, source_version, other_defines=True):
    # Check that the package is available. If not, the API documentation is not
    # (re)generated and existing API documentation sources will be used.

    try:
        __import__(package)
    except ImportError:
        abort("Can not import " + package)

    module = sys.modules[package]

    # Check that the source version is equal to the installed
    # version. If the versions mismatch the API documentation sources
    # are not (re)generated. This avoids automatic generation of documentation
    # for older or newer versions if such versions are installed on the system.

    installed_version = V(module.__version__)
    if source_version != installed_version:
        abort("Installed version does not match source version")

    docwriter = ApiDocWriter(package, rst_extension='.rst',
                             other_defines=other_defines)

    docwriter.package_skip_patterns += [r'\.%s$' % package,
                                        r'.*test.*$',
                                        r'.*duecredit.*$',
                                        r'.*due.*$',
                                        r'\.version.*$']
    docwriter.write_api_docs(outdir)
    docwriter.write_index(outdir, 'index', relative_to=outdir)
    print('%d files written' % len(docwriter.written_modules))
コード例 #3
0
def generate_api_reference_rst(app=None,
                               package='fury',
                               outdir='reference',
                               defines=True):
    try:
        __import__(package)
    except ImportError:
        abort("Can not import " + package)

    module = sys.modules[package]
    installed_version = LooseVersion(module.__version__)
    print("Generation API for {} v{}".format(package, installed_version))

    docwriter = ApiDocWriter(package,
                             rst_extension='.rst',
                             other_defines=defines)
    docwriter.package_skip_patterns += [
        r'.*test.*$',
        # r'^\.utils.*',
        r'\._version.*$',
        r'\.interactor.*$',
        r'\.optpkg.*$',
    ]
    docwriter.object_skip_patterns += [
        r'.*FetcherError.*$',
        r'.*urlopen.*',
        r'.*add_callback.*',
    ]
    if app is not None:
        outdir = pjoin(app.builder.srcdir, outdir)

    docwriter.write_api_docs(outdir)
    docwriter.write_index(outdir, 'index', relative_to=outdir)
    print('%d files written' % len(docwriter.written_modules))
コード例 #4
0
#!/usr/bin/env python
"""Script to auto-generate our API docs.
"""
# stdlib imports
import os

# local imports
from apigen import ApiDocWriter

#*****************************************************************************
if __name__ == '__main__':
    package = 'pysvg'
    outdir = os.path.join('api','generated')
    docwriter = ApiDocWriter(package)
    docwriter.package_skip_patterns += [r'\.fixes$',
                                        r'\.externals$',
                                        r'\.neurospin\.viz',
                                        ]
    docwriter.write_api_docs(outdir)
    docwriter.write_index(outdir, 'gen', relative_to='api')
    print '%d files written' % len(docwriter.written_modules)
コード例 #5
0
        r'\.utils\.py3compat',
        # These are exposed in display
        r'\.core\.display',
        r'\.lib\.display',
        # Shims
        r'\.config',
        r'\.consoleapp',
        r'\.frontend$',
        r'\.html',
        r'\.nbconvert',
        r'\.nbformat',
        r'\.parallel',
        r'\.qt',
    ]
    # main API is in the inputhook module, which is documented.

    # These modules import functions and classes from other places to expose
    # them as part of the public API. They must have __all__ defined. The
    # non-API modules they import from should be excluded by the skip patterns
    # above.
    docwriter.names_from__all__.update({
        'IPython.display',
    })

    # Now, generate the outputs
    docwriter.write_api_docs(outdir)
    # Write index with .txt extension - we can include it, but Sphinx won't try
    # to compile it
    docwriter.write_index(outdir, 'gen.txt', relative_to=pjoin(source, 'api'))
    print('%d files written' % len(docwriter.written_modules))