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

Python addnodes.desc_parameter函数代码示例

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

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



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

示例1: _get_column_node

def _get_column_node(m):
    if m.group('name'):
        node = addnodes.desc_parameter()

        if m.group('key'):
            node += nodes.Text("#", "#")

        key = nodes.strong(m.group('name'), m.group('name'))
        key['classes'].append('arg-key')
        node += key

        if m.group('type'):
            node += nodes.Text(" : ", " : ")
            value = nodes.inline(m.group('type'), m.group('type'))
            value['classes'].append('arg-value')  # FIXME: should vbe arg type probably
            node += value

        if m.group('optional'):
            node += nodes.Text("? ", "?")  # FIXME: find a better type

        if m.group('reference'):
            value = nodes.inline(m.group('reference'), m.group('reference'))
            value['classes'].append('arg-value')  # FIXME: should vbe arg type probably
            node += value

        return node

    else:
        return addnodes.desc_parameter(m.group(0), m.group(0))
开发者ID:ScribesZone,项目名称:ScribesInfra,代码行数:29,代码来源:sqldomain.py


示例2: render_atom

        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))
开发者ID:millejoh,项目名称:emacs-ipython-notebook,代码行数:7,代码来源:eldomain.py


示例3: _get_param_node

def _get_param_node(m,optional):
    if m.group('flag'):
        node = addnodes.desc_parameter()
        flag = nodes.strong(m.group('flag'), m.group('flag'))
        if optional:
            flag['classes'].append('arg-flag-optional')
        else:
            flag['classes'].append('arg-flag')
        node += flag
        return flag
        
    else:
        return addnodes.desc_parameter(m.group(0), m.group(0))
开发者ID:tak2004,项目名称:RadonCMakeFramework,代码行数:13,代码来源:cmakedomain.py


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


示例5: handle_signature

    def handle_signature(self, sig, signode):
        m = sig_pattern.match(sig)
        if m is None:
            raise ValueError()
        return_type, method_name, arglist = m.groups()

        arguments = []
        if arglist:
            for arg in arglist.split(","):
                m = arg_pattern.match(arg)
                if m is None:
                    raise ValueError()
                arguments.append(m.groups())

        class_name = self.env.temp_data.get("java:class")
        if not class_name:
            self.env.warn(
                self.env.docname, "Java method description of %s outside of class is not supported" % sig, self.lineno
            )
            raise ValueError()

        if return_type is not None:  # will be absent for constructors
            self._parse_type(return_type, signode)
        signode += nodes.Text(" ", " ")
        signode += addnodes.desc_name(method_name, method_name)
        signode += addnodes.desc_parameterlist()
        for type, name in arguments:
            signode[-1] += addnodes.desc_parameter("", "", noemph=True)
            self._parse_type(type, signode[-1][-1])
            signode[-1][-1] += nodes.Text(" ", " ")
            signode[-1][-1] += nodes.emphasis(name, name)

        return "%s#%s(%s)" % (class_name, method_name, ", ".join(type for type, name in arguments))
开发者ID:rogerbinns,项目名称:jia-mini-python,代码行数:33,代码来源:javadomain.py


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


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


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


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


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


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


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


示例13: _pseudo_parse_arglist

def _pseudo_parse_arglist(signode, arglist):
    # type: (addnodes.desc_signature, str) -> None
    """"Parse" a list of arguments separated by commas.

    Arguments can have "optional" annotations given by enclosing them in
    brackets.  Currently, this will split at any comma, even if it's inside a
    string literal (e.g. default argument value).
    """
    paramlist = addnodes.desc_parameterlist()
    stack = [paramlist]  # type: List[nodes.Element]
    try:
        for argument in arglist.split(','):
            argument = argument.strip()
            ends_open = ends_close = 0
            while argument.startswith('['):
                stack.append(addnodes.desc_optional())
                stack[-2] += stack[-1]
                argument = argument[1:].strip()
            while argument.startswith(']'):
                stack.pop()
                argument = argument[1:].strip()
            while argument.endswith(']') and not argument.endswith('[]'):
                ends_close += 1
                argument = argument[:-1].strip()
            while argument.endswith('['):
                ends_open += 1
                argument = argument[:-1].strip()
            if argument:
                stack[-1] += addnodes.desc_parameter(argument, argument)
            while ends_open:
                stack.append(addnodes.desc_optional())
                stack[-2] += stack[-1]
                ends_open -= 1
            while ends_close:
                stack.pop()
                ends_close -= 1
        if len(stack) != 1:
            raise IndexError
    except IndexError:
        # if there are too few or too many elements on the stack, just give up
        # and treat the whole argument list as one argument, discarding the
        # already partially populated paramlist node
        paramlist = addnodes.desc_parameterlist()
        paramlist += addnodes.desc_parameter(arglist, arglist)
        signode += paramlist
    else:
        signode += paramlist
开发者ID:lmregus,项目名称:Portfolio,代码行数:47,代码来源:python.py


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


示例15: make_desc_parameters

def make_desc_parameters(params):
    for p in params:
        if '.' in p.name:
            continue

        node = addnodes.desc_parameter(p.name, p.name)
        if p.optional:
            node = addnodes.desc_optional('', '', node)
        yield node
开发者ID:xmo-odoo,项目名称:odoo,代码行数:9,代码来源:directives.py


示例16: parse_arglist

 def parse_arglist(self, signode, arglist):
     """parses argument lists
     
     largely imported from sphinx.domains.python,
     changes are mainly to make it work with space-separated
     argument lists and to make it look so"""
     paramlist = self._fix_paramlist(addnodes.desc_parameterlist())
     stack = [paramlist]
     try:
         for argument in arglist.split(" "):
             argument = argument.strip()
             ends_open = ends_close = 0
             while argument.startswith("["):
                 stack.append(self._fix_paramlist(addnodes.desc_optional(), False))
                 stack[-2] += stack[-1]
                 argument = argument[1:].strip()
             while argument.startswith("]"):
                 stack.pop()
                 argument = argument[1:].strip()
             while argument.endswith("]"):
                 ends_close += 1
                 argument = argument[:-1].strip()
             while argument.endswith("["):
                 ends_open += 1
                 argument = argument[:-1].strip()
             if argument:
                 stack[-1] += addnodes.desc_parameter(argument, argument)
             while ends_open:
                 stack.append(self._fix_paramlist(addnodes.desc_optional(), False))
                 stack[-2] += stack[-1]
                 ends_open -= 1
             while ends_close:
                 stack.pop()
                 ends_close -= 1
         if len(stack) != 1:
             raise IndexError
     except IndexError:
         # if there are too few or too many elements on the stack, just give up
         # and treat the whole argument list as one argument, discarding the
         # already partially populated paramlist node
         signode += self._fix_paramlist(addnodes.desc_parameterlist())
         signode[-1] += addnodes.desc_parameter(arglist, arglist)
     else:
         signode += paramlist
开发者ID:unknownnf,项目名称:pypickbot,代码行数:44,代码来源:domain.py


示例17: parse_opcode_signature

def parse_opcode_signature(signode, sig):
    """Transform an opcode signature into RST nodes."""
    m = opcode_sig_re.match(sig)
    if m is None: raise ValueError
    opname, arglist = m.groups()
    signode += addnodes.desc_name(opname, opname)
    paramlist = addnodes.desc_parameterlist()
    signode += paramlist
    paramlist += addnodes.desc_parameter(arglist, arglist)
    return opname.strip()
开发者ID:lshmenor,项目名称:IMTAphy,代码行数:10,代码来源:directives.py


示例18: parse_macro_arguments

def parse_macro_arguments(signode, args):
	plist = DescRPCArgumentList()
	args = args.split(',')
	for pos, arg in enumerate(args):
		arg = arg.strip()
		if pos < len(args) - 1:
			arg += ','
		x = DescRPCArgument()
		x += addnodes.desc_parameter(arg, arg)
		plist += x
	signode += plist
开发者ID:garyhak2009,项目名称:king-phisher,代码行数:11,代码来源:rpc_docs.py


示例19: _parse_parameter_list

def _parse_parameter_list(params):
    """Parse a SpeedCrunch parameter list into nodes."""
    paramlist = sc_parameterlist()
    stack = deque([paramlist])
    for param in params.split(';'):
        param = param.strip()
        if param and param[-1] in '[]':
            p = param[:-1].strip()
            stack[-1] += addnodes.desc_parameter(p, p)
        else:
            stack[-1] += addnodes.desc_parameter(param, param)

        if param.endswith('['):
            node = addnodes.desc_optional()
            stack[-1] += node
            stack.append(node)
        elif param.endswith(']'):
            stack.pop()

    return paramlist
开发者ID:Tey,项目名称:speedcrunch-nightlies,代码行数:20,代码来源:speedcrunch_domain.py


示例20: append_parameters

 def append_parameters(self, node, params):
     pnodes = addnodes.desc_parameterlist()
     for param in params:
         pnode = addnodes.desc_parameter('', '', noemph=True)
         self.append_type(pnode, param.type)
         pnode += nodes.Text(u' ')
         pnode += nodes.emphasis(param.name, param.name)
         if param.default is not None:
             default = u' = ' + param.default
             pnode += nodes.emphasis(default, default)
         pnodes += pnode
     node += pnodes
开发者ID:djungelorm,项目名称:sphinx-csharp,代码行数:12,代码来源:csharp.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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