本文整理汇总了Python中sphinx.domains.python._pseudo_parse_arglist函数的典型用法代码示例。如果您正苦于以下问题:Python _pseudo_parse_arglist函数的具体用法?Python _pseudo_parse_arglist怎么用?Python _pseudo_parse_arglist使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了_pseudo_parse_arglist函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: 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, '')
示例2: handle_signature
def handle_signature(self, sig, signode):
sig = sig.strip()
if '(' in sig and sig[-1:] == ')':
prefix, arglist = sig.split('(', 1)
prefix = prefix.strip()
arglist = arglist[:-1].strip()
else:
prefix = sig
arglist = None
if '.' in prefix:
nameprefix, name = prefix.rsplit('.', 1)
else:
nameprefix = None
name = prefix
objectname = self.env.temp_data.get('js:object')
if nameprefix:
if objectname:
# someone documenting the method of an attribute
# of the current object? shouldn't happen but
# who knows...
nameprefix = objectname + '.' + nameprefix
fullname = nameprefix + '.' + name
elif objectname:
fullname = objectname + '.' + name
else:
# just a function or constructor
objectname = ''
fullname = name
signode['object'] = objectname
signode['fullname'] = fullname
if self.display_prefix:
signode += addnodes.desc_annotation(self.display_prefix,
self.display_prefix)
if nameprefix:
signode += addnodes.desc_addname(nameprefix + '.',
nameprefix + '.')
signode += addnodes.desc_name(name, name)
if self.has_arguments:
if not arglist:
signode += addnodes.desc_parameterlist()
else:
_pseudo_parse_arglist(signode, arglist)
class_name = self.options.get('outertype')
# object belongs to some class or namespace
if class_name:
# func_desc = function return type + function name
func_desc = fullname.split(' ', 1)
if len(func_desc) > 1:
fullname = func_desc[0] + ' ' + class_name +\
'.' + func_desc[1]
return fullname, nameprefix
示例3: parse
def parse(sig):
m = py_sig_re.match(sig)
if m is None:
raise ValueError
name_prefix, name, arglist, retann = m.groups()
signode = addnodes.desc_signature(sig, '')
_pseudo_parse_arglist(signode, arglist)
return signode.astext()
示例4: handle_signature
def handle_signature(self, sig_input, signode):
"""Parses out pieces from construct signatures
Parses out prefix and argument list from construct definition. This is
assuming that the .NET languages this will support will be in a common
format, such as::
Namespace.Class.method(argument, argument, ...)
The namespace and class will be determined by the nesting of rST
directives.
Returns
Altered :py:data:`signode` with attributes corrected for rST
nesting/etc
"""
try:
sig = self.parse_signature(sig_input.strip())
except ValueError:
self.env.warn(self.env.docname,
'Parsing signature failed: "{}"'.format(sig_input),
self.lineno)
raise
prefix = self.env.ref_context.get('dn:prefix', None)
if prefix is not None:
sig.prefix = prefix
signode['object'] = sig.member
signode['prefix'] = sig.prefix
signode['fullname'] = sig.full_name()
# Prefix modifiers
if self.display_prefix:
signode += addnodes.desc_annotation(self.display_prefix,
self.display_prefix)
for prefix in ['public', 'protected', 'static']:
if prefix in self.options:
signode += addnodes.desc_annotation(prefix + ' ',
prefix + ' ')
# Show prefix only on shorter declarations
if sig.prefix is not None and not self.has_arguments:
signode += addnodes.desc_addname(sig.prefix + '.', sig.prefix + '.')
signode += addnodes.desc_name(sig.member, sig.member)
if self.has_arguments:
if not sig.arguments:
signode += addnodes.desc_parameterlist()
else:
# TODO replace this
_pseudo_parse_arglist(signode, ', '.join(sig.arguments))
if isinstance(self, DotNetObjectNested):
return sig.full_name(), sig.full_name()
return sig.full_name(), sig.prefix
示例5: handle_signature
def handle_signature(self, sig, signode):
sig = sig.strip()
if '(' in sig and sig[-1:] == ')':
prefix, arglist = sig.split('(', 1)
prefix = prefix.strip()
arglist = arglist[:-1].strip()
else:
prefix = sig
arglist = None
if '.' in prefix:
nameprefix, name = prefix.rsplit('.', 1)
else:
nameprefix = None
name = prefix
objectname = self.env.temp_data.get('mongodb:object')
if nameprefix:
if objectname:
# someone documenting the method of an attribute of the current
# object? shouldn't happen but who knows...
nameprefix = objectname + '.' + nameprefix
fullname = nameprefix + '.' + name
elif objectname:
fullname = objectname + '.' + name
else:
# just a function or constructor
objectname = ''
fullname = name
signode['object'] = objectname
signode['fullname'] = fullname
if self.display_prefix:
signode += addnodes.desc_annotation(self.display_prefix,
self.display_prefix)
if nameprefix:
if nameprefix in conf['suppress-prefix']:
pass
else:
nameprefix += '.'
for prefix in conf['suppress-prefix']:
if nameprefix.startswith(prefix):
nameprefix = nameprefix[len(prefix)+1:]
break
signode += addnodes.desc_addname(nameprefix, nameprefix)
nameprefix[:-1]
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, nameprefix
示例6: handle_signature
def handle_signature(self, sig, signode):
if self.display_prefix:
signode += addnodes.desc_annotation(self.display_prefix, self.display_prefix)
fullname, _, args = sig.partition('(')
modname, name = fullname.split('::')
args = args[:-1]
signode += addnodes.desc_name(name, name)
if isinstance(self, CoffeeFunction):
_pseudo_parse_arglist(signode, args)
return fullname
示例7: handle_signature
def handle_signature(self, sig, signode):
"""Transform a Lasso signature into RST nodes.
"""
sig = sig.strip().replace(' ', ' ').replace(' ::', '::').replace(':: ', '::')
if '(' in sig:
if ')::' in sig:
sig, returntype = sig.rsplit('::', 1)
else:
returntype = None
prefix, arglist = sig.split('(', 1)
prefix = prefix.strip()
arglist = arglist[:-1].strip().replace(' =', '=').replace('= ', '=')
else:
if '::' in sig:
sig, returntype = sig.rsplit('::', 1)
else:
returntype = None
prefix = sig
arglist = None
if '->' in prefix:
objectprefix, name = prefix.rsplit('->', 1)
objectprefix += '->'
else:
objectprefix = None
name = prefix
objectname = self.env.ref_context.get('ls:object')
if objectprefix:
fullname = objectprefix + name
elif objectname:
fullname = objectname + '->' + name
else:
objectname = ''
fullname = name
signode['object'] = objectname
signode['fullname'] = fullname
sig_prefix = self.get_signature_prefix(sig)
if sig_prefix:
signode += addnodes.desc_annotation(sig_prefix, sig_prefix)
if objectprefix:
signode += addnodes.desc_addname(objectprefix, objectprefix)
signode += addnodes.desc_name(name, name)
if self.needs_arglist():
if arglist:
_pseudo_parse_arglist(signode, arglist)
else:
signode += addnodes.desc_parameterlist()
if returntype:
signode += addnodes.desc_returns(returntype, returntype)
return fullname, objectprefix
示例8: 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
示例9: handle_signature
def handle_signature(self, sig, signode):
"""Transform a Python signature into RST nodes.
Return (fully qualified name of the thing, classname if any).
If inside a class, the current class name is handled intelligently:
* it is stripped from the displayed name if present
* it is added to the full name (return value) if not present
"""
name_prefix = None
name = sig
arglist = None
retann = None
# determine module and class name (if applicable), as well as full name
modname = self.options.get(
'module', self.env.temp_data.get('py:module'))
classname = self.env.temp_data.get('py:class')
fullname = name
signode['module'] = modname
signode['class'] = classname
signode['fullname'] = fullname
sig_prefix = self.get_signature_prefix(sig)
if sig_prefix:
signode += addnodes.desc_annotation(sig_prefix, sig_prefix)
if name_prefix:
signode += addnodes.desc_addname(name_prefix, name_prefix)
anno = self.options.get('annotation')
signode += addnodes.desc_name(name, 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 anno:
signode += addnodes.desc_annotation(' ' + anno, ' ' + anno)
return fullname, name_prefix
_pseudo_parse_arglist(signode, arglist)
if retann:
signode += addnodes.desc_returns(retann, retann)
if anno:
signode += addnodes.desc_annotation(' ' + anno, ' ' + anno)
return fullname, name_prefix
示例10: handle_signature
def handle_signature(self, sig, signode):
if self.display_prefix:
signode += addnodes.desc_annotation(self.display_prefix, self.display_prefix)
fullname, paren, args = sig.partition('(')
modname, name = fullname.split(MOD_SEP)
classname = self.env.temp_data.get('autodoc:class')
if classname and name.startswith(classname):
name = name[len(classname):]
args = args[:-1]
signode += addnodes.desc_name(name, name)
if isinstance(self, CoffeeFunction):
_pseudo_parse_arglist(signode, args)
return fullname
示例11: handle_signature
def handle_signature(self, sig, signode):
# type: (unicode, addnodes.desc_signature) -> Tuple[unicode, unicode]
sig = sig.strip()
if '(' in sig and sig[-1:] == ')':
prefix, arglist = sig.split('(', 1)
prefix = prefix.strip()
arglist = arglist[:-1].strip()
else:
prefix = sig
arglist = None
if '.' in prefix:
nameprefix, name = prefix.rsplit('.', 1)
else:
nameprefix = None
name = prefix
objectname = self.env.ref_context.get('js:object')
if nameprefix:
if objectname:
# someone documenting the method of an attribute of the current
# object? shouldn't happen but who knows...
nameprefix = objectname + '.' + nameprefix
fullname = nameprefix + '.' + name
elif objectname:
fullname = objectname + '.' + name
else:
# just a function or constructor
objectname = ''
fullname = name
signode['object'] = objectname
signode['fullname'] = fullname
if self.display_prefix:
signode += addnodes.desc_annotation(self.display_prefix,
self.display_prefix)
if nameprefix:
signode += addnodes.desc_addname(nameprefix + '.', nameprefix + '.')
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, nameprefix
示例12: handle_signature
def handle_signature(self, sig, signode):
sig = sig.strip()
if '(' in sig and sig[-1:] == ')':
prefix, arglist = sig.split('(', 1)
prefix = prefix.strip()
arglist = arglist[:-1].strip()
else:
prefix = sig
arglist = None
if re.search(separators, prefix):
separator = re.findall(separators, prefix)[-1]
nameprefix, name = prefix.rsplit(separator, 1)
else:
separator = None
nameprefix = None
name = prefix
objectname = self.env.temp_data.get('lua:object')
if nameprefix:
if objectname:
nameprefix = objectname + '.' + nameprefix
fullname = nameprefix + separator + name
elif objectname:
fullname = objectname + '.' + name
else:
objectname = ''
fullname = name
signode['object'] = objectname
signode['fullname'] = fullname
if self.display_prefix:
signode += addnodes.desc_annotation(self.display_prefix,
self.display_prefix)
if nameprefix:
signode += addnodes.desc_addname(nameprefix + separator, nameprefix + separator)
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, nameprefix
示例13: handle_signature
def handle_signature(self, sig, signode):
sig = sig.strip()
if "(" in sig and sig[-1:] == ")":
prefix, arglist = sig.split("(", 1)
prefix = prefix.strip()
arglist = arglist[:-1].strip()
else:
prefix = sig
arglist = None
if "." in prefix:
nameprefix, name = prefix.rsplit(".", 1)
else:
nameprefix = None
name = prefix
objectname = self.env.temp_data.get("mongodb:object")
if nameprefix:
if objectname:
# someone documenting the method of an attribute of the current
# object? shouldn't happen but who knows...
nameprefix = objectname + "." + nameprefix
fullname = nameprefix + "." + name
elif objectname:
fullname = objectname + "." + name
else:
# just a function or constructor
objectname = ""
fullname = name
signode["object"] = objectname
signode["fullname"] = fullname
if self.display_prefix:
signode += addnodes.desc_annotation(self.display_prefix, self.display_prefix)
if nameprefix:
signode += addnodes.desc_addname(nameprefix + ".", nameprefix + ".")
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, nameprefix
示例14: handle_signature
def handle_signature(self, sig, signode):
"""Transform a Python signature into RST nodes.
Return (fully qualified name of the thing, classname if any).
If inside a class, the current class name is handled intelligently:
* it is stripped from the displayed name if present
* it is added to the full name (return value) if not present
"""
# determine module and class name (if applicable), as well as full name
from sphinx import addnodes
r = re.compile(r"(\w+)\s+([^\(]+)\s*\((.*)\)")
m = r.match(sig)
if m is None:
raise ValueError
method, name, arglist = m.groups()
modname = self.options.get(
'module', self.env.temp_data.get('py:module'))
add_module = True
classname = ''
fullname = "%s %s" % (method, name)
signode['module'] = modname
signode['class'] = classname
signode['fullname'] = fullname
signode += addnodes.desc_name(fullname, fullname)
if not arglist:
return fullname, ''
from sphinx.domains.python import _pseudo_parse_arglist
_pseudo_parse_arglist(signode, arglist)
return fullname, ''
示例15: handle_signature
def handle_signature(self, sig, signode):
sig = sig.strip()
prefix = sig
arglist = None
nameprefix = None
name = prefix
objectname = self.env.temp_data.get('make:object')
if nameprefix:
if objectname:
# someone documenting the method of an attribute of the current
# object? shouldn't happen but who knows...
nameprefix = objectname + '.' + nameprefix
fullname = nameprefix + '.' + name
elif objectname:
fullname = objectname + '.' + name
else:
# just a function or constructor
objectname = ''
fullname = name
signode['object'] = objectname
signode['fullname'] = fullname
if self.display_prefix:
signode += addnodes.desc_annotation(self.display_prefix,
self.display_prefix)
if nameprefix:
signode += addnodes.desc_addname(nameprefix + '.', nameprefix + '.')
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, nameprefix