本文整理汇总了Python中sphinx.addnodes.desc函数的典型用法代码示例。如果您正苦于以下问题:Python desc函数的具体用法?Python desc怎么用?Python desc使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了desc函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: run
def run(self):
self.desctype = self.name
self.env = self.state.document.settings.env
self.indexnode = addnodes.index(entries=[])
node = addnodes.desc()
node.document = self.state.document
node['desctype'] = self.desctype
node['noindex'] = noindex = ('noindex' in self.options)
self.names = []
signatures = self.get_signatures()
for i, sig in enumerate(signatures):
# add a signature node for each signature in the current unit
# and add a reference target for it
signode = addnodes.desc_signature(sig, '')
signode['first'] = False
node.append(signode)
try:
# name can also be a tuple, e.g. (classname, objname)
name = self.parse_signature(sig, signode)
except ValueError, err:
# signature parsing failed
signode.clear()
signode += addnodes.desc_name(sig, sig)
continue # we don't want an index entry here
if not noindex and name not in self.names:
# only add target and index entry if this is the first
# description of the object with this name in this desc block
self.names.append(name)
self.add_target_and_index(name, sig, signode)
开发者ID:89sos98,项目名称:main,代码行数:31,代码来源:desc.py
示例2: 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
示例3: 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
示例4: getGroupTree
def getGroupTree(Group, prefix):
return [
nodes.target('', '', ids=[prefix]),
desc(prefix,
getSignature(Group.Config),
getMemberContent(Group, *getChildren(Group, prefix)),
id=prefix, objtype='Group'
)
]
开发者ID:Laufire,项目名称:eccontrib-sphinxdoc,代码行数:9,代码来源:sphinxdoc.py
示例5: run
def run(self):
populated = CPPAutoDocObject._populate(self)
indexnode = addnodes.index(entries=[])
main_node = addnodes.desc()
main_node['objtype'] = 'type'
if populated:
obj = self._get_obj()
main_node += self._make_typedef_documentation(obj)
return [indexnode, main_node]
开发者ID:aldebaran,项目名称:doc-tools,代码行数:9,代码来源:__init__.py
示例6: run
def run(self):
self.env = env = self.state.document.settings.env
# normalize whitespace in fullname like XRefRole does
fullname = ws_re.sub(' ', self.arguments[0].strip())
targetname = '%s-%s' % (self.ref_type, fullname)
# keep the target; this may be used to generate a BBIndex later
targets = env.domaindata['bb']['targets'].setdefault(self.ref_type, {})
targets[fullname] = env.docname, targetname
# make up the descriptor: a target and potentially an index descriptor
node = nodes.target('', '', ids=[targetname])
ret = [node]
# add the target to the document
self.state.document.note_explicit_target(node)
# append the index node if necessary
entries = []
for tpl in self.indextemplates:
colon = tpl.find(':')
if colon != -1:
indextype = tpl[:colon].strip()
indexentry = tpl[colon + 1:].strip() % (fullname,)
else:
indextype = 'single'
indexentry = tpl % (fullname,)
entries.append(
(indextype, indexentry, targetname, targetname, None))
if entries:
inode = addnodes.index(entries=entries)
ret.insert(0, inode)
# if the node has content, set up a signature and parse the content
if self.has_content:
descnode = addnodes.desc()
descnode['domain'] = 'bb'
descnode['objtype'] = self.ref_type
descnode['noindex'] = True
signode = addnodes.desc_signature(fullname, '')
if self.name_annotation:
annotation = "%s " % self.name_annotation
signode += addnodes.desc_annotation(annotation, annotation)
signode += addnodes.desc_name(fullname, fullname)
descnode += signode
contentnode = addnodes.desc_content()
self.state.nested_parse(self.content, 0, contentnode)
DocFieldTransformer(self).transform_all(contentnode)
descnode += contentnode
ret.append(descnode)
return ret
开发者ID:Cray,项目名称:buildbot,代码行数:56,代码来源:ext.py
示例7: run
def run(self):
"""Same as :meth:`sphinx.directives.ObjectDescription`
but using :class:`FortranDocFieldTransformer`"""
if ':' in self.name:
self.domain, self.objtype = self.name.split(':', 1)
else:
self.domain, self.objtype = '', self.name
self.env = self.state.document.settings.env
self.indexnode = addnodes.index(entries=[])
node = addnodes.desc()
node.document = self.state.document
node['domain'] = self.domain
# 'desctype' is a backwards compatible attribute
node['objtype'] = node['desctype'] = self.objtype
node['noindex'] = noindex = ('noindex' in self.options)
self.names = []
signatures = self.get_signatures()
for i, sig in enumerate(signatures):
# add a signature node for each signature in the current unit
# and add a reference target for it
signode = addnodes.desc_signature(sig, '')
signode['first'] = False
node.append(signode)
try:
# name can also be a tuple, e.g. (classname, objname);
# this is strictly domain-specific (i.e. no assumptions may
# be made in this base class)
name = self.handle_signature(sig, signode)
except ValueError:
# signature parsing failed
signode.clear()
signode += addnodes.desc_name(sig, sig)
continue # we don't want an index entry here
if not isinstance(name[0], unicode):
name = (unicode(name), name[1])
if not noindex and name not in self.names:
# only add target and index entry if this is the first
# description of the object with this name in this desc block
self.names.append(name)
self.add_target_and_index(name, sig, signode)
modname = signode.get('module')
typename = signode.get('type')
contentnode = addnodes.desc_content()
node.append(contentnode)
if self.names:
# needed for association of version{added,changed} directives
self.env.temp_data['object'] = self.names[0]
self.before_content()
self.state.nested_parse(self.content, self.content_offset, contentnode)
FortranDocFieldTransformer(self, modname=modname, typename=typename).transform_all(contentnode)
self.env.temp_data['object'] = None
self.after_content()
return [self.indexnode, node]
开发者ID:leloulight,项目名称:magic,代码行数:56,代码来源:fortran_domain.py
示例8: getArgsContent
def getArgsContent(Args):
Container = desc('', desc_signature(text='Args'), objtype="Args")
for name, Arg in Args.items():
Content = desc_content()
Content.append(desc_name(text='%s: ' % name))
Content.append(compact_paragraph(text=getArgDesc(Arg)))
Container.append(Content)
return Container
开发者ID:Laufire,项目名称:eccontrib-sphinxdoc,代码行数:10,代码来源:sphinxdoc.py
示例9: run
def run(self):
if ':' in self.name:
self.domain, self.objtype = self.name.split(':', 1)
else:
self.domain, self.objtype = '', self.name
self.env = self.state.document.settings.env
self.indexnode = addnodes.index(entries=[])
obj = self.make_obj()
node = addnodes.desc()
node.document = self.state.document
node['domain'] = self.domain
# 'desctype' is a backwards compatible attribute
node['objtype'] = node['desctype'] = self.objtype
node['noindex'] = noindex = ('noindex' in self.options)
node.name = obj.name
obj.docname = self.env.docname
objects = self.env.domaindata['envy']['objects']
signode = addnodes.desc_signature('', '')
signode['first'] = True
node.append(signode)
self.make_signature(obj, signode)
if not noindex and self.name not in objects:
# only add target and index entry if this is the first
# description of the object with this name in this desc block
#self.add_target_and_index(self.name, sig, signode)
nid = obj.iname + '-' + self.name
signode['names'].append(nid)
signode['ids'].append(nid)
self.state.document.note_explicit_target(signode)
for loc in self.locs:
signode = addnodes.desc_signature('', '')
signode['first'] = False
node.append(signode)
signode += addnodes.desc_name(loc, loc)
node.append(uplink_placeholder(self.name))
if self.name in objects:
other = objects[self.name]
self.state_machine.reporter.warning('duplicate object {}, other instance in {}'.format(self.name, self.env.doc2path(other.docname)))
objects[self.name] = obj
contentnode = addnodes.desc_content()
node.append(contentnode)
self.env.temp_data['object'] = self.name
self.state.nested_parse(self.content, self.content_offset, contentnode)
self.env.temp_data['object'] = None
contentnode += self.after_content()
return [self.indexnode, node]
开发者ID:AlexAltea,项目名称:envytools,代码行数:53,代码来源:envy.py
示例10: _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
示例11: getTaskTree
def getTaskTree(Task, id):
Config = Task.Config
Elms = [nodes.target('', '', ids=[id])]
content = getMemberContent(Task)
signature = getSignature(Config)
signature.append(getArgList(Task.Args))
if Task.Args:
content.append(getArgsContent(Task.Args))
Elms.append(desc(id, signature, content, id=id, objtype='Task'))
return Elms
开发者ID:Laufire,项目名称:eccontrib-sphinxdoc,代码行数:15,代码来源:sphinxdoc.py
示例12: _make_enums_documentation
def _make_enums_documentation(self, obj):
first = True
if obj.enums:
section = self._make_section('Enumerations')
lst = addnodes.desc()
section += lst
lst['objtype'] = 'type'
for obj_ in obj.enums:
obj_.docname = obj.docname
(desc, content) = _make_enum_documentation(self, obj_)
desc.attributes['first'] = first
lst += desc
lst += content
return section
return None
开发者ID:aldebaran,项目名称:doc-tools,代码行数:15,代码来源:__init__.py
示例13: check
def check(name, input, idDict, output=None):
# first a simple check of the AST
if output is None:
output = input
ast = parse(name, input)
res = text_type(ast)
if res != output:
print("")
print("Input: ", text_type(input))
print("Result: ", res)
print("Expected: ", output)
raise DefinitionError("")
rootSymbol = Symbol(None, None, None, None, None, None)
symbol = rootSymbol.add_declaration(ast, docname="TestDoc")
parentNode = addnodes.desc()
signode = addnodes.desc_signature(input, '')
parentNode += signode
ast.describe_signature(signode, 'lastIsName', symbol, options={})
idExpected = [None]
for i in range(1, _max_id + 1):
if i in idDict:
idExpected.append(idDict[i])
else:
idExpected.append(idExpected[i - 1])
idActual = [None]
for i in range(1, _max_id + 1):
try:
id = ast.get_id(version=i)
assert id is not None
idActual.append(id[len(_id_prefix[i]):])
except NoOldIdError:
idActual.append(None)
res = [True]
for i in range(1, _max_id + 1):
res.append(idExpected[i] == idActual[i])
if not all(res):
print("input: %s" % text_type(input).rjust(20))
for i in range(1, _max_id + 1):
if res[i]:
continue
print("Error in id version %d." % i)
print("result: %s" % str(idActual[i]))
print("expected: %s" % str(idExpected[i]))
print(rootSymbol.dump(0))
raise DefinitionError("")
开发者ID:mgeier,项目名称:sphinx,代码行数:48,代码来源:test_domain_cpp.py
示例14: run
def run(self):
if ':' in self.name:
self.domain, self.objtype = self.name.split(':', 1)
else:
self.domain, self.objtype = '', self.name
self.env = self.state.document.settings.env
obj_name, = self.arguments
for obj in self.gen_type.instances:
if obj.name == obj_name:
break
else:
raise ValueError('unknown instance {}'.format(obj_name))
node = addnodes.desc()
node.document = self.state.document
node['domain'] = self.domain
node['objtype'] = node['desctype'] = self.objtype
node['noindex'] = False
node.name = obj.slug
pobj = GenObjPlaceholder(self.env.docname, obj.brief)
genobjs = self.env.domaindata['envy']['genobjs']
signode = addnodes.desc_signature('', '')
signode['first'] = True
node.append(signode)
self.make_signature(obj, signode)
signode['names'].append(obj.name)
signode['ids'].append(obj.slug)
self.state.document.note_explicit_target(signode)
if obj.slug in genobjs:
other = genobjs[obj.slug]
self.state_machine.reporter.warning('duplicate object {}, other instance in {}'.format(obj.slug, self.env.doc2path(other.docname)))
genobjs[obj.slug] = pobj
contentnode = addnodes.desc_content()
node.append(contentnode)
vl = ViewList()
doc = prepare_docstring(obj.doc or '')
for line in doc:
vl.append(line, obj_name)
self.state.nested_parse(vl, 0, contentnode)
return [
node
]
开发者ID:envytools,项目名称:envytools,代码行数:48,代码来源:envy.py
示例15: _make_all_typedefs_documentation
def _make_all_typedefs_documentation(self, obj):
section = None
if obj.typedefs:
first = True
section = self._make_section('Types')
lst = addnodes.desc()
section += lst
lst['objtype'] = 'type'
for tpd in obj.typedefs:
tpd.docname = obj.docname
(node, desc) = self._make_typedef_documentation(self._get_obj(tpd.name))
node.attributes['first'] = first
first = False
lst += node
lst += desc
return section
开发者ID:aldebaran,项目名称:doc-tools,代码行数:16,代码来源:__init__.py
示例16: document
def document(self):
eid = (self.tag, self.fqname)
if eid in self.documented:
return [build_paragraph(get_xref(self.tag, eid[1]))]
else:
self.documented.append(eid)
rv = [self.target_node(self.tag, self.ns_name, self.name)]
data = addnodes.desc(objtype=self.tag)
targetid = get_target_id(self.tag, self.ns_name, self.name)
header = addnodes.desc_signature('', '',
first=True,
ids=[targetid])
if self.include['doc']:
header.extend([nodes.emphasis(self.tag, self.tag),
text(" "), self.tname])
data.append(header)
contents = nodes.definition()
if self.include['doc']:
contents.append(self.get_doc(self.entity))
contents.extend(getattr(self, "document_%s" % self.tag)())
data.append(contents)
rv.append(data)
if self.parent is None:
# avoid adding duplicate dependencies
added = [(self.type, self.name)]
for typ, name, entity in self.dependencies:
if not name:
name = entity.get('name')
if (typ, name) in added:
continue
ns_name, name = self.split_ns(name)
ns_uri = self.namespaces[ns_name]
if not entity:
try:
entity = self.entities[ns_uri][typ][name]
except KeyError:
self.app.warn("Dependency %s not found in schemas" %
get_target_id(typ, ns_name, name))
continue
doc = self.get_documentor(entity, name=name, ns_uri=ns_uri)
rv.extend(doc.document())
added.append((typ, name))
return rv
开发者ID:zenazn,项目名称:bcfg2,代码行数:47,代码来源:xmlschema.py
示例17: run
def run(self):
env = self.state.document.settings.env
package = env.temp_data.get('el:package')
keymap_list = DATA.get(package, {}).get('keymap', [])
keymap_name = self.arguments[0]
for keymap in keymap_list:
if keymap['name'] == keymap_name:
break
else:
return [self.state.reporter.warning(
"Keymap {0} not found".format(keymap_name))]
nodelist = []
mapdoc = keymap['doc']
if mapdoc:
nd = nodes.paragraph()
lines = string2lines(doc_to_rst(mapdoc))
if lines and lines[-1].startswith('(fn '):
lines = lines[:-1]
self.state.nested_parse(StringList(lines), 0, nd)
nodelist.append(nd)
exclude = self.options.get('exclude', [])
replace = self.options.get('replace', [])
for keybind in filter_by_exclude_regexp_list(
keymap['data'], exclude, lambda x: x['func']):
desc = addnodes.desc()
desc['domain'] = 'el'
desc['objtype'] = 'keybind'
desc['noindex'] = False
signode = addnodes.desc_signature()
# signode += addnodes.desc_annotation("", 'keybind ')
key = simple_sed(replace, keybind['key'])
signode += addnodes.desc_name("", key)
signode += addnodes.desc_addname("", " " + keybind['func'])
desc += signode
if keybind['doc']:
nd = addnodes.desc_content()
lines = string2lines(doc_to_rst(keybind['doc']))
if lines and lines[-1].startswith('(fn '):
lines = lines[:-1]
self.state.nested_parse(StringList(lines), 0, nd)
desc += nodes.definition("", nd)
nodelist.append(desc)
return nodelist
开发者ID:hyphenlee,项目名称:emacs.d,代码行数:46,代码来源:eldomain.py
示例18: run
def run(self):
"""
Main directive entry function, called by docutils upon encountering the
directive.
This directive is meant to be quite easily subclassable, so it delegates
to several additional methods. What it does:
* find out if called as a domain-specific directive, set self.domain
* create a `desc` node to fit all description inside
* parse standard options, currently `noindex`
* create an index node if needed as self.indexnode
* parse all given signatures (as returned by self.get_signatures())
using self.handle_signature(), which should either return a name
or raise ValueError
* add index entries using self.add_target_and_index()
* parse the content and handle doc fields in it
"""
# set info for sphinx_directive
self.sphinx_directive.objtype = self.objtype
self.sphinx_directive.domain = self.domain
self.sphinx_directive.env = self.sphinx_directive.state.document.settings.env
self.sphinx_directive.indexnode = addnodes.index(entries=[])
# setup this node
self.node = addnodes.desc()
self.node.document = self.sphinx_directive.state.document
self.node['domain'] = self.domain
# 'desctype' is a backwards compatible attribute
self.node['objtype'] = self.node['desctype'] = self.sphinx_directive.objtype
self.node['noindex'] = noindex = ('noindex' in self.sphinx_directive.options)
self.noindex = noindex
self.sphinx_directive.names = []
# get renderer
self.data_object_renderer = self.get_data_object_renderer()
#self.data_object_renderer.handle()
self.node.extend(self.data_object_renderer.render())
return [self.sphinx_directive.indexnode, self.node]
开发者ID:Cyofanni,项目名称:speect,代码行数:46,代码来源:std.py
示例19: make_process_header
def make_process_header(self, slug, typ, version, source_uri, description, inputs):
"""Generate a process definition header.
:param str slug: process' slug
:param str typ: process' type
:param str version: process' version
:param str source_uri: url to the process definition
:param str description: process' description
:param dict inputs: process' inputs
"""
node = addnodes.desc()
signode = addnodes.desc_signature(slug, '')
node.append(signode)
node['objtype'] = node['desctype'] = typ
signode += addnodes.desc_annotation(typ, typ, classes=['process-type'])
signode += addnodes.desc_addname('', '')
signode += addnodes.desc_name(slug + ' ', slug + ' ')
paramlist = addnodes.desc_parameterlist()
for field_schema, _, _ in iterate_schema({}, inputs, ''):
field_type = field_schema['type']
field_name = field_schema['name']
field_default = field_schema.get('default', None)
field_default = '' if field_default is None else '={}'.format(field_default)
param = addnodes.desc_parameter('', '', noemph=True)
param += nodes.emphasis(field_type, field_type, classes=['process-type'])
# separate by non-breaking space in the output
param += nodes.strong(text=u'\xa0\xa0' + field_name)
paramlist += param
signode += paramlist
signode += nodes.reference('', nodes.Text('[Source: v{}]'.format(version)),
refuri=source_uri, classes=['viewcode-link'])
desc = nodes.paragraph()
desc += nodes.Text(description, description)
return [node, desc]
开发者ID:hadalin,项目名称:resolwe,代码行数:45,代码来源:autoprocess.py
示例20: format_operation
def format_operation(self, operations):
c = n.container()
for op in operations:
p = addnodes.desc(objtype='endpoint')
p += addnodes.desc_signature('nickname', op['nickname'])
p += addnodes.desc_addname('method', op['httpMethod'])
p += addnodes.desc_content(text=op['summary'])
if 'parameters' in op.keys():
p += addnodes.desc_annotation(text='Parameters: ')
params = self.format_parameters(op['parameters'])
p += params
if op.get('responseClass'):
response = self.format_response_class(op['responseClass'])
p += response
c += p
return c
开发者ID:doismellburning,项目名称:cla_backend,代码行数:18,代码来源:swag.py
注:本文中的sphinx.addnodes.desc函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论