def make_interface():
    """Generate the RST files for the API doc of ODL."""
    modnames = ['odl'] + list(import_submodules(odl).keys())

    for modname in modnames:
        if not modname.startswith('odl'):
            modname = 'odl.' + modname

        shortmodname = modname.split('.')[-1]
        print('{: <25} : generated {}.rst'.format(shortmodname, modname))

        line = '=' * len(shortmodname)

        module = importlib.import_module(modname)

        docstring = module.__doc__
        submodules = [m[0] for m in inspect.getmembers(
            module, inspect.ismodule) if m[1].__name__.startswith('odl')]
        functions = [m[0] for m in inspect.getmembers(
            module, inspect.isfunction) if m[1].__module__ == modname]
        classes = [m[0] for m in inspect.getmembers(
            module, inspect.isclass) if m[1].__module__ == modname]

        docstring = '' if docstring is None else docstring

        submodules = [modname + '.' + mod for mod in submodules]
        functions = ['~' + modname + '.' + fun
                     for fun in functions if not fun.startswith('_')]
        classes = ['~' + modname + '.' + cls
                   for cls in classes if not cls.startswith('_')]

        if len(submodules) > 0:
            this_mod_string = module_string.format('\n   '.join(submodules))
        else:
            this_mod_string = ''

        if len(functions) > 0:
            this_fun_string = fun_string.format('\n   '.join(functions))
        else:
            this_fun_string = ''

        if len(classes) > 0:
            this_class_string = class_string.format('\n   '.join(classes))
        else:
            this_class_string = ''

        with open(modname + '.rst', 'w') as text_file:
            text_file.write(string.format(shortname=shortmodname,
                                          name=modname,
                                          line=line,
                                          docstring=docstring,
                                          module_string=this_mod_string,
                                          fun_string=this_fun_string,
                                          class_string=this_class_string))
def make_interface ( ) : modnames = [ 'odl' ] + list ( import_submodules ( odl ) . keys ( ) ) for modname in modnames : if not modname . startswith ( 'odl' ) : modname = 'odl.' + modname shortmodname = modname . split ( '.' ) [ - 1 ] print ( '{: <25} : generated {}.rst' . format ( shortmodname , modname ) ) line = '=' * len ( shortmodname ) module = importlib . import_module ( modname ) docstring = module . __doc__ submodules = [ m [ 0 ] for m in inspect . getmembers ( module , inspect . ismodule ) if m [ 1 ] . __name__ . startswith ( 'odl' ) ] functions = [ m [ 0 ] for m in inspect . getmembers ( module , inspect . isfunction ) if m [ 1 ] . __module__ == modname ] classes = [ m [ 0 ] for m in inspect . getmembers ( module , inspect . isclass ) if m [ 1 ] . __module__ == modname ] docstring = '' if docstring is None else docstring submodules = [ modname + '.' + mod for mod in submodules ] functions = [ '~' + modname + '.' + fun for fun in functions if not fun . startswith ( '_' ) ] classes = [ '~' + modname + '.' + cls for cls in classes if not cls . startswith ( '_' ) ] if len ( submodules ) > 0 : this_mod_string = module_string . format ( '\n   ' . join ( submodules ) ) else : this_mod_string = '' if len ( functions ) > 0 : this_fun_string = fun_string . format ( '\n   ' . join ( functions ) ) else : this_fun_string = '' if len ( classes ) > 0 : this_class_string = class_string . format ( '\n   ' . join ( classes ) ) else : this_class_string = '' with open ( modname + '.rst' , 'w' ) as text_file : text_file . write ( string . format ( shortname = shortmodname , name = modname , line = line , docstring = docstring , module_string = this_mod_string , fun_string = this_fun_string , class_string = this_class_string ) )
Generate the RST files for the API doc of ODL.