本文整理汇总了Python中sphinx.addnodes.desc_content函数的典型用法代码示例。如果您正苦于以下问题:Python desc_content函数的具体用法?Python desc_content怎么用?Python desc_content使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了desc_content函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: run
def run(self):
result = super(ELSExp, self).run()
if "nodoc" not in self.options:
package = self.env.temp_data.get('el:package')
node = addnodes.desc_content()
string = DATA_DOC_STRINGS.get(package, {}) \
.get(self.names[0][1], "")
lines = string2lines(string)
if lines and lines[-1].startswith('(fn '):
lines = lines[:-1]
self.state.nested_parse(StringList(lines), 0, node)
if (result[1][1].children and
isinstance(result[1][1][0], nodes.field_list)):
cresult = result[1][1].deepcopy()
target = result[1][1]
target.clear()
target.append(cresult[0])
target.extend(node)
target.extend(cresult[1:])
else:
cresult = result[1][1].deepcopy()
target = result[1][1]
target.clear()
target.extend(node)
target.extend(cresult)
return result
开发者ID:hyphenlee,项目名称:emacs.d,代码行数:26,代码来源:eldomain.py
示例2: make_content
def make_content(self, all_members):
doc = self.item
content = addnodes.desc_content()
if doc.exports or doc.dependencies:
with addto(content, nodes.field_list()) as fields:
if doc.exports:
with addto(fields, nodes.field()) as field:
field += nodes.field_name('Exports', 'Exports')
with addto(field, nodes.field_body()) as body:
ref = doc['exports'] # warning: not the same as doc.exports
label = ref or '<anonymous>'
link = addnodes.pending_xref(
ref, nodes.paragraph(ref, label),
refdomain='js',
reftype='any',
reftarget=ref,
)
link['js:module'] = doc.name
body += link
if doc.dependencies:
with addto(fields, nodes.field()) as field:
self.make_dependencies(field, doc)
if doc.doc:
# FIXME: source offset
self.directive.state.nested_parse(to_list(doc.doc, source=doc['sourcefile']), 0, content)
self.directive.state.nested_parse(self.directive.content, 0, content)
content += self.document_properties(all_members)
return content
开发者ID:xmo-odoo,项目名称:odoo,代码行数:34,代码来源:directives.py
示例3: 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
示例4: 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
示例5: getChildren
def getChildren(Parent, prefix):
Children = []
for name, Child in Parent.Members.iteritems():
if Child.Config.get('alias') == name: # don't process aliases
continue
id = '%s.%s' % (prefix, name)
if hasattr(Child, 'Members'):
Children += desc_content(prefix, *getGroupTree(Child, id))
else:
Children += desc_content(prefix, *getTaskTree(Child, id))
return Children
开发者ID:Laufire,项目名称:eccontrib-sphinxdoc,代码行数:16,代码来源:sphinxdoc.py
示例6: 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
示例7: run
def run(self):
document = self.state.document
env = document.settings.env
docname = env.docname
if ':' in self.name:
self.domain, self.objtype = self.name.split(':', 1)
else:
self.domain, self.objtype = 'py', self.name
key = self.find_key(self.content.parent)
targetnode = nodes.target('', '', ids=[key])
key_elem = keynode(key)
# Separating argument and content causes two <dd>-s to be generated in
# the same <dl>
doc = addnodes.desc_content()
update_attrs(doc, self)
txt = '\n'.join(self.arguments)
self.before_content()
details = keydoc(self.state, self.content)
update_attrs(details, self)
DocFieldTransformer(self).transform_all(details)
self.after_content()
doc += nodes.paragraph(txt, txt)
doc += details
import os
source_line = self.lineno
source, _ = self.state_machine.get_source_and_line(source_line)
src_file, src_other = source.split(':', 1)
source_file = os.path.basename(src_file)
doc_entry = ibkey(self, key, key_elem, doc)
#doc_entry = make_admonition(dummy, self.name, 'Alma', self.options, self.content, self.lineno, self.content_offset, self.block_text, self.state, self.state_machine)[0]
catalog_entry = iblist_entry(
self,
env, docname, src_other, source_file, source_line,
key, key_elem, doc)
set_source_info(self, doc_entry)
set_source_info(self, catalog_entry)
env.resolve_references(doc_entry, docname, env.app.builder)
env.resolve_references(catalog_entry, docname, env.app.builder)
if not hasattr(env, 'ibkey_all_ibkeys'):
env.ibkey_all_ibkeys = dict()
env.ibkey_all_ibkeys[key] = dict(docname=docname,
catalog_entry=catalog_entry)
# - super.run() doesnt't kill the structure, it works fine
# - returning both superrun and doc_entry does (in any order)
# - The todo in the method docstring is rendered outside the
# method's documentation (?!)
return [doc_entry] #[targetnode, doc_entry]
开发者ID:novakadam94,项目名称:docs,代码行数:59,代码来源:ibkeys.py
示例8: 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
示例9: 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
示例10: 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
示例11: 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
示例12: getMemberContent
def getMemberContent(Member, *Children):
Config = Member.Config
Content = desc_content(*Children)
doc = Member.Underlying.__doc__
if doc:
Content.insert(0, getNodeTreeFromStr(doc)) # add the parsed docstring to the content.
if 'desc' in Config:
Content.insert(0, paragraph(text=Config['desc']))
return Content
开发者ID:Laufire,项目名称:eccontrib-sphinxdoc,代码行数:12,代码来源:sphinxdoc.py
示例13: 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
示例14: transform_module_section
def transform_module_section(section_node, title_node, env):
fullmodname = section_node['names'][0]
where = section_node.first_child_matching_class(section_prelude_end_class)
content_children = list(ipop_child(section_node, where + 1))
if title_node is None:
signature_children = [literal('', fullmodname)]
else:
signature_children = list(ipop_child(title_node))
signature_node = desc_signature('', '', *signature_children,
classes=['title', 'module'],
names=[fullmodname])
content_node = desc_content('', *content_children)
desc_node = desc('', signature_node, content_node,
desctype='module',
objtype='module',
classes=['definition'])
section_node.append(desc_node)
add_toc(desc_node, env, section_node)
开发者ID:Anugrahaa,项目名称:anagrammatic,代码行数:18,代码来源:boilerplate.py
示例15: 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:ministryofjustice,项目名称:cla_backend,代码行数:18,代码来源:swag.py
示例16: generate
def generate(self, all_members=False):
"""
:rtype: List[nodes.Node]
"""
objname = self.item.name
prefixed = (self.item['sourcemodule'].name + '.' + objname) if self.item['sourcemodule'] else None
objtype = self.objtype
assert objtype, '%s has no objtype' % type(self)
root = addnodes.desc(domain='js', desctype=objtype, objtype=objtype)
with addto(root, addnodes.desc_signature(
module=self.modname or '',
fullname=objname,
)) as s:
s['class'] = self.classname
s['ids'] = []
if objname:
s['ids'].append(objname)
if prefixed:
s['ids'].append(prefixed)
if objtype:
s += addnodes.desc_annotation(
objtype, objtype,
nodes.Text(' '),
)
env = self.env
if objname:
env.domaindata['js']['objects'][objname] = (env.docname, objtype)
if prefixed:
env.domaindata['js']['objects'][prefixed] = (env.docname, objtype)
# TODO: linkcode_resolve
s += self.make_signature()
with addto(root, addnodes.desc_content()) as c:
# must be here otherwise nested_parse(self.content) will not have
# the prefix set
self.env.temp_data.setdefault('autojs:prefix', []).append(self.item.name)
c += self.make_content(all_members=all_members)
self.env.temp_data['autojs:prefix'].pop()
return [root]
开发者ID:PieterPaulussen,项目名称:odoo,代码行数:42,代码来源:directives.py
示例17: 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=[])
node = addnodes.desc()
node.document = self.state.document
node['domain'] = self.domain
node['objtype'] = node['desctype'] = self.objtype
node['noindex'] = False
try:
signature = self.arguments[0]
if self.objtype == 'schema':
signode = addnodes.desc_signature(signature)
signode['first'] = False
node += signode
except:
signature = None
headernode = addnodes.desc_name()
headernode += nodes.inline('', _(self.objtype) + ' ')
if signature is not None:
headernode += nodes.emphasis('', signature)
if _is_compositional(self.options['type']):
if signature is not None:
headernode += nodes.inline('', ' -- ')
_describe_type(self.options['type'], headernode,
contains=self.options['contains'])
node.append(headernode)
contentnode = addnodes.desc_content()
node.append(contentnode)
self.state.nested_parse(self.content, self.content_offset, contentnode)
type = self.options['type']
if type in __transformers__:
__transformers__[type](self).transform_all(contentnode)
return [addnodes.index(entries=[]), node]
开发者ID:segfault87,项目名称:sphinx-rx,代码行数:42,代码来源:rx.py
示例18: _make_enum_documentation
def _make_enum_documentation(self, obj):
def get_entry(node):
para = addnodes.compact_paragraph()
para += node
entry = nodes.entry()
entry += para
return entry
desc = addnodes.desc_signature()
desc['ids'].append(obj.get_id())
first = False
desc += nodes.emphasis(text=u'enum')
desc += nodes.Text(u' ')
desc += addnodes.desc_name(text=obj.get_name())
desc.attributes['first'] = True
content = addnodes.desc_content()
if obj.brief():
para = nodes.paragraph()
para += nodes.emphasis(text='Brief: ')
para += nodes.Text(' '.join(obj.brief()))
content += para
table, body = nodes.table(), nodes.tbody()
tgroup = nodes.tgroup(cols=3)
thead = nodes.thead()
for it in [20, 10, 70]:
tgroup += nodes.colspec(colwidth=it)
tgroup += thead
tgroup += body
table += tgroup
head_row = nodes.row()
for it in ['Name', 'Value', 'Brief']:
head_row += get_entry(nodes.Text(it))
thead += head_row
for val in sorted(obj.values):
row = nodes.row()
row += get_entry(nodes.literal(text=val.name))
tmp = [val.value if val.value is not None else '',
' '.join(val.brief())]
for it in tmp:
row += get_entry(nodes.Text(it))
body += row
content += table
return (desc, content)
开发者ID:aldebaran,项目名称:doc-tools,代码行数:42,代码来源:__init__.py
示例19: parse_section
def parse_section(self, node):
matched = re.search("^(.*?)\s*\((.*)\)\s*$", node[0].astext())
if not matched:
return
objname = matched.group(1).strip()
typename = matched.group(2).strip()
desc = sphinxnodes.desc(domain="js", desctype="data", objtype="data")
sig = sphinxnodes.desc_signature(object="", fullname=objname, first=False)
sig["names"].append(objname)
sig["ids"].append(objname.replace("$", "_S_"))
sig += sphinxnodes.desc_name(text="%s (%s)" % (objname, typename))
content = sphinxnodes.desc_content()
node.pop(0)
transpose_subnodes(node, content)
node.replace_self(desc)
desc.append(sig)
desc.append(content)
开发者ID:tk0miya,项目名称:sphinxcontrib-apiblueprint,代码行数:21,代码来源:addnodes.py
示例20: add_sig_name
def add_sig_name(self, signode, name):
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)
if "inheritance" in self.sphinx_directive.options:
inheritance_node = addnodes.desc_content('')
self.add_inheritance_diagram(inheritance_node)
signode += inheritance_node
# clean up parentheses from canonical name
m = c_funcptr_name_re.match(name)
if m:
name = m.group(1)
return self.get_full_name(name)
开发者ID:Cyofanni,项目名称:speect,代码行数:21,代码来源:c.py
注:本文中的sphinx.addnodes.desc_content函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论