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


Python addnodes.desc_signature函数代码示例

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


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

示例1: run

    def run(self):
        if ':' in self.name:
            self.domain, self.objtype = self.name.split(':', 1)
        else:
            self.domain, self.objtype = '', self.name
        self.env = self.state.document.settings.env
        self.indexnode = addnodes.index(entries=[])

        obj = self.make_obj()
        node = addnodes.desc()
        node.document = self.state.document
        node['domain'] = self.domain
        # 'desctype' is a backwards compatible attribute
        node['objtype'] = node['desctype'] = self.objtype
        node['noindex'] = noindex = ('noindex' in self.options)
        node.name = obj.name
        obj.docname = self.env.docname

        objects = self.env.domaindata['envy']['objects']

        signode = addnodes.desc_signature('', '')
        signode['first'] = True
        node.append(signode)
        self.make_signature(obj, signode)
        if not noindex and self.name not in objects:
            # only add target and index entry if this is the first
            # description of the object with this name in this desc block
            #self.add_target_and_index(self.name, sig, signode)
            nid = obj.iname + '-' + self.name
            signode['names'].append(nid)
            signode['ids'].append(nid)
            self.state.document.note_explicit_target(signode)

        for loc in self.locs:
            signode = addnodes.desc_signature('', '')
            signode['first'] = False
            node.append(signode)
            signode += addnodes.desc_name(loc, loc)

        node.append(uplink_placeholder(self.name))

        if self.name in objects:
            other = objects[self.name]
            self.state_machine.reporter.warning('duplicate object {}, other instance in {}'.format(self.name, self.env.doc2path(other.docname)))
        objects[self.name] = obj

        contentnode = addnodes.desc_content()
        node.append(contentnode)
        self.env.temp_data['object'] = self.name
        self.state.nested_parse(self.content, self.content_offset, contentnode)
        self.env.temp_data['object'] = None
        contentnode += self.after_content()
        return [self.indexnode, node]
开发者ID:AlexAltea,项目名称:envytools,代码行数:53,代码来源:envy.py

示例2: run

    def run(self):
        """Run this directive.

        In addition to the normal processing of the :class:`EmacsLispSymbol`
        directive, also prepend an additional signature that describes the
        keybinding of the documented command, if any.

        """
        result_nodes = EmacsLispSymbol.run(self)

        # Insert a dedicated signature for the key binding before all other
        # signatures, but only for commands.  Nothing else has key bindings.
        binding = self.options.get('binding')
        if binding:
            binding = self.with_prefix_arg(binding)
            desc_node = result_nodes[-1]
            assert isinstance(desc_node, addnodes.desc)
            signode = addnodes.desc_signature(binding, '')
            # No clue what this property is for, but ObjectDescription sets it
            # for its signatures, so we should do as well for our signature.
            signode['first'] = False
            desc_node.insert(0, signode)
            signode += addnodes.desc_name(binding, binding)

        return result_nodes
开发者ID:lunaryorn,项目名称:sphinxcontrib-emacs,代码行数:25,代码来源:desc.py

示例3: run

  def run(self):
    #no good
    # node = nodes.paragraph('', 'Hi there!',
    #   ids=['foo'],
    #   names = ['foobar']
    # )

    #works
    # node = nodes.section(names=['foobar'])
    # self.state.document.note_explicit_target(node)
    # node.append(nodes.paragraph('', "foo foo"))
    
    #no good
    # node = nodes.admonition(names=['foobar'])
    # self.state.document.note_explicit_target(node)
    # node.append(nodes.paragraph('', "foo foo"))

    # node = nodes.paragraph('', 'foo foo', names=['foobar'])
    # self.state.document.note_explicit_target(node)

    #This doesn't properly render
    desc = addnodes.desc('',
      addnodes.desc_signature('',
        addnodes.desc_name('', 'namename'),
        addnodes.desc_parameterlist('',
          addnodes.desc_parameter('', 'def')
        ),
      names=['namename'], fullname="namename", ids=['namename'], module=None, first=False),
    desctype="function", domain="py", objtype='objtype')
    
    #no link (because didn't properly render?)
    self.state.document.note_explicit_target(desc)
    return [desc]
开发者ID:maxrothman,项目名称:sphinx-test,代码行数:33,代码来源:directives.py

示例4: render

    def render(self):

        title = self.title()
        rettype, name, arglist, const, signature = self.directive.parse_title(title)
        target = self.directive.create_target(name)

        # add a signature node 
        signode = addnodes.desc_signature(signature, '')
        signode['first'] = False

        signode += addnodes.desc_type('', '')
        
        self.directive.add_return_type(signode[-1] , rettype)
        name = self.directive.add_sig_name(signode, name)
        self.directive.set_name(name)
        self.directive.add_sig_args(signode, arglist, const)


        self.directive.before_content()
        description_nodes = self.description()
        content_node = addnodes.desc_content('')
        content_node += description_nodes
        self.directive.after_content()

        target.extend(signode)
        term = self.node_factory.term("","", ids=[name], *target )
        entry = self.node_factory.definition_list_item("",term, content_node)

        
        return [entry]
开发者ID:Cyofanni,项目名称:speect,代码行数:30,代码来源:index.py

示例5: render

    def render(self):
        title = self.title()
        rettype, name, arglist, const, signature = self.directive.parse_title(title)
        fullname = self.directive.get_full_name(name)

        if self.data_object.kind == "function":
            # set True that this might be a structure method
            self.directive.sphinx_directive.typemethod_set = True
        
        target = self.directive.create_target(fullname)

        if self.data_object.kind == "function":
            self.directive.sphinx_directive.typemethod_set = False
      
        # add a signature node 
        signode = addnodes.desc_signature(signature, '')
        signode['first'] = False

        signode += addnodes.desc_type('', '')
        
        self.directive.add_return_type(signode[-1] , rettype)
        name = self.directive.add_sig_name(signode, name)
        self.directive.add_sig_args(signode, arglist, const)

        description_nodes = self.description()
        content_node = addnodes.desc_content('')
        content_node += description_nodes
        

        target.extend(signode)
        term = self.node_factory.term("","", ids=[name], *target )
        entry = self.node_factory.definition_list_item("",term, content_node)

        return [entry]
开发者ID:Cyofanni,项目名称:speect,代码行数:34,代码来源:compound.py

示例6: create_target

    def create_target(self, name):
        if not self.noindex and name not in self.sphinx_directive.names:
            # only add target and index entry if this is the first
            # description of the object with this name in this desc block
            self.sphinx_directive.names.append(name)
            if name not in self.sphinx_directive.state.document.ids:
                signode = addnodes.desc_signature()
                signode['names'].append(name)
                signode['ids'].append(name)
                signode['first'] = (not self.sphinx_directive.names)
                self.sphinx_directive.state.document.note_explicit_target(signode)
                inv = self.sphinx_directive.env.domaindata['c']['objects']
                if name in inv:
                    self.sphinx_directive.env.warn(
                        self.sphinx_directive.env.docname,
                        'duplicate C object description of %s, ' % name +
                        'other instance in ' + self.sphinx_directive.env.doc2path(inv[name][0]),
                        self.sphinx_directive.lineno)
                inv[name] = (self.sphinx_directive.env.docname, self.sphinx_directive.objtype)
            else:
                signode = []

            indextext = self.get_index_text(name)
            if indextext:
                self.sphinx_directive.indexnode['entries'].append(('single', indextext, name, ''))

            return signode
        
        return []
开发者ID:Cyofanni,项目名称:speect,代码行数:29,代码来源:c.py

示例7: run

    def run(self):
        self.desctype = self.name
        self.env = self.state.document.settings.env
        self.indexnode = addnodes.index(entries=[])

        node = addnodes.desc()
        node.document = self.state.document
        node['desctype'] = self.desctype
        node['noindex'] = noindex = ('noindex' in self.options)

        self.names = []
        signatures = self.get_signatures()
        for i, sig in enumerate(signatures):
            # add a signature node for each signature in the current unit
            # and add a reference target for it
            signode = addnodes.desc_signature(sig, '')
            signode['first'] = False
            node.append(signode)
            try:
                # name can also be a tuple, e.g. (classname, objname)
                name = self.parse_signature(sig, signode)
            except ValueError, err:
                # signature parsing failed
                signode.clear()
                signode += addnodes.desc_name(sig, sig)
                continue  # we don't want an index entry here
            if not noindex and name not in self.names:
                # only add target and index entry if this is the first
                # description of the object with this name in this desc block
                self.names.append(name)
                self.add_target_and_index(name, sig, signode)
开发者ID:89sos98,项目名称:main,代码行数:31,代码来源:desc.py

示例8: envy_resolve

def envy_resolve(app, doctree, fromdocname):
    objects = app.env.domaindata['envy']['objects']

    # add uplink info
    for holder in doctree.traverse(uplink_placeholder):
        obj = objects[holder.name]
        links = []
        for sp, pos, name, variants in obj.uplinks:
            signode = addnodes.desc_signature('', '')
            signode['first'] = False
            signode += make_refnode(app.builder, fromdocname, sp.docname, sp.iname + '-' + sp.name, addnodes.desc_addname(sp.name, sp.name), sp.name)
            text = ' {}: {}'.format(pos, name)
            signode += addnodes.desc_name(text, text)
            if variants is not None:
                text = ' [{}]'.format(variants)
                signode += addnodes.desc_annotation(text, text)
            links.append(signode)
        holder.replace_self(links)

    # add subnode list
    for holder in doctree.traverse(sub_placeholder):
        obj = objects[holder.name]
        add_variant = False
        for pos, name, child, variants in obj.subs:
            if variants is not None:
                add_variant = True
        table = nodes.table()
        headers = [(1, 'Address'), (1, 'Name'), (10, 'Description')]
        if add_variant:
            headers.insert(1, (1, 'Variants'))
        tgroup = nodes.tgroup(cols=len(headers))
        table += tgroup
        for colwidth, header in headers:
            tgroup += nodes.colspec(colwidth=colwidth)
        thead = nodes.thead()
        tgroup += thead
        headrow = nodes.row()
        for colwidth, header in headers:
            entry = nodes.entry()
            para = nodes.paragraph()
            entry += para
            para += nodes.Text(header, header)
            headrow += entry
        thead += headrow
        tbody = nodes.tbody()
        tgroup += tbody
        for pos, name, child, variants in obj.subs:
            row = nodes.row()
            row += wrap_text_entry(pos)
            if add_variant:
                row += wrap_text_entry('all' if variants is None else variants)
            row += wrap_text_entry(name)
            entry = nodes.entry()
            para = nodes.paragraph()
            entry += para
            para += make_refnode(app.builder, fromdocname, child.docname, child.iname + '-' + child.name, nodes.Text(child.brief, child.brief), obj.brief)
            row += entry
            tbody += row
        holder.replace_self([table])
开发者ID:plaes,项目名称:envytools,代码行数:59,代码来源:envy.py

示例9: parse

def parse(sig):
    m = py_sig_re.match(sig)
    if m is None:
        raise ValueError
    name_prefix, name, arglist, retann = m.groups()
    signode = addnodes.desc_signature(sig, '')
    _pseudo_parse_arglist(signode, arglist)
    return signode.astext()
开发者ID:hagenw,项目名称:sphinx,代码行数:8,代码来源:test_domain_py.py

示例10: run

    def run(self):
        self.env = env = self.state.document.settings.env
        # normalize whitespace in fullname like XRefRole does
        fullname = ws_re.sub(' ', self.arguments[0].strip())
        targetname = '%s-%s' % (self.ref_type, fullname)

        # keep the target; this may be used to generate a BBIndex later
        targets = env.domaindata['bb']['targets'].setdefault(self.ref_type, {})
        targets[fullname] = env.docname, targetname

        # make up the descriptor: a target and potentially an index descriptor
        node = nodes.target('', '', ids=[targetname])
        ret = [node]

        # add the target to the document
        self.state.document.note_explicit_target(node)

        # append the index node if necessary
        entries = []
        for tpl in self.indextemplates:
            colon = tpl.find(':')
            if colon != -1:
                indextype = tpl[:colon].strip()
                indexentry = tpl[colon + 1:].strip() % (fullname,)
            else:
                indextype = 'single'
                indexentry = tpl % (fullname,)
            entries.append(
                (indextype, indexentry, targetname, targetname, None))

        if entries:
            inode = addnodes.index(entries=entries)
            ret.insert(0, inode)

        # if the node has content, set up a signature and parse the content
        if self.has_content:
            descnode = addnodes.desc()
            descnode['domain'] = 'bb'
            descnode['objtype'] = self.ref_type
            descnode['noindex'] = True
            signode = addnodes.desc_signature(fullname, '')

            if self.name_annotation:
                annotation = "%s " % self.name_annotation
                signode += addnodes.desc_annotation(annotation, annotation)
            signode += addnodes.desc_name(fullname, fullname)
            descnode += signode

            contentnode = addnodes.desc_content()
            self.state.nested_parse(self.content, 0, contentnode)
            DocFieldTransformer(self).transform_all(contentnode)
            descnode += contentnode

            ret.append(descnode)

        return ret
开发者ID:Cray,项目名称:buildbot,代码行数:56,代码来源:ext.py

示例11: run

    def run(self):
        """Same as :meth:`sphinx.directives.ObjectDescription`
        but using :class:`FortranDocFieldTransformer`"""
        if ':' in self.name:
            self.domain, self.objtype = self.name.split(':', 1)
        else:
            self.domain, self.objtype = '', self.name
        self.env = self.state.document.settings.env
        self.indexnode = addnodes.index(entries=[])

        node = addnodes.desc()
        node.document = self.state.document
        node['domain'] = self.domain
        # 'desctype' is a backwards compatible attribute
        node['objtype'] = node['desctype'] = self.objtype
        node['noindex'] = noindex = ('noindex' in self.options)

        self.names = []
        signatures = self.get_signatures()
        for i, sig in enumerate(signatures):
            # add a signature node for each signature in the current unit
            # and add a reference target for it
            signode = addnodes.desc_signature(sig, '')
            signode['first'] = False
            node.append(signode)
            try:
                # name can also be a tuple, e.g. (classname, objname);
                # this is strictly domain-specific (i.e. no assumptions may
                # be made in this base class)
                name = self.handle_signature(sig, signode)
            except ValueError:
                # signature parsing failed
                signode.clear()
                signode += addnodes.desc_name(sig, sig)
                continue  # we don't want an index entry here
            if not isinstance(name[0], unicode):
                name = (unicode(name), name[1])
            if not noindex and name not in self.names:
                # only add target and index entry if this is the first
                # description of the object with this name in this desc block
                self.names.append(name)
                self.add_target_and_index(name, sig, signode)

        modname = signode.get('module')
        typename = signode.get('type')
        contentnode = addnodes.desc_content()
        node.append(contentnode)
        if self.names:
            # needed for association of version{added,changed} directives
            self.env.temp_data['object'] = self.names[0]
        self.before_content()
        self.state.nested_parse(self.content, self.content_offset, contentnode)
        FortranDocFieldTransformer(self, modname=modname, typename=typename).transform_all(contentnode)
        self.env.temp_data['object'] = None
        self.after_content()
        return [self.indexnode, node]
开发者ID:leloulight,项目名称:magic,代码行数:56,代码来源:fortran_domain.py

示例12: 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

示例13: __init__

    def __init__(self, directive, refkey, key_elem, doc):
        label = nodes.strong('@provides', '@provides')
        sep = nodes.Text(': ', ': ')
        par = addnodes.desc_signature('<autodoc>', '', label, sep, key_elem)
        update_attrs(par, directive)
        self.name = 'py:ibkey'

        super(ibkey, self).__init__()
        self += par
        self += doc
        update_attrs(self, directive)
开发者ID:novakadam94,项目名称:docs,代码行数:11,代码来源:ibkeys.py

示例14: _make_index_section

 def _make_index_section(self, obj, title, id):
     section = self._make_section(title)
     subobjs = obj.filter_by_id(id)
     kwargs = {
         'refdomain': 'cpp',
         'refexplicit': False,
     }
     if subobjs:
         lst = addnodes.desc()
         lst['objtype'] = 'function function-index'
         for obj in subobjs:
             desc = addnodes.desc_signature()
             span = nodes.inline()
             try:
                 kwargs['reftype'] = 'func'
                 if obj.rv is not None:
                     span += addnodes.desc_type(text=str(obj.rv))
             except AttributeError:
                 kwargs['reftype'] = 'member'
                 span += addnodes.desc_type(text=str(obj.typename))
             desc += span
             desc += nodes.Text(u' ')
             name = unicode(obj.name)
             kwargs['reftarget'] = unicode(obj.get_name())
             name = name.split('::')[-1]
             desc_name = addnodes.desc_name()
             refnode = addnodes.pending_xref('', **kwargs)
             innernode = nodes.literal(text=name)
             innernode.attributes['classes'].extend(['xref', 'cpp', 'cpp-func'])
             refnode += innernode
             desc_name += refnode
             desc += desc_name
             try:
                 paramlist = addnodes.desc_parameterlist()
                 for param_obj in obj.signature:
                     param = addnodes.desc_parameter('', '', noemph=True)
                     if param_obj.type is not None:
                         param += nodes.Text(str(param_obj.type) + ' ')
                     param += nodes.emphasis(text=str(param_obj.name))
                     paramlist += param
                 desc += paramlist
                 if obj.const:
                     desc += nodes.Text(u' const')
             except AttributeError:
                 pass
             lst += desc
         section += lst
         return section
     return None
开发者ID:aldebaran,项目名称:doc-tools,代码行数:49,代码来源:__init__.py

示例15: run

    def run(self):
        if ':' in self.name:
            self.domain, self.objtype = self.name.split(':', 1)
        else:
            self.domain, self.objtype = '', self.name
        self.env = self.state.document.settings.env

        obj_name, = self.arguments
        for obj in self.gen_type.instances:
            if obj.name == obj_name:
                break
        else:
            raise ValueError('unknown instance {}'.format(obj_name))

        node = addnodes.desc()
        node.document = self.state.document
        node['domain'] = self.domain
        node['objtype'] = node['desctype'] = self.objtype
        node['noindex'] = False
        node.name = obj.slug
        pobj = GenObjPlaceholder(self.env.docname, obj.brief)

        genobjs = self.env.domaindata['envy']['genobjs']

        signode = addnodes.desc_signature('', '')
        signode['first'] = True
        node.append(signode)
        self.make_signature(obj, signode)
        signode['names'].append(obj.name)
        signode['ids'].append(obj.slug)
        self.state.document.note_explicit_target(signode)

        if obj.slug in genobjs:
            other = genobjs[obj.slug]
            self.state_machine.reporter.warning('duplicate object {}, other instance in {}'.format(obj.slug, self.env.doc2path(other.docname)))
        genobjs[obj.slug] = pobj

        contentnode = addnodes.desc_content()
        node.append(contentnode)
        vl = ViewList()
        doc = prepare_docstring(obj.doc or '')
        for line in doc:
            vl.append(line, obj_name)
        self.state.nested_parse(vl, 0, contentnode)

        return [
            node
        ]
开发者ID:envytools,项目名称:envytools,代码行数:48,代码来源:envy.py


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