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


Python addnodes.desc_addname函数代码示例

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


在下文中一共展示了desc_addname函数的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: 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


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