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


Python addnodes.desc_parameterlist函数代码示例

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


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

示例1: handle_signature

    def handle_signature(self, sig, signode):
        m = ks_sig_re.match(sig)
        name = m.group('object')

        current_struct = self.env.temp_data.get('ks:structure')
        if m.group('prefix') is None:
            if current_struct is not None:
                fullname = current_struct + ':' + name
        else:
            struct = m.group('prefix').split(':')[-1]
            fullname = struct + ':' + name

        if struct is not None:
            if struct != '':
                signode += addnodes.desc_type(struct,struct+':')

        signode += addnodes.desc_name(fullname, name)

        args = m.group('args')
        if args:
            signode += addnodes.desc_parameterlist(args,args)
        else:
            signode += addnodes.desc_parameterlist()


        return fullname
开发者ID:Blanks821,项目名称:KOS,代码行数:26,代码来源:ksdomain.py

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

示例3: handle_signature

    def handle_signature(self, sig, signode):
        m = ks_sig_re.match(sig)
        name = m.group('object')
        struct = None  #might override further down

        current_struct = self.env.temp_data.get('ks:structure')
        if m.group('prefix') is None:
            if current_struct is not None:
                struct = current_struct
                fullname = current_struct + ':' + name
            else:
                raise Exception("Method name lacks a prefix and isn't " +
                    "indented inside a structure section.  Problem " +
                    "occurred at " + self.env.docname + ", line " +
                     str(self.lineno) +
                     ".")
        else:
            struct = m.group('prefix').split(':')[-1]
            fullname = struct + ':' + name

        if struct is not None:
            if struct != '':
                signode += addnodes.desc_type(struct,struct+':')

        signode += addnodes.desc_name(fullname, name)

        args = m.group('args')
        if args:
            signode += addnodes.desc_parameterlist(args,args)
        else:
            signode += addnodes.desc_parameterlist()


        return fullname
开发者ID:KSP-KOS,项目名称:KOS,代码行数:34,代码来源:ksdomain.py

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

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

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

示例7: _handle_function_signature

    def _handle_function_signature(self, sig, signode):
        m = ada_func_sig_re.match(sig)
        if m is None:
            print "m did not match the function"
            raise ValueError

        modname, name, dummy, arglist, returntype, abstract = m.groups()
        print "DEBUG: modname %s name %s arglist %s" % (modname, name, arglist)

        fullname = self._resolve_module_name(signode, modname, name)
        print "DEBUG: fullname %s" % fullname

        if not arglist:
            if self.needs_arglist():
                # for functions and procedures, add an empty parameter list
                new_node = addnodes.desc_parameterlist()
                new_node.child_text_separator = '; '
                signode += new_node
            if returntype:
                signode += addnodes.desc_returns(returntype, returntype)
            return fullname

        signode += nodes.Text(' ')

        new_node = addnodes.desc_parameterlist()
        new_node.child_text_separator = '; '
        signode += new_node

        stack = [signode[-1]]
        counters = [0, 0]
        for token in string.split(arglist, ';'):
            pieces = string.split(token, ':')
            name = pieces[0].strip()
            stack[-1] += addnodes.desc_parameter(name, name + " : " + pieces[1].strip())

            if len(stack) == 1:
                counters[0] += 1
            else:
                counters[1] += 1

        if len(stack) != 1:
            raise ValueError
        if not counters[1]:
            fullname = '%s/%d' % (fullname, counters[0])
        else:
            fullname = '%s/%d..%d' % (fullname, counters[0], sum(counters))
        if returntype:
            signode += addnodes.desc_returns(returntype,returntype)
        return fullname
开发者ID:capnrefsmmat,项目名称:sphinx-contrib,代码行数:49,代码来源:adadomain.py

示例8: _handle_function_signature

    def _handle_function_signature(self, sig, signode):
        m = erl_func_sig_re.match(sig)
        if m is None:
            raise ValueError
        modname, name, arglist, retann = m.groups()

        fullname = self._resolve_module_name(signode, modname, 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 self.objtype == 'function':
                return fullname + '/0'
            return fullname
        signode += addnodes.desc_parameterlist()

        stack = [signode[-1]]
        counters = [0, 0]
        for token in erl_paramlist_re.split(arglist):
            if token == '[':
                opt = addnodes.desc_optional()
                stack[-1] += opt
                stack.append(opt)
            elif token == ']':
                try:
                    stack.pop()
                except IndexError:
                    raise ValueError
            elif not token or token == ',' or token.isspace():
                pass
            else:
                token = token.strip()
                stack[-1] += addnodes.desc_parameter(token, token)
                if len(stack) == 1:
                    counters[0] += 1
                else:
                    counters[1] += 1
        if len(stack) != 1:
            raise ValueError
        if not counters[1]:
            fullname = '%s/%d' % (fullname, counters[0])
        else:
            fullname = '%s/%d..%d' % (fullname, counters[0], sum(counters))
        if retann:
            signode += addnodes.desc_returns(retann, retann)
        return fullname
开发者ID:Lemma1,项目名称:MINAMI,代码行数:49,代码来源:erlangdomain.py

示例9: make_parameters

    def make_parameters(self):
        params = addnodes.desc_parameterlist('', '')
        ctor = self.item.constructor
        if ctor:
            params += make_desc_parameters(ctor.params)

        return params
开发者ID:xmo-odoo,项目名称:odoo,代码行数:7,代码来源:directives.py

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

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

示例12: handle_signature

    def handle_signature(self, sig, signode):
        cache = _APP_CACHES.get(self.env.app, {})
        key = CursorKind.MACRO_DEFINITION, (sig, )
        if key in cache:
            node, comment, start, end, _ = cache[key]
            signode += addnodes.desc_name(node.displayname, node.displayname)

            # There is unfortunately no API to get the parameters of a macro,
            # so we identify them by looking at the tokens.
            tokens = list(node.get_tokens())
            if (
                tokens[1].kind is TokenKind.PUNCTUATION and
                tokens[1].spelling == '('
            ):
                paramlist = addnodes.desc_parameterlist()
                for token in tokens[2:]:
                    if (
                        token.kind is TokenKind.PUNCTUATION and
                        token.spelling == ')'
                    ):
                        break
                    elif token.kind is TokenKind.IDENTIFIER:
                        paramlist += addnodes.desc_parameter(token.spelling, token.spelling)
                signode += paramlist

            self.content = ViewList()
            for lineno, line in enumerate(comment.splitlines(), start[0]):
                self.content.append(line, '<unknown>', lineno)
        return sig
开发者ID:DasIch,项目名称:autodoc-c,代码行数:29,代码来源:__init__.py

示例13: handle_constructor_signature

    def handle_constructor_signature(self, sig, signode):
        try:
            member = javalang.parse.parse_constructor_signature(sig)
        except javalang.parser.JavaSyntaxError:
            raise self.error("syntax error in constructor signature")

        if not isinstance(member, javalang.tree.ConstructorDeclaration):
            raise self.error("expected constructor declaration")

        mods = formatter.output_modifiers(member.modifiers).build()
        signode += nodes.Text(mods + ' ', mods + ' ')

        signode += addnodes.desc_name(member.name, member.name)

        paramlist = addnodes.desc_parameterlist()
        for parameter in member.parameters:
            param = addnodes.desc_parameter('', '', noemph=True)
            param += self._build_type_node(parameter.type)

            if parameter.varargs:
                param += nodes.Text('...', '')

            param += nodes.emphasis(' ' + parameter.name, ' ' + parameter.name)
            paramlist += param
        signode += paramlist

        param_reprs = [formatter.output_type(param.type, with_generics=False).build() for param in member.parameters]
        return '%s(%s)' % (member.name, ', '.join(param_reprs))
开发者ID:bronto,项目名称:javasphinx,代码行数:28,代码来源:domain.py

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

示例15: lua_desc_parameterlist

def lua_desc_parameterlist(argstart, argend):
    node = addnodes.desc_parameterlist()
    node.param_start = argstart
    node.param_end = argend
    if argstart == "{":
        node.param_class = "brace"
    return node
开发者ID:jd28,项目名称:sphinx-lua,代码行数:7,代码来源:lua.py


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