• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python addnodes.toctree函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中sphinx.addnodes.toctree函数的典型用法代码示例。如果您正苦于以下问题:Python toctree函数的具体用法?Python toctree怎么用?Python toctree使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了toctree函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: toctree_directive

def toctree_directive(name, arguments, options, content, lineno,
                      content_offset, block_text, state, state_machine):
    env = state.document.settings.env
    suffix = env.config.source_suffix
    dirname = posixpath.dirname(env.docname)

    ret = []
    subnode = addnodes.toctree()
    includefiles = []
    includetitles = {}
    for docname in content:
        if not docname:
            continue
        # look for explicit titles and documents ("Some Title <document>").
        m = caption_ref_re.match(docname)
        if m:
            docname = m.group(2)
            includetitles[docname] = m.group(1)    
        # absolutize filenames, remove suffixes
        if docname.endswith(suffix):
            docname = docname[:-len(suffix)]
        docname = posixpath.normpath(posixpath.join(dirname, docname))
        if docname not in env.found_docs:
            ret.append(state.document.reporter.warning(
                'toctree references unknown document %r' % docname, line=lineno))
        else:
            includefiles.append(docname)
    subnode['includefiles'] = includefiles
    subnode['includetitles'] = includetitles
    subnode['maxdepth'] = options.get('maxdepth', -1)
    ret.append(subnode)
    return ret
开发者ID:lshmenor,项目名称:IMTAphy,代码行数:32,代码来源:directives.py


示例2: run

    def run(self):
        self.env = env = self.state.document.settings.env
        self.genopt = {}
        self.warnings = []

        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:
            suffix = env.config.source_suffix
            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, docname) for docname in docnames]
            tocnode['maxdepth'] = -1
            tocnode['glob'] = None

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

        return self.warnings + nodes
开发者ID:Fematich,项目名称:article_browser,代码行数:34,代码来源:__init__.py


示例3: run

    def run(self):
        self.warnings = []

        env = self.state.document.settings.env
        mapper = env.autoapi_mapper

        objects = [mapper.all_objects[name] for name in self._get_names()]
        nodes_ = self._get_table(objects)

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

            tree_prefix = self.options["toctree"].strip()
            docnames = []
            for obj in objects:
                docname = posixpath.join(tree_prefix, obj.name)
                docname = posixpath.normpath(posixpath.join(dirname, docname))
                if docname not in env.found_docs:
                    self.warn("toctree references unknown document {}".format(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 = sphinx.ext.autosummary.autosummary_toc("", "", tocnode)
            nodes_.append(tocnode)

        return self.warnings + nodes_
开发者ID:rtfd,项目名称:sphinx-autoapi,代码行数:31,代码来源:directives.py


示例4: run

    def run(self):
        # type: () -> List[nodes.Node]
        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(self.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 self.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
开发者ID:mgeier,项目名称:sphinx,代码行数:34,代码来源:__init__.py


示例5: create_toc

def create_toc(names, maxdepth=-1):
    """Create toc node entries for names.
    
    """
    tocnode = addnodes.toctree()
    tocnode['includefiles'] = [name for _short_name, name in names]
    tocnode['entries'] = [(short_name, name) for short_name, name in names]
    tocnode['maxdepth'] = maxdepth
    tocnode['glob'] = None
    return tocnode
开发者ID:Ciantic,项目名称:sphinkydoc,代码行数:10,代码来源:sphinkydoc.py


示例6: toctree_directive

def toctree_directive(name, arguments, options, content, lineno,
                      content_offset, block_text, state, state_machine):
    env = state.document.settings.env
    suffix = env.config.source_suffix
    dirname = posixpath.dirname(env.docname)
    glob = 'glob' in options

    ret = []
    subnode = addnodes.toctree()
    includefiles = []
    includetitles = {}
    all_docnames = env.found_docs.copy()
    # don't add the currently visited file in catch-all patterns
    all_docnames.remove(env.docname)
    for entry in content:
        if not entry:
            continue
        if not glob:
            # look for explicit titles and documents ("Some Title <document>").
            m = caption_ref_re.match(entry)
            if m:
                docname = m.group(2)
                includetitles[docname] = m.group(1)
            else:
                docname = entry
            # remove suffixes (backwards compatibility)
            if docname.endswith(suffix):
                docname = docname[:-len(suffix)]
            # absolutize filenames
            docname = posixpath.normpath(posixpath.join(dirname, docname))
            if docname not in env.found_docs:
                ret.append(state.document.reporter.warning(
                    'toctree references unknown document %r' % docname, line=lineno))
            else:
                includefiles.append(docname)
        else:
            patname = posixpath.normpath(posixpath.join(dirname, entry))
            docnames = sorted(patfilter(all_docnames, patname))
            for docname in docnames:
                all_docnames.remove(docname) # don't include it again
                includefiles.append(docname)
            if not docnames:
                ret.append(state.document.reporter.warning(
                    'toctree glob pattern %r didn\'t match any documents' % entry,
                    line=lineno))
    subnode['includefiles'] = includefiles
    subnode['includetitles'] = includetitles
    subnode['maxdepth'] = options.get('maxdepth', -1)
    subnode['glob'] = glob
    ret.append(subnode)
    return ret
开发者ID:fedor4ever,项目名称:linux_build,代码行数:51,代码来源:other.py


示例7: run

    def run(self):
        self.env = env = self.state.document.settings.env
        self.genopt = {}
        self.warnings = []

        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:
            suffixes = env.config.source_suffix
            # adapt to a change with sphinx 1.3:
            # for sphinx >= 1.3 env.config.source_suffix is a list
            # see sphinx-doc/[email protected]
            if map(int, sphinx.__version__.split(".")[:2]) < [1, 3]:
                suffixes = [suffixes]
            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)
                for suffix in suffixes:
                    if docname.endswith(suffix):
                        docname = docname[:-len(suffix)]
                        break
                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, docname_) for docname_ in docnames]
            tocnode['maxdepth'] = -1
            tocnode['glob'] = None

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

        return self.warnings + nodes
开发者ID:jshridha,项目名称:obspy,代码行数:43,代码来源:__init__.py


示例8: run

 def run(self):
     env = self.state.document.settings.env
     output = []
     entries = []
     includefiles = []
     for entry in self.content:
         if not entry:
             continue
         docname = docname_join(env.docname, entry)
         if docname not in env.found_docs:
             output.append(
                 self.state.document.reporter.warning(
                     "feed contains a reference to nonexisting " "document %r" % docname, line=self.lineno
                 )
             )
             env.note_reread()
         else:
             output.append(self.state.document.reporter.warning("file exists %r" % docname, line=self.lineno))
             entries.append((None, docname))
             includefiles.append(docname)
     subnode = addnodes.toctree()
     subnode["parent"] = env.docname
     subnode["entries"] = entries
     subnode["includefiles"] = includefiles
     subnode["maxdepth"] = 1
     subnode["glob"] = False
     subnode["hidden"] = True
     subnode["numbered"] = False
     subnode["titlesonly"] = False
     wrappernode = nodes.compound(classes=["toctree-wrapper"])
     wrappernode.append(subnode)
     output.append(wrappernode)
     subnode = feed()
     subnode["entries"] = includefiles
     subnode["rss"] = self.options.get("rss")
     subnode["title"] = self.options.get("title", "")
     subnode["link"] = self.options.get("link", "")
     subnode["description"] = self.options.get("description", "")
     output.append(subnode)
     return output
开发者ID:xxks-kkk,项目名称:source2.io.github.xxks-kkk,代码行数:40,代码来源:newsfeed.py


示例9: run

    def run(self):
        names = []
        names += [x.strip() for x in self.content if x.strip()]

        table, warnings, real_names = get_autosummary(
            names, self.state, 'nosignatures' in self.options)
        node = table

        env = self.state.document.settings.env
        suffix = env.config.source_suffix
        all_docnames = env.found_docs.copy()
        dirname = posixpath.dirname(env.docname)

        if 'toctree' in self.options:
            tree_prefix = self.options['toctree'].strip()
            docnames = []
            for name in names:
                name = real_names.get(name, name)

                docname = posixpath.join(tree_prefix, name)
                if docname.endswith(suffix):
                    docname = docname[:-len(suffix)]
                docname = posixpath.normpath(posixpath.join(dirname, docname))
                if docname not in env.found_docs:
                    warnings.append(self.state.document.reporter.warning(
                        'toctree references unknown document %r' % docname,
                        line=self.lineno))
                docnames.append(docname)

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

            tocnode = autosummary_toc('', '', tocnode)
            return warnings + [node] + [tocnode]
        else:
            return warnings + [node]
开发者ID:89sos98,项目名称:main,代码行数:39,代码来源:__init__.py


示例10: run

    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)):
                        self.warn('toctree references excluded document %r'
                                  % docname)
                    else:
                        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

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

        return nodes
开发者ID:olivier-heurtier,项目名称:sphinx,代码行数:37,代码来源:__init__.py


示例11: run

 def run(self):
     env = self.state.document.settings.env
     output = []
     entries = []
     includefiles = []
     for entry in self.content:
         if not entry:
             continue
         docname = docname_join(env.docname, entry)
         if docname not in env.found_docs:
             output.append(self.state.document.reporter.warning(
                 'feed contains a reference to nonexisting '
                 'document %r' % docname, line=self.lineno))
             env.note_reread()
         else:
             entries.append((None, docname))
             includefiles.append(docname)
     subnode = addnodes.toctree()
     subnode['parent'] = env.docname
     subnode['entries'] = entries
     subnode['includefiles'] = includefiles
     subnode['maxdepth'] = 1
     subnode['glob'] = False
     subnode['hidden'] = True
     subnode['numbered'] = False
     subnode['titlesonly'] = False
     wrappernode = nodes.compound(classes=['toctree-wrapper'])
     wrappernode.append(subnode)
     output.append(wrappernode)
     subnode = feed()
     subnode['entries'] = includefiles
     subnode['rss'] = self.options.get('rss')
     subnode['title'] = self.options.get('title', '')
     subnode['link'] = self.options.get('link', '')
     subnode['description'] = self.options.get('description', '')
     output.append(subnode)
     return output
开发者ID:douarime,项目名称:sphinx-doc,代码行数:37,代码来源:newsfeed.py


示例12: run

    def run(self):
        # type: () -> List[nodes.Node]
        subnode = addnodes.toctree()
        subnode['parent'] = self.env.docname

        # (title, ref) pairs, where ref may be a document, or an external link,
        # and title may be None if the document's title is to be used
        subnode['entries'] = []
        subnode['includefiles'] = []
        subnode['maxdepth'] = self.options.get('maxdepth', -1)
        subnode['caption'] = self.options.get('caption')
        subnode['glob'] = 'glob' in self.options
        subnode['hidden'] = 'hidden' in self.options
        subnode['includehidden'] = 'includehidden' in self.options
        subnode['numbered'] = self.options.get('numbered', 0)
        subnode['titlesonly'] = 'titlesonly' in self.options
        set_source_info(self, subnode)
        wrappernode = nodes.compound(classes=['toctree-wrapper'])
        wrappernode.append(subnode)
        self.add_name(wrappernode)

        ret = self.parse_content(subnode)
        ret.append(wrappernode)
        return ret
开发者ID:papadeltasierra,项目名称:sphinx,代码行数:24,代码来源:other.py


示例13: autosummary_directive

def autosummary_directive(dirname, arguments, options, content, lineno,
                          content_offset, block_text, state, state_machine):
    names = []
    names += [x for x in content if x.strip()]

    result, warnings = get_autosummary(names, state.document)

    node = nodes.paragraph()
    state.nested_parse(result, 0, node)

    env = state.document.settings.env
    suffix = env.config.source_suffix
    all_docnames = env.found_docs.copy()
    dirname = posixpath.dirname(env.docname)

    docnames = []
    doctitles = {}
    for docname in names:
        docname = 'generated/' + docname
        doctitles[docname] = ''
        if docname.endswith(suffix):
            docname = docname[:-len(suffix)]
        docname = posixpath.normpath(posixpath.join(dirname, docname))
        if docname not in env.found_docs:
            warnings.append(state.document.reporter.warning(
                'toctree references unknown document %r' % docname,
                line=lineno))
        docnames.append(docname)

    tocnode = addnodes.toctree()
    tocnode['includefiles'] = docnames
    tocnode['includetitles'] = doctitles
    tocnode['maxdepth'] = -1
    tocnode['glob'] = None

    return warnings + node.children + [tocnode]
开发者ID:yekm,项目名称:talkbox,代码行数:36,代码来源:numpydoc.py


示例14: run

    def run(self):
        env = self.state.document.settings.env
        suffix = env.config.source_suffix
        glob = 'glob' in self.options

        ret = []
        # (title, ref) pairs, where ref may be a document, or an external link,
        # and title may be None if the document's title is to be used
        entries = []
        includefiles = []
        includetitles = {}
        all_docnames = env.found_docs.copy()
        # don't add the currently visited file in catch-all patterns
        all_docnames.remove(env.docname)
        for entry in self.content:
            if not entry:
                continue
            if not glob:
                # look for explicit titles ("Some Title <document>")
                m = caption_ref_re.match(entry)
                if m:
                    ref = m.group(2)
                    title = m.group(1)
                    docname = ref
                else:
                    ref = docname = entry
                    title = None
                # remove suffixes (backwards compatibility)
                if docname.endswith(suffix):
                    docname = docname[:-len(suffix)]
                # absolutize filenames
                docname = docname_join(env.docname, docname)
                if url_re.match(ref) or ref == 'self':
                    entries.append((title, ref))
#                 elif docname not in env.found_docs:
#                     ret.append(self.state.document.reporter.warning(
#                         'toctree references unknown document %r' % docname,
#                         line=self.lineno))
                else:
                    entries.append((title, docname))
                    includefiles.append(docname)
            else:
                patname = docname_join(env.docname, entry)
                docnames = sorted(patfilter(all_docnames, patname))
                for docname in docnames:
                    all_docnames.remove(docname) # don't include it again
                    entries.append((None, docname))
                    includefiles.append(docname)
                if not docnames:
                    ret.append(self.state.document.reporter.warning(
                        'toctree glob pattern %r didn\'t match any documents'
                        % entry, line=self.lineno))
        subnode = addnodes.toctree()
        subnode['parent'] = env.docname
        # entries contains all entries (self references, external links etc.)
        subnode['entries'] = entries
        # includefiles only entries that are documents
        subnode['includefiles'] = includefiles
        subnode['maxdepth'] = self.options.get('maxdepth', -1)
        subnode['glob'] = glob
        subnode['hidden'] = 'hidden' in self.options
        subnode['numbered'] = 'numbered' in self.options
        ret.append(subnode)
        return ret
开发者ID:LWhitson2,项目名称:fipy,代码行数:64,代码来源:example.py


示例15: my_toctree_run

def my_toctree_run(self):
    """Show non existing entries of toctree

    Used to replace the function -> sphinx.directives.other.TocTree.run

    Only %r following are replaced %s to avoid unreadable string.
    """
    env = self.state.document.settings.env
    suffix = env.config.source_suffix
    glob = 'glob' in self.options

    ret = []
    # (title, ref) pairs, where ref may be a document, or an external link,
    # and title may be None if the document's title is to be used
    entries = []
    includefiles = []
    all_docnames = env.found_docs.copy()
    # don't add the currently visited file in catch-all patterns
    all_docnames.remove(env.docname)
    for entry in self.content:
        if not entry:
            continue
        if not glob:
            # look for explicit titles ("Some Title <document>")
            m = explicit_title_re.match(entry)
            if m:
                ref = m.group(2)
                title = m.group(1)
                docname = ref
            else:
                ref = docname = entry
                title = None
            # remove suffixes (backwards compatibility)
            if docname.endswith(suffix):
                docname = docname[:-len(suffix)]
            # absolutize filenames
            docname = docname_join(env.docname, docname)
            if url_re.match(ref) or ref == 'self':
                entries.append((title, ref))
            elif docname not in env.found_docs:
                ret.append(self.state.document.reporter.warning(
                    u'toctree contains reference to nonexisting '
                    u'document %s' % docname, line=self.lineno))
                env.note_reread()
            else:
                entries.append((title, docname))
                includefiles.append(docname)
        else:
            patname = docname_join(env.docname, entry)
            docnames = sorted(patfilter(all_docnames, patname))
            for docname in docnames:
                all_docnames.remove(docname) # don't include it again
                entries.append((None, docname))
                includefiles.append(docname)
            if not docnames:
                ret.append(self.state.document.reporter.warning(
                    'toctree glob pattern %s didn\'t match any documents'
                    % entry, line=self.lineno))
    subnode = addnodes.toctree()
    subnode['parent'] = env.docname
    # entries contains all entries (self references, external links etc.)
    subnode['entries'] = entries
    # includefiles only entries that are documents
    subnode['includefiles'] = includefiles
    subnode['maxdepth'] = self.options.get('maxdepth', -1)
    subnode['glob'] = glob
    subnode['hidden'] = 'hidden' in self.options
    subnode['numbered'] = 'numbered' in self.options
    subnode['titlesonly'] = 'titlesonly' in self.options
    wrappernode = nodes.compound(classes=['toctree-wrapper'])
    wrappernode.append(subnode)
    ret.append(wrappernode)
    return ret
开发者ID:tkzwtks,项目名称:zaffy,代码行数:73,代码来源:unicode_ids.py


示例16: build_details_table


#.........这里部分代码省略.........
            append_detail_row(tbody, "Token Policy ID",
                              nodes.literal(text=resource.policy_id))

        # HTTP Methods
        allowed_http_methods = self.get_http_methods(resource, is_list)
        bullet_list = nodes.bullet_list()

        for http_method in allowed_http_methods:
            item = nodes.list_item()
            bullet_list += item

            paragraph = nodes.paragraph()
            item += paragraph

            ref = nodes.reference(text=http_method, refid=http_method)
            paragraph += ref

            doc_summary = self.get_doc_for_http_method(resource, http_method)
            i = doc_summary.find('.')

            if i != -1:
                doc_summary = doc_summary[:i + 1]

            paragraph += nodes.inline(text=" - ")
            paragraph += parse_text(
                self, doc_summary,
                wrapper_node_type=nodes.inline,
                where='HTTP %s handler summary for %s'
                      % (http_method, self.options['classname']))

        append_detail_row(tbody, "HTTP Methods", bullet_list)

        # Parent Resource
        if is_list or resource.uri_object_key is None:
            parent_resource = resource._parent_resource
            is_parent_list = False
        else:
            parent_resource = resource
            is_parent_list = True

        if parent_resource:
            paragraph = nodes.paragraph()
            paragraph += get_ref_to_resource(app, parent_resource,
                                             is_parent_list)
        else:
            paragraph = 'None.'

        append_detail_row(tbody, "Parent Resource", paragraph)

        # Child Resources
        if is_list:
            child_resources = list(resource.list_child_resources)

            if resource.name != resource.name_plural:
                if resource.uri_object_key:
                    child_resources.append(resource)

                are_children_lists = False
            else:
                are_children_lists = True
        else:
            child_resources = resource.item_child_resources
            are_children_lists = True

        if child_resources:
            tocnode = addnodes.toctree()
            tocnode['glob'] = None
            tocnode['maxdepth'] = 1
            tocnode['hidden'] = False

            docnames = sorted([
                docname_join(env.docname,
                             get_resource_docname(app, child_resource,
                                                  are_children_lists))
                for child_resource in child_resources
            ])

            tocnode['includefiles'] = docnames
            tocnode['entries'] = [(None, docname) for docname in docnames]
        else:
            tocnode = nodes.paragraph(text="None")

        append_detail_row(tbody, "Child Resources", tocnode)

        # Anonymous Access
        if is_list and not resource.singleton:
            getter = resource.get_list
        else:
            getter = resource.get

        if getattr(getter, 'login_required', False):
            anonymous_access = 'No'
        elif getattr(getter, 'checks_login_required', False):
            anonymous_access = 'Yes, if anonymous site access is enabled'
        else:
            anonymous_access = 'Yes'

        append_detail_row(tbody, "Anonymous Access", anonymous_access)

        return table
开发者ID:darmhoo,项目名称:reviewboard,代码行数:101,代码来源:webapidocs.py


示例17: build_details_table

    def build_details_table(self, resource):
        is_list = "is-list" in self.options

        table = nodes.table(classes=["resource-info"])

        tgroup = nodes.tgroup(cols=2)
        table += tgroup

        tgroup += nodes.colspec(colwidth=30, classes=["field"])
        tgroup += nodes.colspec(colwidth=70, classes=["value"])

        tbody = nodes.tbody()
        tgroup += tbody

        # Name
        if is_list:
            resource_name = resource.name_plural
        else:
            resource_name = resource.name

        append_detail_row(tbody, "Name", nodes.literal(text=resource_name))

        # URI
        uri_template = get_resource_uri_template(resource, not is_list)
        append_detail_row(tbody, "URI", nodes.literal(text=uri_template))

        # Token Policy ID
        if hasattr(resource, "policy_id"):
            append_detail_row(tbody, "Token Policy ID", nodes.literal(text=resource.policy_id))

        # HTTP Methods
        allowed_http_methods = self.get_http_methods(resource, is_list)
        bullet_list = nodes.bullet_list()

        for http_method in allowed_http_methods:
            item = nodes.list_item()
            bullet_list += item

            paragraph = nodes.paragraph()
            item += paragraph

            ref = nodes.reference(text=http_method, refid=http_method)
            paragraph += ref

            doc_summary = self.get_doc_for_http_method(resource, http_method)
            i = doc_summary.find(".")

            if i != -1:
                doc_summary = doc_summary[: i + 1]

            paragraph += nodes.inline(text=" - ")
            paragraph += parse_text(
                self,
                doc_summary,
                nodes.inline,
                where="HTTP %s handler summary for %s" % (http_method, self.options["classname"]),
            )

        append_detail_row(tbody, "HTTP Methods", bullet_list)

        # Parent Resource
        if is_list or resource.uri_object_key is None:
            parent_resource = resource._parent_resource
            is_parent_list = False
        else:
            parent_resource = resource
            is_parent_list = True

        if parent_resource:
            paragraph = nodes.paragraph()
            paragraph += get_ref_to_resource(parent_resource, is_parent_list)
        else:
            paragraph = "None."

        append_detail_row(tbody, "Parent Resource", paragraph)

        # Child Resources
        if is_list:
            child_resources = list(resource.list_child_resources)

            if resource.name != resource.name_plural:
                if resource.uri_object_key:
                    child_resources.append(resource)

                are_children_lists = False
            else:
                are_children_lists = True
        else:
            child_resources = resource.item_child_resources
            are_children_lists = True

        if child_resources:
            tocnode = addnodes.toctree()
            tocnode["glob"] = None
            tocnode["maxdepth"] = 1
            tocnode["hidden"] = False

            docnames = sorted(
                [
                    docname_join(
#.........这里部分代码省略.........
开发者ID:chipx86,项目名称:reviewboard,代码行数:101,代码来源:webapidocs.py


示例18: run

    def run(self):
        env = self.state.document.settings.env
        suffixes = env.config.source_suffix
        glob = 'glob' in self.options
        caption = self.options.get('caption')
        if caption:
            self.options.setdefault('name', nodes.fully_normalize_name(caption))

        ret = []
        # (title, ref) pairs, where ref may be a document, or an external link,
        # and title may be None if the document's title is to be used
        entries = []
        includefiles = []
        all_docnames = env.found_docs.copy()
        # don't add the currently visited file in catch-all patterns
        all_docnames.remove(env.docname)
        for entry in self.content:
            if not entry:
                continue
            if glob and ('*' in entry or '?' in entry or '[' in entry):
                patname = docname_join(env.docname, entry)
                docnames = sorted(patfilter(all_docnames, patname))
                for docname in docnames:
                    all_docnames.remove(docname)  # don't include it again
                    entries.append((None, docname))
                    includefiles.append(docname)
                if not docnames:
                    ret.append(self.state.document.reporter.warning(
                        'toctree glob pattern %r didn\'t match any documents'
                        % entry, line=self.lineno))
            else:
                # look for explicit titles ("Some Title <document>")
                m = explicit_title_re.match(entry)
                if m:
                    ref = m.group(2)
                    title = m.group(1)
                    docname = ref
                else:
                    ref = docname = entry
                    title = None
                # remove suffixes (backwards compatibility)
                for suffix in suffixes:
                    if docname.endswith(suffix):
                        docname = docname[:-len(suffix)]
                        break
                # absolutize filenames
                docname = docname_join(env.docname, docname)
                if url_re.match(ref) or ref == 'self':
                    entries.append((title, ref))
                elif docname not in env.found_docs:
                    ret.append(self.state.document.reporter.warning(
                        'toctree contains reference to nonexisting '
                        'document %r' % docname, line=self.lineno))
                    env.note_reread()
                else:
                    all_docnames.discard(docname)
                    entries.append((title, docname))
                    includefiles.append(docname)
        subnode = addnodes.toctree()
        subnode['parent'] = env.docname
        # entries contains all entries (self references, external links etc.)
        subnode['entries'] = entries
        # includefiles only entries that are documents
        subnode['includefiles'] = includefiles
        subnode['maxdepth'] = self.options.get('maxdepth', -1)
        subnode['caption'] = caption
        subnode['glob'] = glob
        subnode['hidden'] = 'hidden' in self.options
        subnode['includehidden'] = 'includehidden' in self.options
        subnode['numbered'] = self.options.get('numbered', 0)
        subnode['titlesonly'] = 'titlesonly' in self.options
        set_source_info(self, subnode)
        wrappernode = nodes.compound(classes=['toctree-wrapper'])
        wrappernode.append(subnode)
        self.add_name(wrappernode)
        ret.append(wrappernode)
        return ret
开发者ID:861008761,项目名称:standard_flask_web,代码行数:77,代码来源:other.py


示例19: build_details_table

    def build_details_table(self, resource):
        is_list = 'is-list' in self.options

        table = nodes.table()

        tgroup = nodes.tgroup(cols=1)
        table += tgroup

        tgroup += nodes.colspec(colwidth=30)
        tgroup += nodes.colspec(colwidth=70)

        tbody = nodes.tbody()
        tgroup += tbody

        # Name
        if is_list:
            resource_name = resource.name_plural
        else:
            resource_name = resource.name

        self.append_detail_row(tbody, "Name", nodes.literal(text=resource_name))

        # URI
        request = DummyRequest()
        uri_template = get_resource_uri_template(resource, not is_list)

        self.append_detail_row(tbody, "URI", nodes.literal(text=uri_template))

        # URI Parameters
        #self.append_detail_row(tbody, "URI Parameters", '')

        # Description
        self.append_detail_row(tbody, "Description",
                               parse_text(self, inspect.getdoc(resource)))

        # HTTP Methods
        allowed_http_methods = self.get_http_methods(resource, is_list)
        bullet_list = nodes.bullet_list()

        for http_method in allowed_http_methods:
            item = nodes.list_item()
            bullet_list += item

            paragraph = nodes.paragraph()
            item += paragraph

            ref = nodes.reference(text=http_method, refid=http_method)
            paragraph += ref

            doc_summary = self.get_doc_for_http_method(resource, http_method)
            i = doc_summary.find('.')

            if i != -1:
                doc_summary = doc_summary[:i + 1]

            paragraph += nodes.inline(text=" - ")
            paragraph += parse_text(self, doc_summary, nodes.inline)

        self.append_detail_row(tbody, "HTTP Methods", bullet_list)

        # Parent Resource
        if is_list or resource.uri_object_key is None:
            parent_resource = resource._parent_resource
            is_parent_list = False
        else:
            parent_resource = resource
            is_parent_list = True

        if parent_resource:
            paragraph = nodes.paragraph()
            paragraph += get_ref_to_resource(parent_resource, is_parent_list)
        else:
            paragraph = 'None.'

        self.append_detail_row(tbody, "Parent Resource", paragraph)

        # Child Resources
        if is_list:
            child_resources = list(resource.list_child_resources)

            if resource.name != resource.name_plural:
                if resource.uri_object_key:
                    child_resources.append(resource)

                are_children_lists = False
            else:
                are_children_lists = True
        else:
            child_resources = resource.item_child_resources
            are_children_lists = True

        if child_resources:
            tocnode = addnodes.toctree()
            tocnode['glob'] = None
            tocnode['maxdepth'] = 1
            tocnode['hidden'] = False

            docnames = sorted([
                docname_join(self.state.document.settings.env.docname,
                             get_resource_docname(child_resource,
#.........这里部分代码省略.........
开发者ID:zjinys,项目名称:reviewboard,代码行数:101,代码来源:webapidocs.py


示例20: run

该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python addnodes.versionmodified函数代码示例发布时间:2022-05-27
下一篇:
Python addnodes.tabular_col_spec函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap