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

Python addnodes.desc_addname函数代码示例

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

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



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

def parse_django_adminopt_node(env, sig, signode):
    """A copy of sphinx.directives.CmdoptionDesc.parse_signature()"""
    option_desc_re = None
    # Sphinx >= 1.0 and Sphinx < 1.0, respectively.
    for module in ['sphinx.domains.std', 'sphinx.directives.desc']:
        try:
            mod = import_module(module)
            option_desc_re = mod.option_desc_re
        except ImportError:
            pass
        else:
            break
    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 firstname:
        raise ValueError
    return firstname
开发者ID:alvaromartin,项目名称:baph,代码行数:26,代码来源:djangodocs.py


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


示例5: add_sig_args

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

        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.add_cross_ref(param, arg)
            else:
                self.add_cross_ref(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)
开发者ID:Cyofanni,项目名称:speect,代码行数:29,代码来源:c.py


示例6: handle_signature

 def handle_signature(self, sig, signode):
     """Transform an option description into RST nodes."""
     count = 0
     firstname = ''
     for potential_option in sig.split(', '):
         potential_option = potential_option.strip()
         m = option_desc_re.match(potential_option)
         if not m:
             self.env.warn(
                 self.env.docname,
                 'Malformed option description %r, should '
                 'look like "opt", "-opt args", "--opt args", '
                 '"/opt args" or "+opt args"' % potential_option,
                 self.lineno)
             continue
         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
             signode['allnames'] = [optname]
         else:
             signode['allnames'].append(optname)
         count += 1
     if not firstname:
         raise ValueError
     return firstname
开发者ID:861008761,项目名称:standard_flask_web,代码行数:29,代码来源:std.py


示例7: handle_signature

    def handle_signature(self, sig, signode):
        # type: (unicode, addnodes.desc_signature) -> Tuple[unicode, unicode]
        """Breaks down construct signatures

        Parses out prefix and argument list from construct definition. The
        namespace and class will be determined by the nesting of domain
        directives.
        """
        sig = sig.strip()
        if '(' in sig and sig[-1:] == ')':
            member, arglist = sig.split('(', 1)
            member = member.strip()
            arglist = arglist[:-1].strip()
        else:
            member = sig
            arglist = None
        # If construct is nested, prefix the current prefix
        prefix = self.env.ref_context.get('js:object', None)
        mod_name = self.env.ref_context.get('js:module')
        name = member
        try:
            member_prefix, member_name = member.rsplit('.', 1)
        except ValueError:
            member_name = name
            member_prefix = ''
        finally:
            name = member_name
            if prefix and member_prefix:
                prefix = '.'.join([prefix, member_prefix])
            elif prefix is None and member_prefix:
                prefix = member_prefix
        fullname = name
        if prefix:
            fullname = '.'.join([prefix, name])

        signode['module'] = mod_name
        signode['object'] = prefix
        signode['fullname'] = fullname

        if self.display_prefix:
            signode += addnodes.desc_annotation(self.display_prefix,
                                                self.display_prefix)
        if prefix:
            signode += addnodes.desc_addname(prefix + '.', prefix + '.')
        elif mod_name:
            signode += addnodes.desc_addname(mod_name + '.', mod_name + '.')
        signode += addnodes.desc_name(name, name)
        if self.has_arguments:
            if not arglist:
                signode += addnodes.desc_parameterlist()
            else:
                _pseudo_parse_arglist(signode, arglist)
        return fullname, prefix
开发者ID:nvmanh,项目名称:plant,代码行数:53,代码来源:javascript.py


示例8: parse_c_signature

def parse_c_signature(signode, sig, desctype):
    """Transform a C (or 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('', '')
    parse_c_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)
    if not arglist:
        if desctype == 'cfunction':
            # for functions, add an empty parameter list
            signode += addnodes.desc_parameterlist()
        return name

    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
            parse_c_type(param, arg)
        else:
            parse_c_type(param, ctype)
            param += nodes.emphasis(' '+argname, ' '+argname)
        paramlist += param
    signode += paramlist
    if const:
        signode += addnodes.desc_addname(const, const)
    return name
开发者ID:fedor4ever,项目名称:linux_build,代码行数:50,代码来源:desc.py


示例9: handle_signature

 def handle_signature(self, fqname, signode):
     m = fq_classname_pattern.match(fqname)
     if m is not None:
         package, classname, generics = m.groups()
     else:
         package, classname, generics = None, fqname, None
     if package is not None and self.env.config.java_show_package:
         signode += addnodes.desc_addname(package, package)
     signode += addnodes.desc_name(classname, classname)
     if generics is not None:
         signode += addnodes.desc_addname(generics, generics)
     if package is not None:
         return package + classname
     else:
         return classname
开发者ID:rogerbinns,项目名称:jia-mini-python,代码行数:15,代码来源:javadomain.py


示例10: handle_signature

    def handle_signature(self, sig, signode):
        """Transform an option description into RST nodes."""

        starts_with_arg = re.match(r'\s*\*',sig)

        options = sig.split("!")

        firstname = None
        for i in range(len(options)):
            o = options[i].strip()
            ws = o.split("*")
            if not firstname:
                firstname = ws[0]

            #is_name = not starts_with_arg
            is_name = True

            is_first_name = True
            for x in ws:
                if is_name:
                    n = addnodes.desc_name(x,x)
                    if is_first_name:
                        is_first_name = False
                        if i != 0:
                            n['classes'].append('duplicate')
                    signode += n
                    is_name = not is_name
                else:
                    signode += addnodes.desc_addname(x,x)
                    is_name = not is_name

        return firstname
开发者ID:xcore,项目名称:xdoc,代码行数:32,代码来源:xdirectives.py


示例11: handle_signature

    def handle_signature(self, sig, signode):
        sdkname = self.options.get('sdk', self.env.ref_context.get('qbs:sdk'))
        pkgname = self.options.get('package', self.env.ref_context.get('qbs:package'))
        modname = self.env.ref_context.get('qbs:module', None)
        itemname = self.env.ref_context.get('qbs:item', None)

        type, name, value = self.parse(sig)

        signode['module'] = modname
        signode['package'] = pkgname
        signode['item'] = itemname

        if self.objtype == 'property':
            fullname = self.get_signature_name(objname=(modname or itemname), name=name)
        else:
            fullname = name

        signode['sdk'] = sdkname
        signode['fullname'] = fullname

        sigprefix = self.get_signature_prefix()
        if sigprefix:
            signode += addnodes.desc_annotation(sigprefix, sigprefix)
        if type:
            signode += addnodes.desc_addname(type, type)
        if name:
            signode += addnodes.desc_name(name, name)
        if value:
            signode += addnodes.desc_returns(value, value)

        return fullname
开发者ID:StoiridhProject,项目名称:StoiridhTools,代码行数:31,代码来源:qbs.py


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


示例13: parse_option_desc

def parse_option_desc(signode, sig):
    """Transform an option description into RST nodes."""
    count = 0
    firstname = ''
    for m in option_desc_re.finditer(sig):
        prefix, optname, args = m.groups()
        if count:
            signode += addnodes.desc_addname(', ', ', ')
        signode += addnodes.desc_name(prefix+optname, prefix+optname)
        signode += addnodes.desc_addname(args, args)
        if not count:
            firstname = optname
        count += 1
    if not firstname:
        raise ValueError
    return firstname
开发者ID:lshmenor,项目名称:IMTAphy,代码行数:16,代码来源:desc.py


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


示例15: attach_name

  def attach_name(self, signode, full_name):
    """Attaches a fully qualified TypeInfo name to the node tree"""
    # Get the previous namespace
    # import pdb
    # pdb.set_trace()
    prev_namespace = self.resolve_previous_namespace()
    if prev_namespace:
      curr = full_name.fqn()
      if full_name.fqn().startswith(prev_namespace) and not full_name.fqn() == prev_namespace:
        # print "Partially filled by parent: "
        # print "Previous namespace: '{}'".format(prev_namespace)
        # print "  Cutting from " + full_name.fqn()
        new_fqn = full_name.fqn()[len(prev_namespace):]
        if new_fqn[0] == ".":
          new_fqn = new_fqn[1:]
        # print "New fqn is: " + new_fqn
        full_name = DefinitionParser.ParseNamespace(new_fqn)
        # print "            to " + full_name.fqn()

    names = full_name.flatten_namespace()

    for space in names[:-1]:
      signode += addnodes.desc_addname(space, space)
      signode += nodes.Text('.')

    signode += addnodes.desc_name(names[-1], names[-1])
开发者ID:ndevenish,项目名称:sphinxcontrib-csdomain,代码行数:26,代码来源:csdomain.py


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


示例17: handle_signature

 def handle_signature(self, sig, signode):
     '''return the name of this object from its signature'''
     # Must be able to match these (without preceding def or rdef)
     #     def macro_name
     #     def macro_name()
     #     def macro_name(arg1, arg2)
     #     rdef macro_name
     #     cdef("macro_name", "content", "groupname", flags)
     m = spec_func_sig_re.match(sig) or spec_macro_sig_re.match(sig)
     if m is None:
         raise ValueError
     arglist = m.groups()
     name = arglist[0]
     args = []
     if len(arglist) > 1:
         args = arglist[1:]
         if name == 'cdef':
             # TODO: need to match complete arg list
             # several different signatures are possible (see cdef-examples.mac)
             # for now, just get the macro name and ignore the arg list
             m = spec_cdef_name_sig_re.match(args[0])
             arglist = m.groups()
             name = arglist[0].strip('"')
             args = ['<<< cdef argument list not handled yet >>>']       # FIXME:
     signode += addnodes.desc_name(name, name)
     if len(args) > 0:
         signode += addnodes.desc_addname(args, args)
     return name
开发者ID:prjemian,项目名称:specdomain,代码行数:28,代码来源:specdomain.py


示例18: attach_name

 def attach_name(self, node, name):
     owner, name = name.split_owner()
     varname = str(name)
     if owner is not None:
         owner = str(owner) + "::"
         node += addnodes.desc_addname(owner, owner)
     node += addnodes.desc_name(varname, varname)
开发者ID:pykomke,项目名称:Kurz_Python_KE,代码行数:7,代码来源:cpp.py


示例19: handle_signature

 def handle_signature(self, sig, signode):
     """Transform an option description into RST nodes."""
     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 firstname:
         raise ValueError
     return firstname
开发者ID:qsnake,项目名称:sphinx,代码行数:16,代码来源:std.py


示例20: attach_name

 def attach_name(self, node, name):
     owner, name = name.split_owner()
     varname = unicode(name)
     if owner is not None:
         owner = unicode(owner) + '::'
         node += addnodes.desc_addname(owner, owner)
     node += addnodes.desc_name(varname, varname)
开发者ID:aras0,项目名称:porownywarka-ofert,代码行数:7,代码来源:cpp.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python addnodes.desc_annotation函数代码示例发布时间:2022-05-27
下一篇:
Python addnodes.desc函数代码示例发布时间: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