本文整理汇总了Python中sphinx.addnodes.desc_content函数的典型用法代码示例。如果您正苦于以下问题:Python desc_content函数的具体用法?Python desc_content怎么用?Python desc_content使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了desc_content函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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
示例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
示例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
示例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]
示例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
示例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]
示例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]
示例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]
示例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
示例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
示例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]
示例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
示例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
]
示例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)
示例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