Example #1
0
def module_doc(tenv, module_name, output_dir="", source_dir="", 
               overwrite=False):
    """Generates documentation for module or package.
    
    :param tenv: Jinja2 templating environment.
    :param module_name: Full name of the module.
    :param source_dir: Source directory.
    :param output_dir: Output directory of generated documents, 
        **must be relative to the source directory!**
    :returns: Generated document path.
     
    """
    
    try:
        module, name = import_by_name(module_name)
    except ImportError, e:
        raise GenerateDocError("Failed to import '%s': %s" % (module_name, e))
Example #2
0
def recursive_module_doc(tenv, module_name, output_dir="", source_dir="", 
                         overwrite=False):
    """Recursively generates module documentation also for all submodules,
    and subpackages.
    
    :param tenv: Jinja2 templating environment. :param module_name: Module
    :param source_dir: Source directory.
    :param output_dir: Output directory of generated documents. **Must be
        relative to the source directory!** :returns: List of generated document
        paths.
    
    """
    
    module_files = []
    
    # We must try to import the module, so we can recurse to the submodules
    try:
        module, _name = import_by_name(module_name)
    except ImportError:
        log.warning("Unable to import '%s', docs for this module cannot "
                    "be generated.", module_name)
    else:
        
        # Try to generate documentation for this module 
        try:
            module_files.append(\
                module_doc(tenv, module_name, output_dir=output_dir, 
                           source_dir=source_dir, overwrite=overwrite))
        except GenerateDocError, er:
            log.warning("Unable to generate module doc for '%s':  %s", 
                        module_name, unicode(er))
    
        # Continue to found submodules
        for submodule_name in get_submodules(module):
            module_files.extend(\
                recursive_module_doc(tenv, _name + "." + submodule_name, 
                                     output_dir=output_dir, 
                                     source_dir=source_dir,
                                     overwrite=overwrite))