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


Python addnodes.desc_annotation函数代码示例

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


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

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

示例2: handle_signature

 def handle_signature(self, sig, signode):
     """Handle IDL signature lines"""
     m = idl_sig_re.match(sig)
     if not m:
         self.env.app.warn("Signature did not match for {}".format(sig))
         raise ValueError("Signature did not match!")
     pro_or_function, name, arglist = m.groups()
     
     # Add a prefix for function/program
     if self.display_prefix:
         signode += addnodes.desc_annotation(self.display_prefix,
                                             self.display_prefix)
     
     signode += addnodes.desc_annotation(self.objtype, self.objtype)
     
     # Register the full name of the program
     signode['fullname'] = name
     signode += addnodes.desc_name(name, name)
     
     # Parse the argument list from the signature
     if not arglist and self.objtype == 'function':
         signode += addnodes.desc_parameterlist()
     elif arglist:
         _pseudo_parse_arglist(signode, arglist)
     return (name, '')
开发者ID:alexrudy,项目名称:sphinx-idl,代码行数:25,代码来源:domain.py

示例3: handle_signature

    def handle_signature(self, sig, signode, display_text=None):
        """This method determines the appearance of the object.

        Overloaded Args:
            display_test: Used for overriding the object name.
        """
        # Override sig with display_text if provided.
        if display_text is None:
            display_text = sig

        display_text, argument, alt_forms = self.process_name(display_text)

        # Add a label before the name of the object.
        signode += addnodes.desc_annotation(*('%s ' % self.LABEL,) * 2)
        # Add the object name.
        signode += addnodes.desc_name(sig, display_text)
        # Add arguments.
        if argument:
            argument = '%s %s' % (self.ARGUMENT_SEPARATOR, argument)
            signode += addnodes.desc_annotation(argument, argument)
        # Add alternate object names.
        if alt_forms:
            signode += addnodes.desc_annotation(
                *(self.ALT_FORM_TEMPLATE % (', '.join(alt_forms)),) * 2)

        signode['fullname'] = sig
        return (sig, self.NAME, sig)
开发者ID:aosprey,项目名称:rose,代码行数:27,代码来源:rose_domain.py

示例4: handle_signature

    def handle_signature(self, sig: str, signode: addnodes.desc) -> str:
        """Transform signature into RST nodes"""
        signode += addnodes.desc_annotation(self.typename, self.typename + " ")
        signode += addnodes.desc_name(sig, sig)

        if 'badges' in self.options:
            badges = addnodes.desc_annotation()
            badges['classes'] += ['badges']
            content = StringList([self.options['badges']])
            self.state.nested_parse(content, 0, badges)
            signode += badges


        if 'replaces_section_title' in self.options:
            section = self.state.parent
            if isinstance(section, nodes.section):
                title = section[-1]
                if isinstance(title, nodes.title):
                    section.remove(title)
                else:
                    signode += self.state.document.reporter.warning(
                        "%s:%s:: must follow section directly to replace section title"
                        % (self.domain, self.objtype), line = self.lineno
                    )
            else:
                signode += self.state.document.reporter.warning(
                    "%s:%s:: must be in section to replace section title"
                    % (self.domain, self.objtype), line = self.lineno
                )

        return sig
开发者ID:bioconda,项目名称:bioconda-utils,代码行数:31,代码来源:sphinxext.py

示例5: handle_signature

    def handle_signature(self, sig, signode):
        context, name, argstart, arglist, argend, retann = self.parse_signature(sig)

        self.context, self.contextsep = self.build_context(context)
        self.module = self.options.get('module', self.env.temp_data.get('haka:module'))
        self.objtype = self.build_objtype()
        self.idxtype = self.options.get('idxtype') or self.options.get('objtype')
        self.name = name
        self.argstart = argstart
        self.arglist = arglist
        self.argend = argend
        self.retann = retann

        add_module = True
        fullname = name

        signode['module'] = self.module
        signode['class'] = self.context
        signode['fullname'] = fullname

        prefix = "%s " % (self.objtype)
        signode += addnodes.desc_annotation(prefix, prefix)

        if self.module and self.needs_module():
            modname = '%s.' % (self.module)
            signode += addnodes.desc_addname(modname, modname)

        self.build_signode(signode)

        anno = self.options.get('annotation')
        if anno:
            signode += addnodes.desc_annotation(' ' + anno, ' ' + anno)

        return {'fullname': fullname, 'context': self.context,
                'objtype': self.objtype, 'idxctx': self.options.get('idxctx') or ""}
开发者ID:Cyber-Forensic,项目名称:haka,代码行数:35,代码来源:haka.py

示例6: attach_modifiers

 def attach_modifiers(self, node, obj):
     if obj.visibility != 'public':
         node += addnodes.desc_annotation(obj.visibility,
                                          obj.visibility)
         node += nodes.Text(' ')
     if obj.static:
         node += addnodes.desc_annotation('static', 'static')
         node += nodes.Text(' ')
开发者ID:ZoomQuiet,项目名称:python-doc-translation,代码行数:8,代码来源:cpp.py

示例7: handle_signature

    def handle_signature(self, sig, signode):
        a = (context, name, argstart, arglist, argend, retann) = self.parse_signature(sig)

        self.context, self.contextsep = self.build_context(context)
        self.module = self.options.get('module', self.env.temp_data.get('lua:module'))
        self.clsname = self.options.get('class', self.env.temp_data.get('lua:class'))
        self.objtype = self.build_objtype()
        self.idxtype = self.options.get('idxtype') or self.options.get('objtype')
        self.name = name
        self.argstart = argstart
        self.arglist = arglist
        self.argend = argend
        self.retann = retann
        # print "context: '%s', name: '%s'" % a[:2]
        # print "module: '%s', clsname: '%s', idxtype: '%s'" % (self.module, self.clsname, self.idxtype)
        # print "typename: '%s', objtype: '%s'" % (self.typename, self.objtype)
        # print "needs_module: '%s', needs_class: '%s'" % (self.needs_class(), self.needs_module())
        # print ""

        add_module = True
        fullname = name

        signode['module'] = self.module
        signode['class'] = self.context
        signode['fullname'] = fullname

        prefix = "%s " % (self.objtype)
        signode += addnodes.desc_annotation(prefix, prefix)

        clsname = ''
        if fullname.find('.') != -1 or str(self.typename) == "object":
            pass
        elif self.clsname and self.needs_class():
            sprtr = '.' if str(self.typename) == "data" else ':'
            clsname = '%s%s' % (self.clsname, sprtr)
        elif self.module and self.needs_module():
            clsname = '%s.' % (self.module)

        if clsname:
            signode += addnodes.desc_addname(clsname, clsname)

#        if self.clsname and self.needs_class():
#            signode += addnodes.desc_addname(clsname, clsname)
#        elif str(self.typename) == "data":
#            clsname = '%s:' % (self.clsname)
#            signode += addnodes.desc_addname(clsname, clsname)
#        elif self.module and self.needs_module():
#            modname = '%s.' % (self.module)
#            signode += addnodes.desc_addname(modname, modname)

        self.build_signode(signode)

        anno = self.options.get('annotation')
        if anno:
            signode += addnodes.desc_annotation(' ' + anno, ' ' + anno)

        return {'fullname': fullname, 'context': self.context,
                'objtype': self.objtype, 'idxctx': self.options.get('idxctx') or ""}
开发者ID:daurnimator,项目名称:tarantool,代码行数:58,代码来源:LuaDomain.py

示例8: handle_signature

    def handle_signature(self, sig_input, signode):
        """Parses out pieces from construct signatures

        Parses out prefix and argument list from construct definition. This is
        assuming that the .NET languages this will support will be in a common
        format, such as::

            Namespace.Class.method(argument, argument, ...)

        The namespace and class will be determined by the nesting of rST
        directives.

        Returns
            Altered :py:data:`signode` with attributes corrected for rST
            nesting/etc
        """
        try:
            sig = self.parse_signature(sig_input.strip())
        except ValueError:
            self.env.warn(self.env.docname,
                          'Parsing signature failed: "{}"'.format(sig_input),
                          self.lineno)
            raise

        prefix = self.env.ref_context.get('dn:prefix', None)

        if prefix is not None:
            sig.prefix = prefix

        signode['object'] = sig.member
        signode['prefix'] = sig.prefix
        signode['fullname'] = sig.full_name()

        # Prefix modifiers
        if self.display_prefix:
            signode += addnodes.desc_annotation(self.display_prefix,
                                                self.display_prefix)
        for prefix in ['public', 'protected', 'static']:
            if prefix in self.options:
                signode += addnodes.desc_annotation(prefix + ' ',
                                                    prefix + ' ')

        # Show prefix only on shorter declarations
        if sig.prefix is not None and not self.has_arguments:
            signode += addnodes.desc_addname(sig.prefix + '.', sig.prefix + '.')

        signode += addnodes.desc_name(sig.member, sig.member)
        if self.has_arguments:
            if not sig.arguments:
                signode += addnodes.desc_parameterlist()
            else:
                # TODO replace this
                _pseudo_parse_arglist(signode, ', '.join(sig.arguments))

        if isinstance(self, DotNetObjectNested):
            return sig.full_name(), sig.full_name()
        return sig.full_name(), sig.prefix
开发者ID:anurse,项目名称:sphinxcontrib-dotnetdomain,代码行数:57,代码来源:dotnetdomain.py

示例9: attach_modifiers

 def attach_modifiers(self, node, obj, visibility="public"):
     if obj.visibility != visibility:
         node += addnodes.desc_annotation(obj.visibility, obj.visibility)
         node += nodes.Text(" ")
     if obj.static:
         node += addnodes.desc_annotation("static", "static")
         node += nodes.Text(" ")
     if getattr(obj, "constexpr", False):
         node += addnodes.desc_annotation("constexpr", "constexpr")
         node += nodes.Text(" ")
开发者ID:pykomke,项目名称:Kurz_Python_KE,代码行数:10,代码来源:cpp.py

示例10: p_returnval_expr

		def p_returnval_expr(p):
			'''returnval : MINUS LPAREN expression RPAREN
			             | PLUS LPAREN expression RPAREN'''
			p[0] = addnodes.desc_annotation(p[1], p[1])
			p[0] += nodes.Text(u' ')
			p[0] += addnodes.desc_annotation(p[2], p[2])
			p[0] += nodes.Text(u' ')
 			p[0] += p[3]
			p[0] += nodes.Text(u' ')
			p[0] += addnodes.desc_annotation(p[4], p[4])
开发者ID:jespinoz,项目名称:jia-mini-python,代码行数:10,代码来源:objcdomain.py

示例11: attach_modifiers

 def attach_modifiers(self, node, obj, visibility='public'):
     if obj.visibility != visibility:
         node += addnodes.desc_annotation(obj.visibility,
                                          obj.visibility)
         node += nodes.Text(' ')
     if obj.static:
         node += addnodes.desc_annotation('static', 'static')
         node += nodes.Text(' ')
     if getattr(obj, 'constexpr', False):
         node += addnodes.desc_annotation('constexpr', 'constexpr')
         node += nodes.Text(' ')
开发者ID:aras0,项目名称:porownywarka-ofert,代码行数:11,代码来源:cpp.py

示例12: attach_modifiers

 def attach_modifiers(self, node, obj):
     lname = self.__class__.langname
     node += nodes.strong(lname + ":", lname + ":")
     node += addnodes.desc_name(" ", " ")
     if obj.visibility != 'public':
         node += addnodes.desc_annotation(obj.visibility,
                                          obj.visibility)
         node += nodes.Text(' ')
     if obj.static:
         node += addnodes.desc_annotation('static', 'static')
         node += nodes.Text(' ')
开发者ID:ethanrublee,项目名称:libopencv-debian,代码行数:11,代码来源:ocv.py

示例13: p_parameters_exp

		def p_parameters_exp(p):
			'''parameters : LPAREN expression RPAREN methodname
			              | LPAREN expression RPAREN methodname parameter'''
			p[0] = addnodes.desc_annotation(p[1], p[1])
			p[0] += nodes.Text(u' ')
			p[0] += p[2]
			p[0] += nodes.Text(u' ')
			p[0] += addnodes.desc_annotation(p[3], p[3])
			p[0] += p[4]

			if (len(p) == 6):
				p[0] += nodes.Text(u' ')
				p[0] += p[5]
开发者ID:jespinoz,项目名称:jia-mini-python,代码行数:13,代码来源:objcdomain.py

示例14: handle_signature

    def handle_signature(self, sig, signode):
        """Transform a Python signature into RST nodes.

        Return (fully qualified name of the thing, classname if any).

        If inside a class, the current class name is handled intelligently:
        * it is stripped from the displayed name if present
        * it is added to the full name (return value) if not present
        """
        name_prefix = None
        name = sig
        arglist = None
        retann = None

        # determine module and class name (if applicable), as well as full name
        modname = self.options.get(
            'module', self.env.temp_data.get('py:module'))
        classname = self.env.temp_data.get('py:class')

        fullname = name

        signode['module'] = modname
        signode['class'] = classname
        signode['fullname'] = fullname

        sig_prefix = self.get_signature_prefix(sig)
        if sig_prefix:
            signode += addnodes.desc_annotation(sig_prefix, sig_prefix)

        if name_prefix:
            signode += addnodes.desc_addname(name_prefix, name_prefix)

        anno = self.options.get('annotation')

        signode += addnodes.desc_name(name, name)
        if not arglist:
            if self.needs_arglist():
                # for callables, add an empty parameter list
                signode += addnodes.desc_parameterlist()
            if retann:
                signode += addnodes.desc_returns(retann, retann)
            if anno:
                signode += addnodes.desc_annotation(' ' + anno, ' ' + anno)
            return fullname, name_prefix

        _pseudo_parse_arglist(signode, arglist)
        if retann:
            signode += addnodes.desc_returns(retann, retann)
        if anno:
            signode += addnodes.desc_annotation(' ' + anno, ' ' + anno)
        return fullname, name_prefix
开发者ID:10173677,项目名称:jenkins-job-builder,代码行数:51,代码来源:yaml.py

示例15: handle_signature

    def handle_signature(self, sig, signode):
        match = re.search('(\w+)', sig)
        name = match.groups()[0]
        # At this point, we make no attempt to break up the arglist into
        # reqired parameters, keywords, optional arguments etc.
        # This would be very hard, since we would have to cover the syntax
        # of shell, IDL, S-Lang, ...
        # For our output all we want is to attach it to the name in
        # reasonable formatting.
        arglist = sig[len(name):]

        anno = self.options.get('annotation')
        lang = self.options.get('language')

        signode += addnodes.desc_name(name, name)
        # addname has a good formatting, even if it is meant for a
        # different use in sphinx for python.
        # Sphinx expects name + parameterlist, but unfortunately,
        # the parameterlist is automatically wrapped in (), so we avoid that
        # here.
        signode += addnodes.desc_addname(arglist, arglist)

        if lang:
            signode += addnodes.desc(' ' + lang, ' ' + lang)
        if anno:
            signode += addnodes.desc_annotation(' ' + anno, ' ' + anno)
        return name
开发者ID:Chandra-MARX,项目名称:doc,代码行数:27,代码来源:marxmarkup.py


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