本文整理汇总了Python中sphinx.addnodes.desc_type函数的典型用法代码示例。如果您正苦于以下问题:Python desc_type函数的具体用法?Python desc_type怎么用?Python desc_type使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了desc_type函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: foobar
def foobar(argument, is_last, param):
parts = argument.replace('[]', '()').split(' ')
if len(parts) != 4:
raise ValueError("Argument '{0}' has unexpected format".format(argument))
param += addnodes.desc_type(parts[0] + ' ', parts[0] + ' ')
param += nodes.emphasis(parts[1] + ' ', parts[1] + ' ')
param += addnodes.desc_type(' '.join(parts[2:]), ' '.join(parts[2:]))
if not is_last:
param += nodes.emphasis(', ', ', ')
开发者ID:flyeven,项目名称:doc,代码行数:12,代码来源:vbnetdomain.py
示例2: foobar
def foobar(argument, is_last, param):
parts = argument.split(':')
name = parts[0].split(' ')
if len(name) > 1:
param += addnodes.desc_type(name[0] + ' ', name[0] + ' ')
param += nodes.emphasis(' '.join(name[1:]) + ': ', ' '.join(name[1:]) + ': ')
else:
param += nodes.emphasis(name[0] + ': ', name[0] + ': ')
param += addnodes.desc_type(parts[-1], parts[-1])
if not is_last:
param += nodes.emphasis('; ', '; ')
开发者ID:flyeven,项目名称:doc,代码行数:14,代码来源:delphidomain.py
示例3: _make_index_section
def _make_index_section(self, obj, title, id):
section = self._make_section(title)
subobjs = obj.filter_by_id(id)
kwargs = {
'refdomain': 'cpp',
'refexplicit': False,
}
if subobjs:
lst = addnodes.desc()
lst['objtype'] = 'function function-index'
for obj in subobjs:
desc = addnodes.desc_signature()
span = nodes.inline()
try:
kwargs['reftype'] = 'func'
if obj.rv is not None:
span += addnodes.desc_type(text=str(obj.rv))
except AttributeError:
kwargs['reftype'] = 'member'
span += addnodes.desc_type(text=str(obj.typename))
desc += span
desc += nodes.Text(u' ')
name = unicode(obj.name)
kwargs['reftarget'] = unicode(obj.get_name())
name = name.split('::')[-1]
desc_name = addnodes.desc_name()
refnode = addnodes.pending_xref('', **kwargs)
innernode = nodes.literal(text=name)
innernode.attributes['classes'].extend(['xref', 'cpp', 'cpp-func'])
refnode += innernode
desc_name += refnode
desc += desc_name
try:
paramlist = addnodes.desc_parameterlist()
for param_obj in obj.signature:
param = addnodes.desc_parameter('', '', noemph=True)
if param_obj.type is not None:
param += nodes.Text(str(param_obj.type) + ' ')
param += nodes.emphasis(text=str(param_obj.name))
paramlist += param
desc += paramlist
if obj.const:
desc += nodes.Text(u' const')
except AttributeError:
pass
lst += desc
section += lst
return section
return None
开发者ID:aldebaran,项目名称:doc-tools,代码行数:49,代码来源:__init__.py
示例4: 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
示例5: handle_field_signature
def handle_field_signature(self, sig, signode):
try:
member = javalang.parse.parse_member_signature(sig)
except javalang.parser.JavaSyntaxError:
raise self.error("syntax error in field signature")
if not isinstance(member, javalang.tree.FieldDeclaration):
raise self.error("expected field declaration")
mods = formatter.output_modifiers(member.modifiers).build()
signode += nodes.Text(mods + ' ', mods + ' ')
tnode = addnodes.desc_type('', '')
tnode += self._build_type_node(member.type)
signode += tnode
signode += nodes.Text(' ', ' ')
if len(member.declarators) > 1:
self.error('only one field may be documented at a time')
declarator = member.declarators[0]
signode += addnodes.desc_name(declarator.name, declarator.name)
dim = '[]' * len(declarator.dimensions)
signode += nodes.Text(dim)
if declarator.initializer and isinstance(declarator.initializer, javalang.tree.Literal):
signode += nodes.Text(' = ' + declarator.initializer.value)
return declarator.name
开发者ID:bronto,项目名称:javasphinx,代码行数:31,代码来源:domain.py
示例6: render
def render(self):
title = self.title()
rettype, name, arglist, const, signature = self.directive.parse_title(title)
fullname = self.directive.get_full_name(name)
if self.data_object.kind == "function":
# set True that this might be a structure method
self.directive.sphinx_directive.typemethod_set = True
target = self.directive.create_target(fullname)
if self.data_object.kind == "function":
self.directive.sphinx_directive.typemethod_set = False
# add a signature node
signode = addnodes.desc_signature(signature, '')
signode['first'] = False
signode += addnodes.desc_type('', '')
self.directive.add_return_type(signode[-1] , rettype)
name = self.directive.add_sig_name(signode, name)
self.directive.add_sig_args(signode, arglist, const)
description_nodes = self.description()
content_node = addnodes.desc_content('')
content_node += description_nodes
target.extend(signode)
term = self.node_factory.term("","", ids=[name], *target )
entry = self.node_factory.definition_list_item("",term, content_node)
return [entry]
开发者ID:Cyofanni,项目名称:speect,代码行数:34,代码来源:compound.py
示例7: 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
示例8: _handle_object_signature
def _handle_object_signature(self, sig, signode, m):
"Transform a Nim object into RST nodes."
name = m.groups()[0]
signode += addnodes.desc_type('object', 'object')
signode += addnodes.desc_name(name, name)
return name
开发者ID:mindriot101,项目名称:nimcfitsio,代码行数:7,代码来源:nim-domain.py
示例9: _pseudo_parse_arglist
def _pseudo_parse_arglist(signode, arglist):
paramlist = desc_parameterlist()
param = addnodes.desc_type()
def foobar(argument, is_last, param):
parts = argument.split(':')
name = parts[0].split(' ')
if len(name) > 1:
param += addnodes.desc_type(name[0] + ' ', name[0] + ' ')
param += nodes.emphasis(' '.join(name[1:]) + ': ', ' '.join(name[1:]) + ': ')
else:
param += nodes.emphasis(name[0] + ': ', name[0] + ': ')
param += addnodes.desc_type(parts[-1], parts[-1])
if not is_last:
param += nodes.emphasis('; ', '; ')
arguments = arglist.split(';')
for argument in arguments[:-1]:
foobar(argument.strip(), False, param)
foobar(arguments[-1].strip(), True, param)
paramlist += param
signode += paramlist
开发者ID:flyeven,项目名称:doc,代码行数:26,代码来源:delphidomain.py
示例10: handle_signature
def handle_signature(self, sig, signode):
try:
tag, name = sig.split()
except ValueError:
tag, name = None, sig
cache = _APP_CACHES.get(self.env.app, {})
key = {'struct': CursorKind.STRUCT_DECL}[tag], (name, )
if key in cache:
node, comment, start, end, members = cache[key]
signode += addnodes.desc_type(tag, tag + ' ')
signode += addnodes.desc_name(node.spelling, node.spelling)
self.content = ViewList()
for line in comment.splitlines():
self.content.append(line, '<unknown>')
self.content.append('', '<unknown>')
for (_, member_name), value in members.items():
member_node, member_comment, _, _, _ = value
self.content.append(
'.. c:member:: %s %s' % (member_node.type.spelling, member_node.spelling),
'<unknown>'
)
self.content.append('', '<unknown>')
for line in member_comment.splitlines():
self.content.append(' ' + line, '<unknown>')
self.content.append('', '<unknown>')
return sig
开发者ID:DasIch,项目名称:autodoc-c,代码行数:31,代码来源:__init__.py
示例11: 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
示例12: render
def render(self):
title = self.title()
rettype, name, arglist, const, signature = self.directive.parse_title(title)
target = self.directive.create_target(name)
# add a signature node
signode = addnodes.desc_signature(signature, '')
signode['first'] = False
signode += addnodes.desc_type('', '')
self.directive.add_return_type(signode[-1] , rettype)
name = self.directive.add_sig_name(signode, name)
self.directive.set_name(name)
self.directive.add_sig_args(signode, arglist, const)
self.directive.before_content()
description_nodes = self.description()
content_node = addnodes.desc_content('')
content_node += description_nodes
self.directive.after_content()
target.extend(signode)
term = self.node_factory.term("","", ids=[name], *target )
entry = self.node_factory.definition_list_item("",term, content_node)
return [entry]
开发者ID:Cyofanni,项目名称:speect,代码行数:30,代码来源:index.py
示例13: 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
示例14: _handle_enum_signature
def _handle_enum_signature(self, sig, signode, m):
"Transform a Nim enum into RST nodes."
name, values = m.groups()
signode += addnodes.desc_type('enum', 'enum')
signode += addnodes.desc_name(name, name)
signode += addnodes.desc_addname(values, '= ' + values)
return name
开发者ID:mindriot101,项目名称:nimcfitsio,代码行数:8,代码来源:nim-domain.py
示例15: p_expression_word
def p_expression_word(p):
'''expression : WORD
| WORD STAR
| WORD STAR STAR
| WORD LT WORD GT
| ENUM WORD
| VOID '''
p[0] = addnodes.desc_type(" ".join(p[1:]), " ".join(p[1:]))
开发者ID:jespinoz,项目名称:jia-mini-python,代码行数:8,代码来源:objcdomain.py
示例16: _make_typedef_documentation
def _make_typedef_documentation(self, obj):
kwargs = {
'refdomain': 'cpp',
'refexplicit': False,
}
content = addnodes.desc_signature()
content['ids'].append(obj.get_id())
content.attributes['first'] = True
span = nodes.inline()
span += nodes.emphasis(text = u'typedef ')
if obj._ref is None or obj._ref is '' or self._get_obj_by_refid(obj._ref) is None:
span += addnodes.desc_type(text = obj._type)
else:
ref = self._get_obj_by_refid(obj._ref)
kwargs['reftarget'] = unicode(ref.get_name())
kwargs['reftype'] = qiapidoc.data.types.get_obj_type(ref)
refname = addnodes.desc_name()
refnode = addnodes.pending_xref('', **kwargs)
innernode = nodes.literal(text = unicode(ref.name))
innernode.attributes['classes'].extend(['xref', 'cpp', 'cpp-func'])
refnode += innernode
refname += refnode
span += refname
content += span
if obj._args is '':
content += nodes.Text(u' ')
span = nodes.inline()
span += addnodes.desc_type(text = obj.rawname)
content += span
if obj._args is not '':
content += nodes.inline() + addnodes.desc_type(text = obj._args)
span = nodes.inline()
span += nodes.Text(obj._desc)
return content, span
开发者ID:aldebaran,项目名称:doc-tools,代码行数:42,代码来源:__init__.py
示例17: _parse_type
def _parse_type(self, type_name, node):
if type_name.endswith("..."):
type_name = type_name[:-3]
if type_name in primitives:
node += addnodes.desc_type(type_name, type_name)
else:
m = fq_classname_pattern.match(type_name)
if m is not None:
package, classname, generics = m.groups()
else:
package, classname, generics = None, fqname, None
if package is not None:
target = package + classname
else:
target = classname
xref_text = nodes.inline()
if package is not None and self.env.config.java_show_package:
xref_text += nodes.Text(package, package)
xref_text += addnodes.desc_type(classname, classname)
if generics is not None:
xref_text += nodes.Text(generics, generics)
node += addnodes.pending_xref(type_name, xref_text, refdomain="java", reftype="class", reftarget=target)
开发者ID:rogerbinns,项目名称:jia-mini-python,代码行数:22,代码来源:javadomain.py
示例18: handle_signature
def handle_signature(self, sig, signode):
name = sig.strip()
fullname = name
content = '\n'.join(self.content)
method = _http_method_re.search(content)
path = _http_path_re.search(content)
if method and path:
prefix = method.group(1)
signode += addnodes.desc_type(prefix + ' ', prefix + ' ')
signode += api_url_rule(path.group(1))
return fullname
开发者ID:SLusenti,项目名称:origin,代码行数:14,代码来源:sentryext.py
示例19: 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
示例20: make_signature
def make_signature(self):
cls = self.item.cls
ret = super(InstanceDocumenter, self).make_signature()
if cls:
super_ref = addnodes.pending_xref(
cls.name, nodes.Text(cls.name, cls.name),
refdomain='js', reftype='class', reftarget=cls.name
)
super_ref['js:module'] = cls['sourcemodule'].name
ret.append(addnodes.desc_annotation(' instance of ', ' instance of '))
ret.append(addnodes.desc_type(cls.name, '', super_ref))
if not ret:
return [addnodes.desc_name('???', '???')]
return ret
开发者ID:xmo-odoo,项目名称:odoo,代码行数:14,代码来源:directives.py
注:本文中的sphinx.addnodes.desc_type函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论