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))
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))
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))
package = 'zmq' outdir = pjoin('source', 'api', 'generated') docwriter = ApiDocWriter(package, rst_extension='.rst') # You have to escape the . here because . is a special char for regexps. # You must do make clean if you change this! docwriter.package_skip_patterns += [ r'\.tests$', r'\.backend$', r'\.eventloop\.minitornado$', r'\.green\.eventloop$', r'\.sugar$', r'\.devices$', ] docwriter.module_skip_patterns += [ r'\.eventloop\.stack_context$', r'\.error$', r'\.green\..+$', r'\.utils\.initthreads$', r'\.utils\.constant_names$', r'\.utils\.garbage$', r'\.utils\.rebuffer$', r'\.utils\.strtypes$', ] # Now, generate the outputs docwriter.write_api_docs(outdir) docwriter.write_index(outdir, 'gen', relative_to=pjoin('source', 'api')) print('%d files written' % len(docwriter.written_modules))
r"\.nbformat\.convert", r"\.nbformat\.validator", r"\.nbformat\.notebooknode", # Deprecated r"\.nbformat\.current", # Exposed by nbformat.vN r"\.nbformat\.v[3-4]\.nbbase", # These are exposed in display r"\.core\.display", r"\.lib\.display", # This isn't actually a module r"\.html\.tasks", # This is private r"\.html\.allow76", ] # 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.nbformat", "IPython.nbformat.v3", "IPython.nbformat.v4", "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))
#!/usr/bin/env python # emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*- # vi: set ft=python sts=4 ts=4 sw=4 et: """Script to auto-generate our API docs. """ # stdlib imports import os # local imports from apigen import ApiDocWriter #***************************************************************************** if __name__ == '__main__': package = 'regreg' outdir = os.path.join('source', 'api', 'generated') docwriter = ApiDocWriter(package) docwriter.write_api_docs(outdir) docwriter.write_index(outdir, 'gen', relative_to='api') print('%d files written' % len(docwriter.written_modules))
#!/usr/bin/env python """Script to generate API docs""" import os, sys from apigen import ApiDocWriter if __name__ == '__main__': package = 'pygimli' try: __import__(package) except ImportError as e: print("Can not import pygimli") exit() buildpath = os.path.abspath(os.path.dirname( sys.modules[__name__].__file__)) outdir = os.path.abspath(buildpath + '/pygimliapi') if not os.path.exists(outdir): os.makedirs(outdir) docwriter = ApiDocWriter(package) docwriter.package_skip_patterns += [r'\.gui$'] docwriter.rst_extension = ".rst" docwriter.write_api_docs(outdir) docwriter.write_index(outdir, "index", relative_to=outdir) print('%d files written to %s' % (len(docwriter.written_modules), os.path.abspath(outdir)))
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))
#!/usr/bin/env python """Script to generate API docs""" import os, sys from apigen import ApiDocWriter if __name__ == "__main__": package = "pygimli" try: __import__(package) except ImportError as e: print("Can not import pygimli") exit() buildpath = os.path.abspath(os.path.dirname(sys.modules[__name__].__file__)) outdir = os.path.abspath(buildpath + "/pygimliapi") if not os.path.exists(outdir): os.makedirs(outdir) docwriter = ApiDocWriter(package) docwriter.package_skip_patterns += [r"\.gui$"] docwriter.rst_extension = ".rst" docwriter.write_api_docs(outdir) docwriter.write_index(outdir, "index", relative_to=outdir) print("%d files written to %s" % (len(docwriter.written_modules), os.path.abspath(outdir)))
installed_version = V(module.__version__) info_lines = open('../dipy/info.py').readlines() source_version = '.'.join([v.split('=')[1].strip(" '\n.") for v in info_lines if re.match( '^_version_(major|minor|micro|extra)', v )]) print '***', source_version if source_version != installed_version: abort("Installed version does not match source version") outdir = 'reference' docwriter = ApiDocWriter(package, rst_extension='.rst') docwriter.package_skip_patterns += [r'\.fixes$', r'\.externals$', r'\.reconst.eit$', r'\.tracking\.interfaces.*$', r'\.tracking\.gui_tools.*$', r'.*test.*$', r'\.utils.*$', r'\.viz.*$', r'\.boots\.resampling.*$', r'\.fixes.*$', r'\.info.*$', r'\.pkg_info.*$', ] docwriter.write_api_docs(outdir) docwriter.write_index(outdir, 'index', relative_to='reference') print('%d files written' % len(docwriter.written_modules))
#!/usr/bin/env python # emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*- # vi: set ft=python sts=4 ts=4 sw=4 et: """Script to auto-generate our API docs. This script should run in Python 2 and Python 3 """ # stdlib imports import os # local imports from apigen import ApiDocWriter # ***************************************************************************** if __name__ == "__main__": package = "nipy" outdir = os.path.join("api", "generated") docwriter = ApiDocWriter(package) docwriter.package_skip_patterns += [ r"\.fixes$", r"\.externals$", # r'\.labs\.viz', ] # XXX: Avoid nipy.modalities.fmri.aliased due to a bug in python2.6 docwriter.module_skip_patterns += [r"\.modalities\.fmri.aliased"] docwriter.write_api_docs(outdir) docwriter.write_index(outdir, "gen", relative_to="api") print("%d files written" % len(docwriter.written_modules))
# local imports from apigen import ApiDocWriter outdir = os.path.join("api", "generated") docwriter = ApiDocWriter(package) # Packages that should not be included in generated API docs. docwriter.package_skip_patterns += [ "\.external$", "\.utils$", "\.interfaces\.", "\.workflows$", "\.pipeline\.plugins$", "\.testing$", "\.fixes$", "\.algorithms$", "\.scripts$", ] # Modules that should not be included in generated API docs. docwriter.module_skip_patterns += [ "\.version$", "info", "\.interfaces\.(?!(base|matlab))", "\.pipeline\.utils$", "\.interfaces\.slicer\.generate_classes$", "\.interfaces\.pymvpa$", "\.scripts$", ] docwriter.write_api_docs(outdir) docwriter.write_index(outdir, "gen", relative_to="api") print("%d files written" % len(docwriter.written_modules))
try: __import__(package) except ImportError, e: abort("Can not import MRS") 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__) info_lines = open('../MRS/version.py').readlines() source_version = '.'.join([ v.split('=')[1].strip(" '\n.").split('#')[0] for v in info_lines if re.match('^_version_(major|minor|micro|extra)', v) ]) print '***', source_version if source_version != installed_version: abort("Installed version does not match source version") outdir = 'reference' docwriter = ApiDocWriter(package, rst_extension='.rst') docwriter.package_skip_patterns += [r'\.version$', r'\.MRS$'] docwriter.write_api_docs(outdir) docwriter.write_index(outdir, 'index', relative_to='reference') print('%d files written' % len(docwriter.written_modules))
setup_lines = open("../setup.py").readlines() for l in setup_lines: if l.startswith("VERSION"): source_version = V(l.split("'")[1]) break if source_version != installed_version: abort("Installed version does not match source version") if __name__ == "__main__": package = "mpltools" # Check that the 'image' 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 as e: abort("Cannot import mpltools") # assert_source_and_install_match(package) outdir = "source/api" docwriter = ApiDocWriter(package) docwriter.package_skip_patterns += [r"\.fixes$", r"\.externals$"] docwriter.write_api_docs(outdir) docwriter.write_index(outdir, "api", relative_to="source/api") print("%d files written" % len(docwriter.written_modules))
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__) source_lines = open('../skimage/__init__.py').readlines() version = 'vUndefined' for l in source_lines: if l.startswith('__version__'): source_version = V(l.split("'")[1]) break if source_version != installed_version: abort("Installed version does not match source version") outdir = 'source/api' docwriter = ApiDocWriter(package) docwriter.package_skip_patterns += [ r'\.fixes$', r'\.externals$', r'filter$', r'viewer.viewers$', # all functions already imported to viewer ] docwriter.write_api_docs(outdir) docwriter.write_index(outdir, 'api', relative_to='source/api') print('%d files written' % len(docwriter.written_modules))
pass if source_version == '0+unknown': source_version = None if source_version is None: # Legacy fall-back info_file = pjoin('..', package, 'info.py') info_lines = open(info_file).readlines() source_version = '.'.join([v.split('=')[1].strip(" '\n.") for v in info_lines if re.match( '^_version_(major|minor|micro|extra)', v )]) print('***', source_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'\.fixes$', r'\.fixes.*$', r'\.externals$', r'\.externals.*$', r'.*test.*$', r'\.info.*$', r'\.pkg_info.*$', r'\.py3k.*$', ] docwriter.write_api_docs(outdir) docwriter.write_index(outdir, 'index', relative_to=outdir) print('%d files written' % len(docwriter.written_modules))
except ImportError, e: abort("Can not import scikits.image") 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.version) setup_lines = open('../setup.py').readlines() version = 'vUndefined' for l in setup_lines: if l.startswith('VERSION'): source_version = V(l.split("'")[1]) break if source_version != installed_version: abort("Installed version does not match source version") outdir = 'source/api' docwriter = ApiDocWriter(package) docwriter.package_skip_patterns += [r'\.fixes$', r'\.externals$', ] docwriter.write_api_docs(outdir) docwriter.write_index(outdir, 'api', relative_to='source/api') print '%d files written' % len(docwriter.written_modules)
docwriter.module_skip_patterns += [ r'\.core\.fakemodule', r'\.testing\.iptest', # Keeping these disabled is OK r'\.parallel\.controller\.mongodb', r'\.lib\.inputhookwx', r'\.lib\.inputhookgtk', r'\.cocoa', r'\.ipdoctest', r'\.Gnuplot', r'\.frontend\.process\.winprocess', r'\.frontend', r'\.Shell', ] # If we don't have pexpect, we can't load irunner, so skip any code that # depends on it try: import pexpect except ImportError: docwriter.module_skip_patterns += [r'\.lib\.irunner', r'\.testing\.mkdoctests'] # 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))
info_file = pjoin('..', package, 'info.py') info_lines = open(info_file).readlines() source_version = '.'.join([v.split('=')[1].strip(" '\n.") for v in info_lines if re.match( '^_version_(major|minor|micro|extra)', v )]) print('***', source_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'\.fixes$', r'\.externals$', r'\.reconst.eit$', r'\.tracking\.interfaces.*$', r'\.tracking\.gui_tools.*$', r'.*test.*$', r'\.utils.*$', r'\.viz.*$', r'\.boots\.resampling.*$', r'\.fixes.*$', r'\.info.*$', r'\.pkg_info.*$', ] docwriter.write_api_docs(outdir) docwriter.write_index(outdir, 'index', relative_to=outdir) print('%d files written' % len(docwriter.written_modules))
#!/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)
r"\.core\.display", r"\.lib\.display", # Shims r"\.config", r"\.consoleapp", r"\.frontend$", r"\.html", r"\.nbconvert", r"\.nbformat", r"\.parallel", r"\.qt", # this is deprecated. r"\.utils\.warn", # Private APIs (there should be a lot more here) r"\.terminal\.ptutils", ] # 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))