Beispiel #1
0
    def run(self):
        # type: () -> List[nodes.Node]
        self.env = env = self.state.document.settings.env
        self.genopt = Options()
        self.warnings = []  # type: List[nodes.Node]
        self.result = ViewList()

        names = [x.strip().split()[0] for x in self.content
                 if x.strip() and re.search(r'^[~a-zA-Z_]', x.strip()[0])]
        items = self.get_items(names)
        nodes = self.get_table(items)

        if 'toctree' in self.options:
            dirname = posixpath.dirname(env.docname)

            tree_prefix = self.options['toctree'].strip()
            docnames = []
            for name, sig, summary, real_name in items:
                docname = posixpath.join(tree_prefix, real_name)
                docname = posixpath.normpath(posixpath.join(dirname, docname))
                if docname not in env.found_docs:
                    self.warn('toctree references unknown document %r'
                              % docname)
                docnames.append(docname)

            tocnode = addnodes.toctree()
            tocnode['includefiles'] = docnames
            tocnode['entries'] = [(None, docn) for docn in docnames]
            tocnode['maxdepth'] = -1
            tocnode['glob'] = None

            tocnode = autosummary_toc('', '', tocnode)
            nodes.append(tocnode)

        return self.warnings + nodes
Beispiel #2
0
 def __init__(self) -> None:
     settings = Struct(tab_width=8)
     document = Struct(settings=settings)
     env = BuildEnvironment()
     env.config = Config()
     state = Struct(document=document)
     super().__init__(env, None, Options(), 0, state)
Beispiel #3
0
    def run(self):
        # type: () -> List[nodes.Node]
        self.bridge = DocumenterBridge(self.env, self.state.document.reporter,
                                       Options(), self.lineno)

        names = [x.strip().split()[0] for x in self.content
                 if x.strip() and re.search(r'^[~a-zA-Z_]', x.strip()[0])]
        items = self.get_items(names)
        nodes = self.get_table(items)

        if 'toctree' in self.options:
            dirname = posixpath.dirname(self.env.docname)

            tree_prefix = self.options['toctree'].strip()
            docnames = []
            excluded = Matcher(self.config.exclude_patterns)
            for name, sig, summary, real_name in items:
                docname = posixpath.join(tree_prefix, real_name)
                docname = posixpath.normpath(posixpath.join(dirname, docname))
                if docname not in self.env.found_docs:
                    if excluded(self.env.doc2path(docname, None)):
                        logger.warning(__('toctree references excluded document %r'), docname)
                    else:
                        logger.warning(__('toctree references unknown document %r'), docname)
                docnames.append(docname)

            tocnode = addnodes.toctree()
            tocnode['includefiles'] = docnames
            tocnode['entries'] = [(None, docn) for docn in docnames]
            tocnode['maxdepth'] = -1
            tocnode['glob'] = None

            nodes.append(autosummary_toc('', '', tocnode))

        return nodes
Beispiel #4
0
 def __init__(self) -> None:
     settings = Struct(tab_width=8)
     document = Struct(settings=settings)
     app = FakeApplication()
     app.config.add('autodoc_class_signature', 'mixed', True, None)
     env = BuildEnvironment(app)  # type: ignore
     state = Struct(document=document)
     super().__init__(env, None, Options(), 0, state)
Beispiel #5
0
 def __init__(self) -> None:
     settings = Struct(tab_width=8)
     document = Struct(settings=settings)
     env = BuildEnvironment()
     env.config = Config()
     env.config.add('autodoc_class_signature', 'mixed', True, None)
     state = Struct(document=document)
     super().__init__(env, None, Options(), 0, state)
    def run(self) -> List[Node]:
        self.bridge = DocumenterBridge(self.env, self.state.document.reporter,
                                       Options(), self.lineno, self.state)

        names = [
            x.strip().split()[0] for x in self.content
            if x.strip() and re.search(r"^[~a-zA-Z_]",
                                       x.strip()[0])
        ]
        items = self.get_items(names)
        nodes = self.get_table(items)

        if "toctree" in self.options:
            dirname = posixpath.dirname(self.env.docname)

            tree_prefix = self.options["toctree"].strip()
            docnames = []
            excluded = Matcher(self.config.exclude_patterns)
            filename_map = self.config.autosummary_filename_map
            for name, sig, summary, real_name, _ in items:
                real_name = filename_map.get(real_name, real_name)
                docname = posixpath.join(tree_prefix, real_name)
                docname = posixpath.normpath(posixpath.join(dirname, docname))
                if docname not in self.env.found_docs:
                    if excluded(self.env.doc2path(docname, None)):
                        msg = __(
                            "autosummary references excluded document %r. Ignored."
                        )
                    else:
                        msg = __("autosummary: stub file not found %r. "
                                 "Check your autosummary_generate setting.")

                    logger.warning(msg,
                                   real_name,
                                   location=self.get_source_info())
                    continue

                docnames.append(docname)

            if docnames:
                tocnode = addnodes.toctree()
                tocnode["includefiles"] = docnames
                tocnode["entries"] = [(None, docn) for docn in docnames]
                tocnode["maxdepth"] = -1
                tocnode["glob"] = None
                tocnode["caption"] = self.options.get("caption")

                nodes.append(autosummary_toc("", "", tocnode))
        if "toctree" not in self.options and "caption" in self.options:
            logger.warning(
                __("A captioned autosummary requires :toctree: option. ignored."
                   ),
                location=nodes[-1],
            )

        return nodes
Beispiel #7
0
    def run(self) -> List[Node]:
        self.bridge = DocumenterBridge(self.env, self.state.document.reporter,
                                       Options(), self.lineno, self.state)

        names = [
            x.strip().split()[0] for x in self.content
            if x.strip() and re.search(r'^[~a-zA-Z_]',
                                       x.strip()[0])
        ]
        items = self.get_items(names)
        nodes = self.get_table(items)

        if 'toctree' in self.options:
            dirname = posixpath.dirname(self.env.docname)

            tree_prefix = self.options['toctree'].strip()
            docnames = []
            excluded = Matcher(self.config.exclude_patterns)
            filename_map = self.config.autosummary_filename_map
            for _name, _sig, _summary, real_name in items:
                real_name = filename_map.get(real_name, real_name)
                docname = posixpath.join(tree_prefix, real_name)
                docname = posixpath.normpath(posixpath.join(dirname, docname))
                if docname not in self.env.found_docs:
                    if excluded(self.env.doc2path(docname, False)):
                        msg = __(
                            'autosummary references excluded document %r. Ignored.'
                        )
                    else:
                        msg = __('autosummary: stub file not found %r. '
                                 'Check your autosummary_generate setting.')

                    logger.warning(msg,
                                   real_name,
                                   location=self.get_location())
                    continue

                docnames.append(docname)

            if docnames:
                tocnode = addnodes.toctree()
                tocnode['includefiles'] = docnames
                tocnode['entries'] = [(None, docn) for docn in docnames]
                tocnode['maxdepth'] = -1
                tocnode['glob'] = None
                tocnode['caption'] = self.options.get('caption')

                nodes.append(autosummary_toc('', '', tocnode))

        if 'toctree' not in self.options and 'caption' in self.options:
            logger.warning(__(
                'A captioned autosummary requires :toctree: option. ignored.'),
                           location=nodes[-1])

        return nodes
Beispiel #8
0
    def run(self):
        # type: () -> List[nodes.Node]
        self.bridge = DocumenterBridge(self.env, self.state.document.reporter,
                                       Options(), self.lineno, self.state)

        names = [
            x.strip().split()[0] for x in self.content
            if x.strip() and re.search(r'^[~a-zA-Z_]',
                                       x.strip()[0])
        ]
        items = self.get_items(names)
        nodes = self.get_table(items)

        if 'toctree' in self.options:
            dirname = posixpath.dirname(self.env.docname)

            tree_prefix = self.options['toctree'].strip()
            docnames = []
            excluded = Matcher(self.config.exclude_patterns)
            for name, sig, summary, real_name in items:
                docname = posixpath.join(tree_prefix, real_name)
                docname = posixpath.normpath(posixpath.join(dirname, docname))
                if docname not in self.env.found_docs:
                    location = self.state_machine.get_source_and_line(
                        self.lineno)
                    if excluded(self.env.doc2path(docname, None)):
                        msg = __(
                            'autosummary references excluded document %r. Ignored.'
                        )
                    else:
                        msg = __('autosummary: stub file not found %r. '
                                 'Check your autosummary_generate setting.')

                    logger.warning(msg, real_name, location=location)
                    continue

                docnames.append(docname)

            if docnames:
                tocnode = addnodes.toctree()
                tocnode['includefiles'] = docnames
                tocnode['entries'] = [(None, docn) for docn in docnames]
                tocnode['maxdepth'] = -1
                tocnode['glob'] = None

                nodes.append(autosummary_toc('', '', tocnode))

        return nodes
Beispiel #9
0
 def __init__(self) -> None:
     settings = Struct(tab_width=8)
     document = Struct(settings=settings)
     state = Struct(document=document)
     super().__init__({}, None, Options(), 0, state)  # type: ignore
Beispiel #10
0
 def __init__(self):
     # type: () -> None
     super().__init__({}, None, Options(), 0)  # type: ignore
Beispiel #11
0
 def __init__(self):
     super(FakeDirective, self).__init__({}, None, Options(), 0)  # type: ignore