Exemple #1
0
def run_apidoc(_):

    # Import the sporco.admm and sporco.fista modules and undo the
    # effect of sporco.util._module_name_nested so that docs for
    # Options classes appear in the correct locations
    import inspect
    import sporco.admm
    for mnm, mod in inspect.getmembers(sporco.admm, inspect.ismodule):
        for cnm, cls in inspect.getmembers(mod, inspect.isclass):
            if hasattr(cls, 'Options') and inspect.isclass(
                    getattr(cls, 'Options')):
                optcls = getattr(cls, 'Options')
                if optcls.__name__ != 'Options':
                    delattr(mod, optcls.__name__)
                    optcls.__name__ = 'Options'

    import sporco.fista
    for mnm, mod in inspect.getmembers(sporco.fista, inspect.ismodule):
        for cnm, cls in inspect.getmembers(mod, inspect.isclass):
            if hasattr(cls, 'Options') and inspect.isclass(
                    getattr(cls, 'Options')):
                optcls = getattr(cls, 'Options')
                if optcls.__name__ != 'Options':
                    delattr(mod, optcls.__name__)
                    optcls.__name__ = 'Options'

    import sphinx.apidoc
    module = '../../sporco' if on_rtd else 'sporco'
    cpath = os.path.abspath(os.path.dirname(__file__))
    opath = cpath

    # Insert documentation for inherited solve methods
    callgraph.insert_solve_docs()

    # Remove auto-generated sporco.rst, sporco.admm.rst, and sporco.fista.rst
    rst = os.path.join(cpath, 'sporco.rst')
    if os.path.exists(rst):
        os.remove(rst)
    rst = os.path.join(cpath, 'sporco.admm.rst')
    if os.path.exists(rst):
        os.remove(rst)
    rst = os.path.join(cpath, 'sporco.fista.rst')
    if os.path.exists(rst):
        os.remove(rst)

    # Run sphinx-apidoc
    print("Running sphinx-apidoc with output path " + opath)
    sys.stdout.flush()
    sphinx.apidoc.main([
        'sphinx-apidoc', '-e', '-d', '2', '-o', opath, module,
        os.path.join(module, 'admm/tests'),
        os.path.join(module, 'fista/tests')
    ])

    # Remove "Module contents" sections from specified autodoc generated files
    rmmodlst = ['sporco.rst', 'sporco.admm.rst', 'sporco.fista.rst']
    for fnm in rmmodlst:
        rst = os.path.join(cpath, fnm)
        if os.path.exists(rst):
            rmsection(rst, r'^Module contents')
Exemple #2
0
def run_apidoc(_):

    # Import the sporco.admm, sporco.fista, and sporco.dictlrn modules and
    # undo the effect of common._fix_nested_class_lookup so that docs for
    # Options classes appear in the correct locations
    import sporco.admm
    options_name_fix(sporco.admm)
    import sporco.fista
    options_name_fix(sporco.fista)

    import sphinx.apidoc
    module = '../../sporco' if on_rtd else 'sporco'
    cpath = os.path.abspath(os.path.dirname(__file__))
    opath = cpath

    # Insert documentation for inherited solve methods
    callgraph.insert_solve_docs()

    # Remove auto-generated sporco.rst, sporco.admm.rst, and sporco.fista.rst
    rst = os.path.join(cpath, 'sporco.rst')
    if os.path.exists(rst):
        os.remove(rst)
    rst = os.path.join(cpath, 'sporco.admm.rst')
    if os.path.exists(rst):
        os.remove(rst)
    rst = os.path.join(cpath, 'sporco.fista.rst')
    if os.path.exists(rst):
        os.remove(rst)

    # Run sphinx-apidoc
    print("Running sphinx-apidoc with output path " + opath)
    sys.stdout.flush()
    from distutils.version import LooseVersion
    if LooseVersion(sphinx.__version__) < LooseVersion('1.7.0'):
        sphinx.apidoc.main([
            'sphinx-apidoc', '-e', '-d', '2', '-o', opath, module,
            os.path.join(module, 'admm/tests'),
            os.path.join(module, 'fista/tests')
        ])
    else:
        sphinx.ext.apidoc.main([
            '-o', opath, '-e', '-d', '2', module,
            os.path.join(module, 'admm/tests'),
            os.path.join(module, 'fista/tests')
        ])

    # Remove "Module contents" sections from specified autodoc generated files
    rmmodlst = ['sporco.rst', 'sporco.admm.rst', 'sporco.fista.rst']
    for fnm in rmmodlst:
        rst = os.path.join(cpath, fnm)
        if os.path.exists(rst):
            rmsection(rst, r'^Module contents')
Exemple #3
0
def insertsolve(_):
    # Insert documentation for inherited solve methods
    callgraph.insert_solve_docs()
Exemple #4
0
def insertsolve(_):
    # Insert documentation for inherited solve methods
    callgraph.insert_solve_docs()