def METHOD_NAME(package, modules, dir='api', absolute=True, root=None):
    """
    Generate .rst files in *dir* from *modules* in *package*.
    *dir* defaults to 'api'
    *absolute* is True if modules are listed as package.module in the table
    of contents.  Default is True.
    *root* is the path to the package source.  This may be different from
    the location of the package in the python path if the documentation is
    extracted from the build directory rather than the source directory.
    The source is used to check if the module definition has changed since
    the rst file was built.
    """
    # Get path to package source
    if root is None:
        __import__(package)
        M = sys.modules[package]
        root = abspath(dirname(M.__file__))
    # Build path to documentation tree
    prefix = package+"." if absolute else ""
    if not exists(dir):
        makedirs(dir)
    # Update any modules that are out of date.  Compiled modules
    # will always be updated since we only check for .py files.
    for (module, title) in modules:
        modfile = joinpath(root, module+'.py')
        rstfile = joinpath(dir, module+'.rst')
        if not exists(modfile):
            __import__(package+"."+module)
            modfile = sys.modules[package+"."+module].__file__
        if newer(rstfile, modfile):
            members = "\n    ".join(get_members(package, module))
            #print("writing %s"%rstfile)
            with open(rstfile, 'w') as f:
                f.write(MODULE_TEMPLATE%locals())
    # Update the table of contents, but only if the configuration
    # file containing the module list has changed.  For now, that
    # is the current file.
    api_index = joinpath(dir, 'index.rst')
    if newer(api_index, __file__):
        rsts = "\n   ".join(module+'.rst' for module, _ in modules)
        mods = "\n   ".join(prefix+module for module, _ in modules)
        #print("writing %s"%api_index)
        with open(api_index, 'w') as f:
            f.write(PACKAGE_TEMPLATE%locals())