本文整理汇总了Python中sphinx.util.compat.make_admonition函数的典型用法代码示例。如果您正苦于以下问题:Python make_admonition函数的具体用法?Python make_admonition怎么用?Python make_admonition使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了make_admonition函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: run
def run(self):
nodes = make_admonition(extension_node,
self.name, [_('DB API extension')], self.options,
self.content, self.lineno, self.content_offset,
self.block_text, self.state, self.state_machine)
nodes[0]['classes'].append('dbapi-extension')
return nodes
示例2: _make_admonition
def _make_admonition(self, title="Task"):
ad = make_admonition(task, self.name, [title], self.options,
self.content, self.lineno, self.content_offset,
self.block_text, self.state, self.state_machine)
self.add_name(ad[0])
#print(title, ad)
return ad
示例3: run
def run(self):
env = self.state.document.settings.env
targetid = "tag-%d" % env.new_serialno('tag')
targetnode = nodes.target('', '', ids=[targetid])
#the tags fetched from the custom directive are one piece of text
#sitting in self.content[0]
taggs = self.content[0].split(", ")
links = []
for tagg in taggs:
#create rst hyperlinks of format `Python <http://www.python.org/>`_.
link = "`" + tagg +" <../tags/" + tagg + ".html>`_ "
links.append(link)
#put links back in a single comma-separated string together
linkjoin = ", ".join(links)
#replace content[0] with hyperlinks to display in admonition
self.content[0] = linkjoin
ad = make_admonition(tag, self.name, [_('Tags')], self.options,
self.content, self.lineno, self.content_offset,
self.block_text, self.state, self.state_machine)
return [targetnode] + ad
示例4: run
def run(self):
env = self.state.document.settings.env
# create a new target node for linking to
targetid = "todo-%d" % env.new_serialno("todo")
targetnode = nodes.target("", "", ids=[targetid])
# make the admonition node
ad = make_admonition(
Todo,
self.name,
[("Todo")],
self.options,
self.content,
self.lineno,
self.content_offset,
self.block_text,
self.state,
self.state_machine,
)
# store a handle in a global list of all todos
if not hasattr(env, "todo_all_todos"):
env.todo_all_todos = []
env.todo_all_todos.append(
{"docname": env.docname, "lineno": self.lineno, "todo": ad[0].deepcopy(), "target": targetnode}
)
# return both the linking target and the node itself
return [targetnode] + ad
示例5: run
def run(self):
env = self.state.document.settings.env
targetid = "req-%d" % env.new_serialno('req')
targetnode = nodes.target('', '', ids=[targetid])
ad = make_admonition(req, self.name, [_('Requirement coverage')], self.options,
self.content, self.lineno, self.content_offset,
self.block_text, self.state, self.state_machine)
if not hasattr(env, 'req_all_reqs'):
env.req_all_reqs = []
env.req_all_reqs.append({
'docname': env.docname,
'evidence': '\n'.join(self.content[-1:]),
'section' : find_parent_section_name(self.state),
'reqid' : self.content[0],
'req': ad[0].deepcopy(),
'target': targetnode,
})
if not self.options.has_key('show'):
return [targetnode]
return [targetnode] + ad
示例6: run
def run(self):
env = self.state.document.settings.env
targetid = "sphinxreportwarning-%s" % env.new_serialno( 'sphinxreportwarning' )
# env.index_num += 1
targetnode = nodes.target('', '', ids=[targetid])
# this sets the formatting
self.options["class"] = "critical"
if len(self.arguments) > 0:
warningclass = self.arguments[0]
else:
warningclass = "generic"
ad = make_admonition(sphinxreportwarning_node,
self.name,
[_('SphinxreportWarning')],
self.options,
self.content, self.lineno, self.content_offset,
self.block_text, self.state, self.state_machine)
# Attach a list of all sphinxreportwarnings to the environment,
# the sphinxreportwarninglist works with the collected sphinxreportwarning nodes
if not hasattr(env, 'sphinxreportwarning_all_sphinxreportwarnings'):
env.sphinxreportwarning_all_sphinxreportwarnings = []
env.sphinxreportwarning_all_sphinxreportwarnings.append({
'docname': env.docname,
'lineno': self.lineno,
'sphinxreportwarning': ad[0].deepcopy(),
'warningclass' : warningclass,
'target': targetnode,
})
return [targetnode] + ad
示例7: run
def run(self):
if len(self.content) == 0:
# TODO: raise nice error that something is missing
return
string_vars = {
'uid': self.content[0],
'width': 480,
'height': 300,
'allowscriptaccess': 'allways',
'allowfullscreen': 'true', }
# TODO: need to redo this
#for item in self.content[1:]:
# item = item.split('=')
# if len(item) == 2:
# key, value = item[0].strip(), item[1].strip()
# if key in string_vars.keys():
# string_vars[key] = value
env = self.state.document.settings.env
targetid = "bliptv-%d" % env.new_serialno('embed')
targetnode = nodes.target('', '', ids=[targetid])
ad = make_admonition(embed, self.name, ['Todo'], self.options,
self.content, self.lineno, self.content_offset,
self.block_text, self.state, self.state_machine)
return [targetnode] + ad
示例8: run
def run(self):
# noinspection PyUnresolvedReferences
""" run
:return:
"""
ret = make_admonition(
self.node_class,
self.name,
[self.label],
self.options,
self.content,
self.lineno,
self.content_offset,
self.block_text,
self.state,
self.state_machine
)
if self.arguments:
argnodes, msgs = self.state.inline_text(self.arguments[0], self.lineno)
para = nodes.paragraph()
para += argnodes
para += msgs
ret[0].insert(1, para)
return ret
示例9: run
def run(self):
env = self.state.document.settings.env
ad = make_admonition(newinxc, self.name, [], self.options,
self.content, self.lineno, self.content_offset,
self.block_text, self.state, self.state_machine)
return ad
示例10: run
def run(self):
env = self.state.document.settings.env
return make_admonition(mongodoc, self.name,
['See general MongoDB documentation'],
self.options, self.content, self.lineno,
self.content_offset, self.block_text,
self.state, self.state_machine)
示例11: run
def run(self):
if self.is_seealso:
ret = make_admonition(addnodes.seealso, self.name, [_('See')], self.options,
self.content, self.lineno, self.content_offset, self.block_text,
self.state, self.state_machine)
else:
ret = make_admonition(optional_node, self.name, self.directive_name, self.options,
self.content, self.lineno, self.content_offset,
self.block_text, self.state, self.state_machine)
if self.arguments:
argnodes, msgs = self.state.inline_text(self.arguments[0],
self.lineno)
para = nodes.paragraph()
para += argnodes
para += msgs
ret[0].insert(1, para)
return ret
示例12: run
def run(self):
ad = make_admonition(UpdateNode, self.name, [_('Updated on')],
self.options,
self.content, self.lineno, self.content_offset,
self.block_text, self.state, self.state_machine)
ad[0]['date'] = self.arguments[0] if self.arguments else ''
set_source_info(self, ad[0])
return ad
示例13: run
def run(self):
env = self.state.document.settings.env
targetid = 'index-%s' % env.new_serialno('index')
targetnode = nodes.target('', '', ids=[targetid])
ad = make_admonition(todo_node, self.name, [_('Todo')], self.options,
self.content, self.lineno, self.content_offset,
self.block_text, self.state, self.state_machine)
set_source_info(self, ad[0])
return [targetnode] + ad
示例14: run
def run(self):
env = self.state.document.settings.env
targetid = 'yippie-%d' % env.new_serialno('yippie')
targetnode = nodes.target('', '', ids=[targetid])
ad = make_admonition(yippie_node, self.name, [_('Yippie')], self.options,
self.content, self.lineno, self.content_offset,
self.block_text, self.state, self.state_machine)
return [targetnode] + ad
示例15: run
def run(self):
self.arguments = ['instructor']
ret = make_admonition(instructor_node, self.name, [_('Instructor Note')],
self.options, self.content, self.lineno, self.content_offset,
self.block_text, self.state, self.state_machine)
ret[0]['expr'] = self.arguments[0]
ret[0]['classes'] += 'note'
return ret