本文整理汇总了Python中sphinx.addnodes.desc_annotation函数的典型用法代码示例。如果您正苦于以下问题:Python desc_annotation函数的具体用法?Python desc_annotation怎么用?Python desc_annotation使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了desc_annotation函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: 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
示例2: 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
示例3: handle_signature
def handle_signature(self, sig, signode, display_text=None):
"""This method determines the appearance of the object.
Overloaded Args:
display_test: Used for overriding the object name.
"""
# Override sig with display_text if provided.
if display_text is None:
display_text = sig
display_text, argument, alt_forms = self.process_name(display_text)
# Add a label before the name of the object.
signode += addnodes.desc_annotation(*('%s ' % self.LABEL,) * 2)
# Add the object name.
signode += addnodes.desc_name(sig, display_text)
# Add arguments.
if argument:
argument = '%s %s' % (self.ARGUMENT_SEPARATOR, argument)
signode += addnodes.desc_annotation(argument, argument)
# Add alternate object names.
if alt_forms:
signode += addnodes.desc_annotation(
*(self.ALT_FORM_TEMPLATE % (', '.join(alt_forms)),) * 2)
signode['fullname'] = sig
return (sig, self.NAME, sig)
开发者ID:aosprey,项目名称:rose,代码行数:27,代码来源:rose_domain.py
示例4: handle_signature
def handle_signature(self, sig: str, signode: addnodes.desc) -> str:
"""Transform signature into RST nodes"""
signode += addnodes.desc_annotation(self.typename, self.typename + " ")
signode += addnodes.desc_name(sig, sig)
if 'badges' in self.options:
badges = addnodes.desc_annotation()
badges['classes'] += ['badges']
content = StringList([self.options['badges']])
self.state.nested_parse(content, 0, badges)
signode += badges
if 'replaces_section_title' in self.options:
section = self.state.parent
if isinstance(section, nodes.section):
title = section[-1]
if isinstance(title, nodes.title):
section.remove(title)
else:
signode += self.state.document.reporter.warning(
"%s:%s:: must follow section directly to replace section title"
% (self.domain, self.objtype), line = self.lineno
)
else:
signode += self.state.document.reporter.warning(
"%s:%s:: must be in section to replace section title"
% (self.domain, self.objtype), line = self.lineno
)
return sig
开发者ID:bioconda,项目名称:bioconda-utils,代码行数:31,代码来源:sphinxext.py
示例5: 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
示例6: attach_modifiers
def attach_modifiers(self, node, obj):
if obj.visibility != 'public':
node += addnodes.desc_annotation(obj.visibility,
obj.visibility)
node += nodes.Text(' ')
if obj.static:
node += addnodes.desc_annotation('static', 'static')
node += nodes.Text(' ')
开发者ID:ZoomQuiet,项目名称:python-doc-translation,代码行数:8,代码来源:cpp.py
示例7: handle_signature
def handle_signature(self, sig, signode):
a = (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('lua:module'))
self.clsname = self.options.get('class', self.env.temp_data.get('lua:class'))
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
# print "context: '%s', name: '%s'" % a[:2]
# print "module: '%s', clsname: '%s', idxtype: '%s'" % (self.module, self.clsname, self.idxtype)
# print "typename: '%s', objtype: '%s'" % (self.typename, self.objtype)
# print "needs_module: '%s', needs_class: '%s'" % (self.needs_class(), self.needs_module())
# print ""
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)
clsname = ''
if fullname.find('.') != -1 or str(self.typename) == "object":
pass
elif self.clsname and self.needs_class():
sprtr = '.' if str(self.typename) == "data" else ':'
clsname = '%s%s' % (self.clsname, sprtr)
elif self.module and self.needs_module():
clsname = '%s.' % (self.module)
if clsname:
signode += addnodes.desc_addname(clsname, clsname)
# if self.clsname and self.needs_class():
# signode += addnodes.desc_addname(clsname, clsname)
# elif str(self.typename) == "data":
# clsname = '%s:' % (self.clsname)
# signode += addnodes.desc_addname(clsname, clsname)
# elif 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:daurnimator,项目名称:tarantool,代码行数:58,代码来源:LuaDomain.py
示例8: 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
开发者ID:anurse,项目名称:sphinxcontrib-dotnetdomain,代码行数:57,代码来源:dotnetdomain.py
示例9: attach_modifiers
def attach_modifiers(self, node, obj, visibility="public"):
if obj.visibility != visibility:
node += addnodes.desc_annotation(obj.visibility, obj.visibility)
node += nodes.Text(" ")
if obj.static:
node += addnodes.desc_annotation("static", "static")
node += nodes.Text(" ")
if getattr(obj, "constexpr", False):
node += addnodes.desc_annotation("constexpr", "constexpr")
node += nodes.Text(" ")
开发者ID:pykomke,项目名称:Kurz_Python_KE,代码行数:10,代码来源:cpp.py
示例10: p_returnval_expr
def p_returnval_expr(p):
'''returnval : MINUS LPAREN expression RPAREN
| PLUS LPAREN expression RPAREN'''
p[0] = addnodes.desc_annotation(p[1], p[1])
p[0] += nodes.Text(u' ')
p[0] += addnodes.desc_annotation(p[2], p[2])
p[0] += nodes.Text(u' ')
p[0] += p[3]
p[0] += nodes.Text(u' ')
p[0] += addnodes.desc_annotation(p[4], p[4])
开发者ID:jespinoz,项目名称:jia-mini-python,代码行数:10,代码来源:objcdomain.py
示例11: attach_modifiers
def attach_modifiers(self, node, obj, visibility='public'):
if obj.visibility != visibility:
node += addnodes.desc_annotation(obj.visibility,
obj.visibility)
node += nodes.Text(' ')
if obj.static:
node += addnodes.desc_annotation('static', 'static')
node += nodes.Text(' ')
if getattr(obj, 'constexpr', False):
node += addnodes.desc_annotation('constexpr', 'constexpr')
node += nodes.Text(' ')
开发者ID:aras0,项目名称:porownywarka-ofert,代码行数:11,代码来源:cpp.py
示例12: attach_modifiers
def attach_modifiers(self, node, obj):
lname = self.__class__.langname
node += nodes.strong(lname + ":", lname + ":")
node += addnodes.desc_name(" ", " ")
if obj.visibility != 'public':
node += addnodes.desc_annotation(obj.visibility,
obj.visibility)
node += nodes.Text(' ')
if obj.static:
node += addnodes.desc_annotation('static', 'static')
node += nodes.Text(' ')
开发者ID:ethanrublee,项目名称:libopencv-debian,代码行数:11,代码来源:ocv.py
示例13: p_parameters_exp
def p_parameters_exp(p):
'''parameters : LPAREN expression RPAREN methodname
| LPAREN expression RPAREN methodname parameter'''
p[0] = addnodes.desc_annotation(p[1], p[1])
p[0] += nodes.Text(u' ')
p[0] += p[2]
p[0] += nodes.Text(u' ')
p[0] += addnodes.desc_annotation(p[3], p[3])
p[0] += p[4]
if (len(p) == 6):
p[0] += nodes.Text(u' ')
p[0] += p[5]
开发者ID:jespinoz,项目名称:jia-mini-python,代码行数:13,代码来源:objcdomain.py
示例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
"""
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
开发者ID:10173677,项目名称:jenkins-job-builder,代码行数:51,代码来源:yaml.py
示例15: 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
示例16: 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
示例17: 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
示例18: handle_signature
def handle_signature(self, signature, signode):
"""Handle the given ``signature``.
In addition to the normal signature handling of the
:class:`EmacsLispSymbol` directive, parse and annotate the function
signature of the symbol.
"""
parts = signature.split(' ')
name = parts[0]
arguments = parts[1:]
name = EmacsLispSymbol.handle_signature(self, name, signode)
paramlist = nodes.el_parameterlist(' '.join(arguments), '')
signode += paramlist
for arg in arguments:
if arg.startswith('&'):
paramlist += addnodes.desc_annotation(' ' + arg + ' ',
' ' + arg + ' ')
else:
node = nodes.el_parameter(arg, arg)
node['noemph'] = True
paramlist += node
return name
开发者ID:lunaryorn,项目名称:sphinxcontrib-emacs,代码行数:25,代码来源:desc.py
示例19: 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
示例20: describe_signature
def describe_signature(self, signode, obj):
self.attach_modifiers(signode, obj)
signode += addnodes.desc_annotation('type ', 'type ')
if obj.typename is not None:
self.attach_type(signode, obj.typename)
signode += nodes.Text(' ')
self.attach_name(signode, obj.name)
开发者ID:flyeven,项目名称:doc,代码行数:7,代码来源:matlabdomain.py
注:本文中的sphinx.addnodes.desc_annotation函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论