Trick sphinx into displaying the desired module in these objects' documentation.
184477
def _set_module_names_for_sphinx(modules: List, new_name: str):
    
    for obj in modules:
        obj.__module__ = new_name
1007633
def generate_documentation(schema):
    

    documentation_title = "Configuration documentation"
    documentation = documentation_title + "\n"
    documentation += "=" * len(documentation_title) + '\n'

    for section_name in schema:
        section_created = False

        for option_name in schema[section_name]:

            option = schema[section_name][option_name]

            if not section_created:
                documentation += '\n'
                documentation += section_name + '\n'
                documentation += '-' * len(section_name) + '\n'
                section_created = True

            documentation += '\n'
            documentation += option_name + '\n'
            documentation += '~' * len(option_name) + '\n'

            if option.get('required'):

                documentation += "** This option is required! **\n"

            if option.get('type'):

                documentation += '*Type : %s.*\n' % option.get('type')

            if option.get('description'):

                documentation += option.get('description') + '\n'

            if option.get('default'):

                documentation += 'The default value is %s.\n' % option.get('default')

            if option.get('deprecated'):

                documentation += "** This option is deprecated! **\n"

    return documentation
342019
def doc_module(module_name, module, output_dir, source_location, leaf):
    
    path = pathlib.Path(output_dir).joinpath(*module.__name__.split("."))
    available_classes = get_available_classes(module)
    deffed_classes = get_classes(module)
    deffed_funcs = get_funcs(module)
    deffed_enums = get_enums(module)
    alias_funcs = available_classes - deffed_classes
    if leaf:
        doc_path = path.with_suffix(".md")
    else:
        doc_path = path / "index.md"
    doc_path.parent.mkdir(parents=True, exist_ok=True)
    module_path = "/".join(module.__name__.split("."))
    doc = [f"title: {module_name.split('.')[-1]}" + "\n"]
    module_doc = module.__doc__

    # Module overview documentation
    if module_doc is not None:
        doc += to_doc(module.__name__, module, 1, source_location)
    else:
        doc.append(f"# {module.__name__}\n\n")
    doc.append("\n\n")
    for cls_name, cls in sorted(deffed_enums) + sorted(deffed_classes):
        doc += to_doc(cls_name, cls, 2, source_location)

        class_methods = [
            x
            for x in inspect.getmembers(cls, inspect.isfunction)
            if (not x[0].startswith("_")) and deffed_here(x[1], cls)
        ]
        class_methods += inspect.getmembers(cls, lambda o: isinstance(o, property))
        if len(class_methods) > 0:
            doc.append("### Methods \n\n")
            for method_name, method in class_methods:
                doc += to_doc(method_name, method, 4, source_location)
    for fname, func in sorted(deffed_funcs):
        doc += to_doc(fname, func, 2, source_location)
    return doc_path.absolute(), "".join(doc)
300426
def bind(self):
        """"""
        self.endline <<= attach(self.endline_ref, self.endline_handle)

        self.moduledoc_item <<= trace(attach(self.moduledoc, self.set_docstring))
        self.name <<= trace(attach(self.base_name, self.name_check))
        # comments are evaluated greedily because we need to know about them even if we're going to suppress them
        self.comment <<= trace(attach(self.comment_ref, self.comment_handle, greedy=True))
        self.set_literal <<= trace(attach(self.set_literal_ref, self.set_literal_handle))
        self.set_letter_literal <<= trace(attach(self.set_letter_literal_ref, self.set_letter_literal_handle))
        self.classlist <<= trace(attach(self.classlist_ref, self.classlist_handle))
        self.import_stmt <<= trace(attach(self.import_stmt_ref, self.import_handle))
        self.complex_raise_stmt <<= trace(attach(self.complex_raise_stmt_ref, self.complex_raise_stmt_handle))
        self.augassign_stmt <<= trace(attach(self.augassign_stmt_ref, self.augassign_handle))
        self.dict_comp <<= trace(attach(self.dict_comp_ref, self.dict_comp_handle))
        self.destructuring_stmt <<= trace(attach(self.destructuring_stmt_ref, self.destructuring_stmt_handle))
        self.name_match_funcdef <<= trace(attach(self.name_match_funcdef_ref, self.name_match_funcdef_handle))
        self.op_match_funcdef <<= trace(attach(self.op_match_funcdef_ref, self.op_match_funcdef_handle))
        self.yield_from <<= trace(attach(self.yield_from_ref, self.yield_from_handle))
        self.exec_stmt <<= trace(attach(self.exec_stmt_ref, self.exec_stmt_handle))
        self.stmt_lambdef <<= trace(attach(self.stmt_lambdef_ref, self.stmt_lambdef_handle))
        self.typedef <<= trace(attach(self.typedef_ref, self.typedef_handle))
        self.typedef_default <<= trace(attach(self.typedef_default_ref, self.typedef_handle))
        self.unsafe_typedef_default <<= trace(attach(self.unsafe_typedef_default_ref, self.unsafe_typedef_handle))
        self.return_typedef <<= trace(attach(self.return_typedef_ref, self.typedef_handle))
        self.typed_assign_stmt <<= trace(attach(self.typed_assign_stmt_ref, self.typed_assign_stmt_handle))
        self.datadef <<= trace(attach(self.datadef_ref, self.data_handle))
        self.with_stmt <<= trace(attach(self.with_stmt_ref, self.with_stmt_handle))
        self.await_item <<= trace(attach(self.await_item_ref, self.await_item_handle))
        self.ellipsis <<= trace(attach(self.ellipsis_ref, self.ellipsis_handle))
        self.case_stmt <<= trace(attach(self.case_stmt_ref, self.case_stmt_handle))

        self.decoratable_normal_funcdef_stmt <<= trace(attach(
            self.decoratable_normal_funcdef_stmt_ref,
            self.decoratable_funcdef_stmt_handle,
        ))
        self.decoratable_async_funcdef_stmt <<= trace(attach(
            self.decoratable_async_funcdef_stmt_ref,
            partial(self.decoratable_funcdef_stmt_handle, is_async=True),
        ))

        self.u_string <<= attach(self.u_string_ref, self.u_string_check)
        self.matrix_at <<= attach(self.matrix_at_ref, self.matrix_at_check)
        self.nonlocal_stmt <<= attach(self.nonlocal_stmt_ref, self.nonlocal_check)
        self.star_assign_item <<= attach(self.star_assign_item_ref, self.star_assign_item_check)
        self.classic_lambdef <<= attach(self.classic_lambdef_ref, self.lambdef_check)
        self.star_expr <<= attach(self.star_expr_ref, self.star_expr_check)
        self.dubstar_expr <<= attach(self.dubstar_expr_ref, self.star_expr_check)
        self.star_sep_arg <<= attach(self.star_sep_arg_ref, self.star_sep_check)
        self.star_sep_vararg <<= attach(self.star_sep_vararg_ref, self.star_sep_check)
        self.endline_semicolon <<= attach(self.endline_semicolon_ref, self.endline_semicolon_check)
        self.async_stmt <<= attach(self.async_stmt_ref, self.async_stmt_check)
        self.async_comp_for <<= attach(self.async_comp_for_ref, self.async_comp_check)
        self.f_string <<= attach(self.f_string_ref, self.f_string_check)
1158472
def get_module_toc(mod_name):
    ""
    mod = import_mod(mod_name)
    ft_names = mod.__all__ if hasattr(mod,'__all__') else get_ft_names(mod)
    ft_names.sort(key = str.lower)
    tabmat = ''
    for ft_name in ft_names:
        tabmat += f'- [{ft_name}](#{ft_name})\n'
        elt = getattr(mod, ft_name)
        if inspect.isclass(elt) and not is_enum(elt.__class__):
            in_ft_names = get_inner_fts(elt)
            for name in in_ft_names:
                tabmat += f'  - [{name}](#{name})\n'
    display(Markdown(tabmat))
1341705
def generate_docs(app):
    
    config = app.config
    config_dir = app.env.srcdir
    source_root = os.path.join(config_dir, config.apidoc_source_root)
    output_root = os.path.join(config_dir, config.apidoc_output_root)
    execution_dir = os.path.join(config_dir, '..')

    # Remove any files generated by earlier builds
    cleanup(output_root)

    command = ['sphinx-apidoc', '-f', '-o', output_root, source_root]
    # Exclude anything else we were specifically asked to
    for exclude in config.apidoc_exclude:
        command.append(os.path.join(source_root, exclude))
    process = Popen(command, cwd=execution_dir)
    process.wait()
676642
def parse_sphinx_docopts(index):
    

    pos = index.find('var DOCUMENTATION_OPTIONS')
    if pos < 0:
        raise ValueError('Documentation options could not be found in index.')
    pos = index.find('{', pos)
    if pos < 0:
        raise ValueError('Documentation options could not be found in index.')
    endpos = index.find('};', pos)
    if endpos < 0:
        raise ValueError('Documentation options could not be found in index.')
    block = index[pos + 1:endpos].strip()
    docopts = {}
    for line in block.splitlines():
        key, value = line.split(':', 1)
        key = key.strip().strip('"')

        value = value.strip()
        if value[-1] == ',':
            value = value[:-1].rstrip()
        if value[0] in '"\'':
            value = value[1:-1]
        elif value == 'false':
            value = False
        elif value == 'true':
            value = True
        else:
            try:
                value = int(value)
            except ValueError:
                # In Sphinx 1.7.5, URL_ROOT is a JavaScript fragment.
                # Ignoring this entry since URL_ROOT is not used
                # elsewhere.
                # https://github.com/sphinx-gallery/sphinx-gallery/issues/382
                continue

        docopts[key] = value

    return docopts
1034499
def append_summary_to_module_docstring(module):
  
  pairs = [(name, getattr(module, name)) for name in module.__all__]
  kws = dict(key_header="Name", summary_type="module contents")
  module.__doc__ = docstring_with_summary(module.__doc__, pairs, **kws)
287669
def generate_docs(klass):
    """"""
    import numina.types.datatype

    attrh = ('Attributes\n'
             '----------\n')

    doc = getattr(klass, '__doc__', None)

    if doc is None or doc == '':
        doc = "%s documentation." % klass.__name__

    if len(klass.stored()):
        doc = doc + '\n\n' + attrh

    skeys = sorted(klass.stored().keys())
    for key in skeys:
        y = klass.stored()[key]

        if isinstance(y, Requirement):
            modo = 'requirement'
        elif isinstance(y, Result):
            modo = 'product'
        else:
            modo = ""
        if y.type.isproduct():
            tipo = y.type.__class__.__name__
        elif isinstance(y.type, numina.types.datatype.PlainPythonType):
            tipo = y.type.internal_type.__name__
        else:
            tipo = y.type.__class__.__name__

        if y.optional:
            if y.default_value():
                modo = "%s, optional, default=%s" % (modo, y.default)
            else:
                modo = "%s, optional" % (modo,)

        descript = y.description
        if descript:
            field = "%s : %s, %s\n %s\n" % (key, tipo, modo, descript)
        else:
            field = "%s : %s, %s\n" % (key, tipo, modo)
        doc = doc + field

    klass.__doc__ = doc
    return klass
325097
def docs(context, builder='html'):
    ""
    cmdline = 'python -msphinx -M {} {} {} {}'.format(builder, DOCS_SRCDIR, DOCS_BUILDDIR, SPHINX_OPTS)
    context.run(cmdline)
1153791
def setup(sphinx):
    
    create_auto_documentation()

    # add the py3status lexer (for code blocks)
    from sphinx.highlighting import lexers
    lexers['py3status'] = Py3statusLexer()

    # enable screenshot directive for dynamic screenshots
    sphinx.add_directive('screenshot', ScreenshotDirective)
734839
def printImportedNames(self):
        """"""
        for module in self.listModules():
            print("%s:" % module.modname)
            print("  %s" % "\n  ".join(imp.name for imp in module.imported_names))
940634
def pandoc_process(app, what, name, obj, options, lines):
    "

    if not lines:
        return None

    input_format = app.config.mkdsupport_use_parser
    output_format = 'rst'

    # Since default encoding for sphinx.ext.autodoc is unicode and pypandoc.convert_text, which will always return a
    # unicode string, expects unicode or utf-8 encodes string, there is on need for dealing with coding
    text = SEP.join(lines)
    text = pypandoc.convert_text(text, output_format, format=input_format)

    # The 'lines' in Sphinx is a list of strings and the value should be changed
    del lines[:]
    lines.extend(text.split(SEP))
467568
def process_docstring(app, what, name, obj, options, lines):
    """"""
    # pylint: disable=unused-argument
    # pylint: disable=too-many-arguments
    lines.extend(_format_contracts(what=what, obj=obj))
131852
def get_index_text(self, modname, name_cls):
        """"""
        name, cls = name_cls
        add_modules = self.env.config.add_module_names
        if self.objtype.endswith('method'):
            try:
                clsname, methname = name.rsplit('.', 1)
            except ValueError:
                if modname:
                    return _('%s() (in module %s)') % (name, modname)
                else:
                    return _('%s()') % name
            if modname and add_modules:
                return _('%s() (%s.%s %s)') % \
                    (methname, modname, clsname, self.chpl_type_name)
            else:
                return _('%s() (%s %s)') % \
                    (methname, clsname, self.chpl_type_name)
        elif self.objtype == 'attribute':
            try:
                clsname, attrname = name.rsplit('.', 1)
            except ValueError:
                if modname:
                    return _('%s (in module %s)') % (name, modname)
                else:
                    return name
            if modname and add_modules:
                return _('%s (%s.%s attribute)') % (attrname, modname, clsname)
            else:
                return _('%s (%s attribute)') % (attrname, clsname)
        else:
            return ''
128663
def doc():
    """"""
    kwdb = current_app.kwdb

    libraries = get_collections(kwdb, libtype="library")
    resource_files = get_collections(kwdb, libtype="resource")
    hierarchy = get_navpanel_data(kwdb)

    return flask.render_template("home.html",
                                 data={"libraries": libraries,
                                       "version": __version__,
                                       "libdoc": None,
                                       "hierarchy": hierarchy,
                                       "resource_files": resource_files
                                   })
193651
def get_imported_modules(self, module):
    """"""
    for name, member in inspect.getmembers(module):
      if inspect.ismodule(member):
        yield name, member