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


Python addnodes.desc_name函数代码示例

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


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

示例1: handle_signature

    def handle_signature(self, sig, signode):
        """Transform a C signature into RST nodes."""
        # first try the function pointer signature regex, it's more specific
        m = c_funcptr_sig_re.match(sig)
        if m is None:
            m = c_sig_re.match(sig)
        if m is None:
            raise ValueError('no match')
        rettype, name, arglist, const = m.groups()

        signode += addnodes.desc_type('', '')
        self._parse_type(signode[-1], rettype)
        try:
            classname, funcname = name.split('::', 1)
            classname += '::'
            signode += addnodes.desc_addname(classname, classname)
            signode += addnodes.desc_name(funcname, funcname)
            # name (the full name) is still both parts
        except ValueError:
            signode += addnodes.desc_name(name, name)
        # clean up parentheses from canonical name
        m = c_funcptr_name_re.match(name)
        if m:
            name = m.group(1)

        typename = self.env.temp_data.get('c:type')
        if self.name == 'c:member' and typename:
            fullname = typename + '.' + name
        else:
            fullname = name

        if not arglist:
            if self.objtype == 'function':
                # for functions, add an empty parameter list
                signode += addnodes.desc_parameterlist()
            if const:
                signode += addnodes.desc_addname(const, const)
            return fullname

        paramlist = addnodes.desc_parameterlist()
        arglist = arglist.replace('`', '').replace('\\ ', '') # remove markup
        # this messes up function pointer types, but not too badly ;)
        args = arglist.split(',')
        for arg in args:
            arg = arg.strip()
            param = addnodes.desc_parameter('', '', noemph=True)
            try:
                ctype, argname = arg.rsplit(' ', 1)
            except ValueError:
                # no argument name given, only the type
                self._parse_type(param, arg)
            else:
                self._parse_type(param, ctype)
                # separate by non-breaking space in the output
                param += nodes.emphasis(' '+argname, u'\xa0'+argname)
            paramlist += param
        signode += paramlist
        if const:
            signode += addnodes.desc_addname(const, const)
        return fullname
开发者ID:Scalr,项目名称:sphinx,代码行数:60,代码来源:c.py

示例2: attach_function

    def attach_function(self, node, func):
        owner, name = func.name.split_owner()
        # Olaf: Never show Class::
        owner = None
        if owner is not None:
            owner = unicode(owner) + '::'
            node += addnodes.desc_addname(owner, owner)

        # cast operator is special.  in this case the return value
        # is reversed.
        if isinstance(name, CastOpDefExpr):
            node += addnodes.desc_name('operator', 'operator')
            node += nodes.Text(u' ')
            self.attach_type(node, name.typename)
        else:
            funcname = unicode(name)
            node += addnodes.desc_name(funcname, funcname)

        paramlist = addnodes.desc_parameterlist()
        for arg in func.signature:
            param = addnodes.desc_parameter('', '', noemph=True)
            if arg.type is not None:
                self.attach_type(param, arg.type)
                param += nodes.Text(u' ')
            param += nodes.emphasis(unicode(arg.name), unicode(arg.name))
            if arg.default is not None:
                def_ = u'=' + unicode(arg.default)
                param += nodes.emphasis(def_, def_)
            paramlist += param

        node += paramlist
        if func.const:
            node += addnodes.desc_addname(' const', ' const')
        if func.pure_virtual:
            node += addnodes.desc_addname(' = 0', ' = 0')
开发者ID:flyeven,项目名称:doc,代码行数:35,代码来源:matlabdomain.py

示例3: handle_signature

 def handle_signature(self, sig, signode):
     method = self.method.upper() + ' '
     signode += addnodes.desc_name(method, method)
     offset = 0
     path = None
     for match in http_sig_param_re.finditer(sig):
         path = sig[offset:match.start()]
         signode += addnodes.desc_name(path, path)
         params = addnodes.desc_parameterlist()
         typ = match.group('type')
         if typ:
             typ += ': '
             params += addnodes.desc_annotation(typ, typ)
         name = match.group('name')
         params += addnodes.desc_parameter(name, name)
         signode += params
         offset = match.end()
     if offset < len(sig):
         path = sig[offset:len(sig)]
         signode += addnodes.desc_name(path, path)
     assert path is not None, 'no matches for sig: %s' % sig
     fullname = self.method.upper() + ' ' + path
     signode['method'] = self.method
     signode['path'] = sig
     signode['fullname'] = fullname
     return (fullname, self.method, sig)
开发者ID:felipeblassioli,项目名称:sphinx_autoflask,代码行数:26,代码来源:httpdomain.py

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

示例5: parse_django_adminopt_node

def parse_django_adminopt_node(env, sig, signode):
    """A copy of sphinx.directives.CmdoptionDesc.parse_signature()"""
    from sphinx.domains.std import option_desc_re
    count = 0
    firstname = ''
    for m in option_desc_re.finditer(sig):
        optname, args = m.groups()
        if count:
            signode += addnodes.desc_addname(', ', ', ')
        signode += addnodes.desc_name(optname, optname)
        signode += addnodes.desc_addname(args, args)
        if not count:
            firstname = optname
        count += 1
    if not count:
        for m in simple_option_desc_re.finditer(sig):
            optname, args = m.groups()
            if count:
                signode += addnodes.desc_addname(', ', ', ')
            signode += addnodes.desc_name(optname, optname)
            signode += addnodes.desc_addname(args, args)
            if not count:
                firstname = optname
            count += 1
    if not firstname:
        raise ValueError
    return firstname
开发者ID:bo858585,项目名称:django_documentation,代码行数:27,代码来源:djangodocs.py

示例6: handle_signature

 def handle_signature(self, sig, signode):
     method = self.method.upper() + " "
     signode += addnodes.desc_name(method, method)
     offset = 0
     path = None
     for match in http_sig_param_re.finditer(sig):
         path = sig[offset : match.start()]
         signode += addnodes.desc_name(path, path)
         params = addnodes.desc_parameterlist()
         typ = match.group("type")
         if typ:
             typ += ": "
             params += addnodes.desc_annotation(typ, typ)
         name = match.group("name")
         params += addnodes.desc_parameter(name, name)
         signode += params
         offset = match.end()
     if offset < len(sig):
         path = sig[offset : len(sig)]
         signode += addnodes.desc_name(path, path)
     if path is None:
         assert False, "no matches for sig: %s" % sig
     fullname = self.method.upper() + " " + path
     signode["method"] = self.method
     signode["path"] = sig
     signode["fullname"] = fullname
     return (fullname, self.method, sig)
开发者ID:apache,项目名称:couchdb-documentation,代码行数:27,代码来源:httpdomain.py

示例7: parse_macro

def parse_macro(env, sig, signode):
    #import rpdb2 ; rpdb2.start_embedded_debugger('foo')
    m = macro_sig_re.match(sig)
    if not m:
        signode += addnodes.desc_name(sig, sig)
        return sig
    name, args = m.groups()
    signode += addnodes.desc_name(name, name)
    plist = desc_cmake_argumentlist()
    for m in macro_param_re.finditer(args):
        arg = m.group(0)

        if arg.startswith('['):
            arg = arg[1:-1].strip()
            x = desc_cmake_argument()
            opt = addnodes.desc_optional()
            x += opt
            m = macro_param_re.match(arg)

            assert m is not None, "%s does not match %s" % (arg, macro_param_re.pattern)

            opt += _get_param_node(m)
            plist += x

        # elif arg.startswith('{') choice
        else:
            x = desc_cmake_argument()
            x += _get_param_node(m)
            plist += x

    signode += plist
    return name
开发者ID:Lemma1,项目名称:MINAMI,代码行数:32,代码来源:cmakedomain.py

示例8: parse_macro

def parse_macro(env, sig, signode):
    m = macro_sig_re.match(sig)
    if not m:
        signode += addnodes.desc_name(sig, sig)
        return sig
    name, args = m.groups()
    signode += addnodes.desc_name(name, name)
    plist = desc_cmake_argumentlist()
    for m in macro_param_re.finditer(args):
        arg = m.group(0)
        if arg.startswith('['):
            arg = arg[1:-1].strip()
            x = desc_cmake_argument()
            opt = addnodes.desc_optional()
            x += opt
            m = macro_param_re.match(arg)
            assert m is not None, "%s does not match %s" % (arg, macro_param_re.pattern)
            opt += _get_param_node(m, True)
            plist += x
        else:
            x = desc_cmake_argument()
            x += _get_param_node(m, False)
            plist += x
    signode += plist
    return name
开发者ID:tak2004,项目名称:RadonCMakeFramework,代码行数:25,代码来源:cmakedomain.py

示例9: handle_signature

    def handle_signature(self, sig, signode):
        """
        Transform a CFEngine 3 signature into RST nodes.
        """
        sig_d = {}
        m = cf3_sig_re.match(sig)
        try:
            sig_d['type'], sig_d['ns'], sig_d['id'], sig_d['args'] = m.groups()
        except AttributeError:
            raise ValueError

        sig_d['ns'] = sig_d['ns'] or self.options.get(
            'namespace', self.env.temp_data.get('cf3:namespace')
        )
        fullname = []
        fn_app   = fullname.append
        fn_app(self.objtype + _FN_SEP)
        if self.objtype in ('body', 'bundle'):
            tnode  = addnodes.desc_type('', '')
            tnode += nodes.Text(self.objtype + _SP, self.objtype)

            try:
                sig_d['type'] = sig_d['type'].strip()
                tnode += nodes.Text(sig_d['type'] + _SP, sig_d['type'])
                fn_app(sig_d['type'] + _FN_SEP)
            except AttributeError:
                self.state_machine.reporter.warning(
                    'invalid %s definition: %s' % (self.objtype, sig),
                    line=self.lineno
                )
            signode += tnode

        if sig_d['ns'] and sig_d['ns'] != 'default' \
            and self.env.config.add_module_names:
            signode += addnodes.desc_addname(
                sig_d['ns'], sig_d['ns'] + _NS_SEP
            )
        signode += addnodes.desc_name(sig_d['id'], sig_d['id'])
        fn_app(sig_d['id'])

        signode['namespace'] = sig_d['ns']
        signode['fullname']  = ''.join(fullname)

        if self.objtype == 'class':
            signode += addnodes.desc_name(_CL_MRK, _CL_MRK)
            return ''.join(fullname), sig_d['ns']

        if not sig_d['args'] and self.objtype == 'function':
            signode += addnodes.desc_parameterlist()
            return ''.join(fullname), sig_d['ns']

        if sig_d['args']:
            paramlist = addnodes.desc_parameterlist()
            for arg in sig_d['args'].split(','):
                arg = arg.strip()
                paramlist += addnodes.desc_parameter(arg, arg)
            signode += paramlist

        return ''.join(fullname), sig_d['ns']
开发者ID:Lemma1,项目名称:MINAMI,代码行数:59,代码来源:cf3domain.py

示例10: handle_signature

    def handle_signature(self, sig, signode):
        method = self.method.upper() + ' '
        signode += addnodes.desc_name(method, method)
        signode += addnodes.desc_name(sig, sig)

        fullname = "Template" + ' ' + sig
        signode['method'] = self.method
        signode['path'] = sig
        signode['fullname'] = fullname
        return (fullname, self.method, sig)
开发者ID:offlinehacker,项目名称:sphinxcontrib.jinjadomain,代码行数:10,代码来源:jinjadomain.py

示例11: handle_signature

    def handle_signature(self, sig, signode):
        symbol_name = []

        def render_sexp(sexp, signode=None, prepend_node=None):
            desc_sexplist = addnodes.desc_parameterlist()
            desc_sexplist.child_text_separator = ' '
            if prepend_node:
                desc_sexplist.append(prepend_node)
            if signode:
                signode.append(desc_sexplist)
            for atom in sexp:
                if isinstance(atom, list):
                    render_sexp(atom, desc_sexplist)
                else:
                    render_atom(atom, desc_sexplist)
            return desc_sexplist

        def render_atom(token, signode, noemph=True):
            "add syntax hi-lighting to interesting atoms"

            if token.startswith("&") or token.startswith(":"):
                signode.append(addnodes.desc_parameter(token, token))
            else:
                signode.append(addnodes.desc_parameter(token, token))

        package = self.env.temp_data.get('el:package')

        objtype = self.get_signature_prefix(sig)
        signode.append(addnodes.desc_annotation(objtype, objtype))

        lisp_args = self.options.get('args', [])
        if not lisp_args:
            v = self.options.get('value')
            lisp_args = [v] if v else []
        if not lisp_args:
            lisp_args = DATA_ARGS.get(package, {}).get(sig, [])
        if not lisp_args:
            v = DATA_VALUES.get(package, {}).get(sig)
            lisp_args = [quote_value_if_necessary(v)] if v else []

        if lisp_args:
            function_name = addnodes.desc_name(sig, sig + " ")
        else:
            function_name = addnodes.desc_name(sig, sig)

        if lisp_args:
            arg_list = render_sexp(lisp_args, prepend_node=function_name)
            signode.append(arg_list)
        else:
            signode.append(function_name)

        symbol_name = sig
        if not symbol_name:
            raise Exception("Unknown symbol type for signature %s" % sig)
        return objtype.strip(), symbol_name
开发者ID:hyphenlee,项目名称:emacs.d,代码行数:55,代码来源:eldomain.py

示例12: parse_event

def parse_event(env, sig, signode):
    m = event_sig_re.match(sig)
    if not m:
        signode += addnodes.desc_name(sig, sig)
        return sig
    name, args = m.groups()
    signode += addnodes.desc_name(name, name)
    plist = addnodes.desc_parameterlist()
    for arg in args.split(','):
        arg = arg.strip()
        plist += addnodes.desc_parameter(arg, arg)
    signode += plist
    return name
开发者ID:certik,项目名称:sphinx,代码行数:13,代码来源:conf.py

示例13: p_method_parts

		def p_method_parts(p):
			'''method : returnval WORD
			          | returnval WORD COLON  parameters'''
			if (len(p) == 5):
				p[0] = p[1]
				p[0] += nodes.Text(u' ')
				p[0] += addnodes.desc_name(p[2], p[2])
				p[0] += addnodes.desc_annotation(p[3], p[3])
				p[0] += p[4]
			else:
				p[0] = p[1]
				p[0] += nodes.Text(u' ')
				p[0] += addnodes.desc_name(p[2], p[2])
开发者ID:jespinoz,项目名称:jia-mini-python,代码行数:13,代码来源:objcdomain.py

示例14: handle_signature

    def handle_signature(self, sig, signode):
        symbol_name = []
        type = []

        def render_sexp(sexp, signode=None, prepend_node=None):
            desc_sexplist = addnodes.desc_parameterlist()
            desc_sexplist.child_text_separator = ' '
            if prepend_node:
                desc_sexplist.append(prepend_node)
            if signode:
                signode.append(desc_sexplist)
            symbol = False
            for atom in sexp:
                if isinstance(atom, list):
                    render_sexp(atom, desc_sexplist)
                else:
                    symbol = render_atom(atom, desc_sexplist)
            return desc_sexplist

        def render_atom(token, signode, noemph=True):
            "add syntax hi-lighting to interesting atoms"

            if token.startswith("&") or token.startswith(":"):
                signode.append(addnodes.desc_parameter(token, token))
            else:
                signode.append(addnodes.desc_parameter(token, token))

        package = self.env.temp_data.get('cl:package')

        objtype = self.get_signature_prefix(sig)
        signode.append(addnodes.desc_annotation(objtype, objtype))
        lisp_args = args[package].get(sig.upper(), "")

        if lisp_args.strip():
            function_name = addnodes.desc_name(sig, sig + " ")
        else:
            function_name = addnodes.desc_name(sig, sig)

        if not lisp_args.strip() and self.objtype in ["function"]:
            lisp_args = "()"
        if lisp_args.strip():
            arg_list = render_sexp(_read(lisp_args), prepend_node=function_name)
            signode.append(arg_list)
        else:
            signode.append(function_name)

        symbol_name = sig
        if not symbol_name:
            raise Exception("Unknown symbol type for signature %s" % sig)
        return objtype.strip(), symbol_name.upper()
开发者ID:tkf,项目名称:sphinxcontrib-cldomain,代码行数:50,代码来源:cldomain.py

示例15: parse_ystaticattr

def parse_ystaticattr(env,attr,attrnode):
	m=re.match(r'([a-zA-Z0-9_]+)\.(.*)\(=(.*)\)',attr)
	if not m:
		print 100*'@'+' Static attribute %s not matched'%attr
		attrnode+=addnodes.desc_name(attr,attr)
	klass,name,default=m.groups()
	#attrnode+=addnodes.desc_type('static','static')
	attrnode+=addnodes.desc_name(name,name)
	plist=addnodes.desc_parameterlist()
	if default=='': default='unspecified'
	plist+=addnodes.desc_parameter('='+default,'='+default)
	attrnode+=plist
	attrnode+=addnodes.desc_annotation('  [static]','  [static]')
	return klass+'.'+name
开发者ID:anna-effeindzourou,项目名称:trunk,代码行数:14,代码来源:confBook.py


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