当前位置: 首页>>代码示例>>Python>>正文


Python addnodes.compact_paragraph函数代码示例

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


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

示例1: extract_toc

def extract_toc(fulltoc, selectors):
    entries = []

    def matches(ref, selector):
        if selector.endswith('/*'):
            return ref.rsplit('/', 1)[0] == selector[:-2]
        return ref == selector

    for refnode in fulltoc.traverse(nodes.reference):
        container = refnode.parent.parent
        if any(
            cls[:4] == 'ref-' and any(
                matches(cls[4:], s) for s in selectors
            )
            for cls in container['classes']
        ):
            parent = container.parent

            new_parent = parent.deepcopy()
            del new_parent.children[:]
            new_parent += container
            entries.append(new_parent)

            parent.remove(container)
            if not parent.children:
                parent.parent.remove(parent)

    newnode = addnodes.compact_paragraph('', '')
    newnode.extend(entries)
    newnode['toctree'] = True

    return newnode
开发者ID:getsentry,项目名称:sentry-doc-support,代码行数:32,代码来源:sentryext.py

示例2: handle_signature

	def handle_signature(self, sig, signode):
		#synopsis = unicodedata.normalize('NFD', self.options.get('synopsis'))
		synopsis = self.options.get('synopsis')
		module = self.env.temp_data.get('nscp:module')
		fullname = 'TODO'
		if self.objtype == 'query':
			fullname = '%s.%s'%(module, sig)
			signode['fullname'] = fullname
			signode += addnodes.desc_addname(module, module)
			signode += addnodes.desc_name(sig, sig)
			signode += addnodes.desc_content('')
			signode += addnodes.compact_paragraph(synopsis, synopsis)
		elif self.objtype == 'option':
			command = self.env.temp_data.get('nscp:command')
			fullname = '%s.%s:%s'%(module, command, sig)
			signode['fullname'] = fullname
			ann = ' (%s, %s)'%(module, command)
			signode += addnodes.desc_name(sig, sig)
			signode += addnodes.desc_annotation(ann, ann)
		elif self.objtype == 'confpath':
			fullname = '%s:%s'%(module, sig)
			signode['fullname'] = fullname
			ann = ' (%s)'%(module)
			signode += addnodes.desc_name(sig, sig)
			signode += addnodes.desc_annotation(ann, ann)
		elif self.objtype == 'confkey':
			confpath = self.env.temp_data.get('nscp:confpath', '')
			fullname = '%s:%s:%s'%(module, confpath, sig)
			signode['fullname'] = fullname
			ann = ' (%s, %s)'%(module, confpath)
			signode += addnodes.desc_name(sig, sig)
			signode += addnodes.desc_annotation(ann, ann)
		#print 'handle_signature(%s, %s) => %s'%(sig, signode, fullname)
		return fullname, sig
开发者ID:Vilse1202,项目名称:nscp,代码行数:34,代码来源:nscp.py

示例3: run

    def run(self):
        self.assert_has_content()

        content = ''.join(self.content).strip()

        icon_classes = self.options.get('icon-classes', '')
        icon_classes = icon_classes.split(' ')

        container_classes = self.options.get('box-classes', '')
        container_classes = container_classes.split(' ')

        icons = span(classes=icon_classes)

        node = nodes.container(classes=container_classes)
        node.children.append(icons)

        parsed, _messages = self.state.inline_text(
            content, self.content_offset
        )
        parsed_ = parsed[0]
        for p in parsed[1:]:
            parsed_.children.append(p)

        cp = compact_paragraph('', '', parsed_)
        node.children.append(cp)

        return [node]
开发者ID:kyungmin,项目名称:balanced-docs,代码行数:27,代码来源:customizations.py

示例4: getArgsContent

def getArgsContent(Args):
  Container = desc('', desc_signature(text='Args'), objtype="Args")

  for name, Arg in Args.items():
    Content = desc_content()
    Content.append(desc_name(text='%s: ' % name))
    Content.append(compact_paragraph(text=getArgDesc(Arg)))
    Container.append(Content)

  return Container
开发者ID:Laufire,项目名称:eccontrib-sphinxdoc,代码行数:10,代码来源:sphinxdoc.py

示例5: build_toc

 def build_toc(node, depth=1):
     # type: (nodes.Element, int) -> nodes.bullet_list
     entries = []  # type: List[nodes.Element]
     for sectionnode in node:
         # find all toctree nodes in this section and add them
         # to the toc (just copying the toctree node which is then
         # resolved in self.get_and_resolve_doctree)
         if isinstance(sectionnode, nodes.section):
             title = sectionnode[0]
             # copy the contents of the section title, but without references
             # and unnecessary stuff
             visitor = SphinxContentsFilter(doctree)
             title.walkabout(visitor)
             nodetext = visitor.get_entry_text()
             if not numentries[0]:
                 # for the very first toc entry, don't add an anchor
                 # as it is the file's title anyway
                 anchorname = ''
             else:
                 anchorname = '#' + sectionnode['ids'][0]
             numentries[0] += 1
             # make these nodes:
             # list_item -> compact_paragraph -> reference
             reference = nodes.reference(
                 '', '', internal=True, refuri=docname,
                 anchorname=anchorname, *nodetext)
             para = addnodes.compact_paragraph('', '', reference)
             item = nodes.list_item('', para)  # type: nodes.Element
             sub_item = build_toc(sectionnode, depth + 1)
             if sub_item:
                 item += sub_item
             entries.append(item)
         elif isinstance(sectionnode, addnodes.only):
             onlynode = addnodes.only(expr=sectionnode['expr'])
             blist = build_toc(sectionnode, depth)
             if blist:
                 onlynode += blist.children
                 entries.append(onlynode)
         elif isinstance(sectionnode, nodes.Element):
             for toctreenode in traverse_in_section(sectionnode,
                                                    addnodes.toctree):
                 item = toctreenode.copy()
                 entries.append(item)
                 # important: do the inventory stuff
                 TocTree(app.env).note(docname, toctreenode)
     if entries:
         return nodes.bullet_list('', *entries)
     return None
开发者ID:olivier-heurtier,项目名称:sphinx,代码行数:48,代码来源:toctree.py

示例6: build_toc

    def build_toc(node, depth=1, main=False, title_visited=False):
      entries = []
      for sectionnode in node:
# EV: added or condition on 'main' and 'title_visited'
        # find all toctree nodes in this section and add them
        # to the toc (just copying the toctree node which is then
        # resolved in self.get_and_resolve_doctree)
        if isinstance(sectionnode, addnodes.only):
          onlynode = addnodes.only(expr=sectionnode['expr'])
          blist = build_toc(sectionnode, depth)
          if blist:
            onlynode += blist.children
            entries.append(onlynode)
        if not isinstance(sectionnode, nodes.section) or (main and title_visited):
          for toctreenode in traverse_in_section(sectionnode,
                                                 addnodes.toctree):
            item = toctreenode.copy()
            entries.append(item)
            # important: do the inventory stuff
            self.note_toctree(docname, toctreenode)
          continue
        title = sectionnode[0]
        # copy the contents of the section title, but without references
        # and unnecessary stuff
        visitor = SphinxContentsFilter(document)
        title.walkabout(visitor)
        nodetext = visitor.get_entry_text()
        if not numentries[0]:
          # for the very first toc entry, don't add an anchor
          # as it is the file's title anyway
          anchorname = ''
        else:
          anchorname = '#' + sectionnode['ids'][0]
        numentries[0] += 1
        reference = nodes.reference(
          '', '', internal=True, refuri=docname,
          anchorname=anchorname, *nodetext)
        para = addnodes.compact_paragraph('', '', reference)
        item = nodes.list_item('', para)
        if maxdepth == 0 or depth < maxdepth:
# EV: set 'main' and 'title_visited' args
          item += build_toc(sectionnode, depth+1, main=main, title_visited=True)
        entries.append(item)
      if entries:
        return nodes.bullet_list('', *entries)
      return []
开发者ID:baohaojun,项目名称:eclim,代码行数:46,代码来源:environment.py

示例7: sub

 def sub(title, lst):
     if not lst:
         return None
     item, res, tmp = nodes.list_item(), addnodes.compact_paragraph(), []
     res += nodes.strong(text=(title + ': '))
     kwargs = {
         'refdomain': 'cpp',
         'refexplicit': False,
         'reftype': 'class',
     }
     for it in lst:
         kwargs['reftarget'] = unicode(it.name)
         node = addnodes.pending_xref('', **kwargs)
         node += nodes.literal(text=it.name)
         tmp.extend([node, nodes.Text(', ')])
     res.extend(tmp[:-1])
     item += res
     return item
开发者ID:aldebaran,项目名称:doc-tools,代码行数:18,代码来源:__init__.py

示例8: _build_toc_node

def _build_toc_node(docname, anchor="anchor", text="test text", bullet=False):
    """
    Create the node structure that Sphinx expects for TOC Tree entries.

    The ``bullet`` argument wraps it in a ``nodes.bullet_list``,
    which is how you nest TOC Tree entries.
    """
    reference = nodes.reference(
        "",
        "",
        internal=True,
        refuri=docname,
        anchorname="#" + anchor,
        *[nodes.Text(text, text)]
    )
    para = addnodes.compact_paragraph("", "", reference)
    ret_list = nodes.list_item("", para)
    return nodes.bullet_list("", ret_list) if bullet else ret_list
开发者ID:rtfd,项目名称:sphinx-autoapi,代码行数:18,代码来源:toctree.py

示例9: run

 def run(self):
     populated = CPPAutoDocObject._populate(self)
     self.name = 'function'
     res, obj = CPPFunctionObject.run(self), self._get_obj()
     if populated:
         fieldlist, _empty = nodes.field_list(), True
         doc_args = [it for it in obj.signature
                     if obj.brief('param_' + str(it.get_name()))]
         if doc_args:
             tmp = []
             for it in doc_args:
                 param_name = 'param_' + str(it.get_name())
                 node = addnodes.compact_paragraph()
                 if obj.param_ways.get(param_name, None) is not None:
                     node += nodes.literal(text='[{}] '.format(
                         obj.param_ways[param_name]
                     ))
                 node += nodes.Text(obj.brief(param_name)[0])
                 tmp.append((it.name, node))
             fieldlist += self.doc_field_types[0].make_field(
                 [], # [it.type for it in doc_args],
                 self._get_domain(),
                 tmp,
             )
             _empty = False
         def _simple_field(fieldlist, name, nb_):
             if obj.brief(name):
                 fieldlist += self.doc_field_types[nb_].make_field(
                     None, self._get_domain(),
                     (None, [nodes.Text(it) for it in obj.brief(name)])
                 )
                 return False
             return True
         _empty =_simple_field(fieldlist, 'return', 1) and _empty
         _empty = _simple_field(fieldlist, 'pre', 3) and _empty
         _empty = _simple_field(fieldlist, 'post', 4) and _empty
         if not _empty:
             res[1][1].insert(0, fieldlist)
         if obj.details() and not _empty:
             para = nodes.paragraph()
             para += nodes.emphasis(text='Brief: ')
             para += nodes.Text(''.join(obj.brief()))
             res[1][1].insert(0, para)
     return res
开发者ID:aldebaran,项目名称:doc-tools,代码行数:44,代码来源:__init__.py

示例10: get_navtree

def get_navtree(app, pagename, collapse=True, **kwargs):

    shift_toc = app.config.navtree_shift
    root_links = app.config.navtree_root_links
    maxdepth = app.config.navtree_maxdepth
    try:
        maxdepth.setdefault('default', kwargs.pop('maxdepth', MAXDEPTH_DEFAULT))
    except AttributeError:
        maxdepth = {'default': maxdepth}

    toctree = app.env.get_toctree_for(pagename, app.builder, collapse=False, **kwargs)
    navtree = addnodes.compact_paragraph()
    navtree['toctree'] = True

    for bullet_list, caption in iter_toctree(toctree):
        process_toctree_list(navtree, bullet_list, caption, app,
                             collapse, maxdepth, shift_toc, root_links)

    if shift_toc:
        update_navtree_classes(navtree)

    return app.builder.render_partial(navtree)['fragment']
开发者ID:bintoro,项目名称:sphinx-navtree,代码行数:22,代码来源:main.py

示例11: extract_toc

def extract_toc(fulltoc, selectors):
    entries = []

    for refnode in fulltoc.traverse(nodes.reference):
        container = refnode.parent.parent
        if any(cls[:4] == 'ref-' and cls[4:] in selectors
               for cls in container['classes']):
            parent = container.parent

            new_parent = parent.deepcopy()
            del new_parent.children[:]
            new_parent += container
            entries.append(new_parent)

            parent.remove(container)
            if not parent.children:
                parent.parent.remove(parent)

    newnode = addnodes.compact_paragraph('', '')
    newnode.extend(entries)
    newnode['toctree'] = True

    return newnode
开发者ID:SLusenti,项目名称:origin,代码行数:23,代码来源:sentryext.py

示例12: apply

    def apply(self):
        env = self.document.settings.env
        if env.config.html_compact_lists:
            return

        def check_refonly_list(node):
            """Check for list with only references in it."""
            visitor = RefOnlyListChecker(self.document)
            try:
                node.walk(visitor)
            except nodes.NodeFound:
                return False
            else:
                return True

        for node in self.document.traverse(nodes.bullet_list):
            if check_refonly_list(node):
                for item in node.traverse(nodes.list_item):
                    para = item[0]
                    ref = para[0]
                    compact_para = addnodes.compact_paragraph()
                    compact_para += ref
                    item.replace(para, compact_para)
开发者ID:TimKam,项目名称:sphinx,代码行数:23,代码来源:compact_bullet_list.py

示例13: build_toc

 def build_toc(node):
     entries = []
     for subnode in node:
         if isinstance(subnode, addnodes.toctree):
             # just copy the toctree node which is then resolved
             # in self.get_and_resolve_doctree
             item = subnode.copy()
             entries.append(item)
             # do the inventory stuff
             self.note_toctree(docname, subnode)
             continue
         if not isinstance(subnode, nodes.section):
             continue
         title = subnode[0]
         # copy the contents of the section title, but without references
         # and unnecessary stuff
         visitor = SphinxContentsFilter(document)
         title.walkabout(visitor)
         nodetext = visitor.get_entry_text()
         if not numentries[0]:
             # for the very first toc entry, don't add an anchor
             # as it is the file's title anyway
             anchorname = ''
         else:
             anchorname = '#' + subnode['ids'][0]
         numentries[0] += 1
         reference = nodes.reference('', '', refuri=docname,
                                     anchorname=anchorname,
                                     *nodetext)
         para = addnodes.compact_paragraph('', '', reference)
         item = nodes.list_item('', para)
         item += build_toc(subnode)
         entries.append(item)
     if entries:
         return nodes.bullet_list('', *entries)
     return []
开发者ID:lshmenor,项目名称:IMTAphy,代码行数:36,代码来源:environment.py

示例14: apply

    def apply(self, **kwargs):
        # type: (Any) -> None
        if self.config.html_compact_lists:
            return

        def check_refonly_list(node):
            # type: (nodes.Node) -> bool
            """Check for list with only references in it."""
            visitor = RefOnlyListChecker(self.document)
            try:
                node.walk(visitor)
            except nodes.NodeFound:
                return False
            else:
                return True

        for node in self.document.traverse(nodes.bullet_list):
            if check_refonly_list(node):
                for item in node.traverse(nodes.list_item):
                    para = cast(nodes.paragraph, item[0])
                    ref = cast(nodes.reference, para[0])
                    compact_para = addnodes.compact_paragraph()
                    compact_para += ref
                    item.replace(para, compact_para)
开发者ID:olivier-heurtier,项目名称:sphinx,代码行数:24,代码来源:compact_bullet_list.py

示例15: __init__

 def __init__(self, *args, **kwargs):
   StandaloneHTMLBuilder.__init__(self, *args, **kwargs)
   self.toctrees = {}
   self.index_node = nodes.list_item('', addnodes.compact_paragraph(''))
开发者ID:DamienCassou,项目名称:eclim,代码行数:4,代码来源:builder.py


注:本文中的sphinx.addnodes.compact_paragraph函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。