本文整理汇总了Python中sphinx.addnodes.versionmodified函数的典型用法代码示例。如果您正苦于以下问题:Python versionmodified函数的具体用法?Python versionmodified怎么用?Python versionmodified使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了versionmodified函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: add_auto_version_changed
def add_auto_version_changed(self, node):
"""Add a version_node to document a version change to ``node``.
Add the new node at the end of ``node``.
"""
symbol = self.lookup_auto_symbol()
if not symbol:
return
package, version = symbol.properties.get(
'custom-package-version', ('', ''))
if version:
version_node = addnodes.versionmodified()
version_node.document = self.state.document
set_source_info(self, version_node)
version_node['type'] = 'versionchanged'
version_node['version'] = version
msg = self.VERSION_CHANGE_LABEL.format(
objtype=self.object_type.lname, version=version,
package=package)
msg_node = corenodes.inline('', msg, classes=['versionmodified'])
version_node.append(corenodes.paragraph('', '', msg_node))
env = self.state.document.settings.env
env.note_versionchange(
version_node['type'], version_node['version'],
version_node, version_node.line)
node.append(version_node)
return node
示例2: run
def run(self):
env = self.state.document.settings.env
arg0 = self.arguments[0]
is_nextversion = env.config.next_version == arg0
ret = []
node = addnodes.versionmodified()
ret.append(node)
if is_nextversion:
node['version'] = "Development version"
else:
if len(self.arguments) == 1:
# linktext = 'Please, see the Changelog <0_0_4>'
# xrefs = roles.XRefRole()('release', linktext, linktext, self.lineno, self.state)
# node.extend(xrefs[0])
linktext = 'Please, see the Changelog <changes>'
xrefs = roles.XRefRole()('doc', linktext, linktext, self.lineno, self.state)
node.extend(xrefs[0])
node['version'] = arg0
node['type'] = self.name
if len(self.arguments) == 2:
inodes, messages = self.state.inline_text(self.arguments[1], self.lineno + 1)
node.extend(inodes)
if self.content:
self.state.nested_parse(self.content, self.content_offset, node)
ret = ret + messages
env.note_versionchange(node['type'], node['version'], node, self.lineno)
return ret
示例3: run
def run(self):
if len(self.arguments) > 1:
msg = """Only one argument accepted for directive '{directive_name}::'.
Comments should be provided as content,
not as an extra argument.""".format(directive_name=self.name)
raise self.error(msg)
env = self.state.document.settings.env
ret = []
node = addnodes.versionmodified()
ret.append(node)
if self.arguments[0] == env.config.karaage_next_version:
node['version'] = "Development version"
else:
node['version'] = self.arguments[0]
node['type'] = self.name
if self.content:
self.state.nested_parse(self.content, self.content_offset, node)
try:
env.get_domain('changeset').note_changeset(node)
except ExtensionError:
# Sphinx < 1.8: Domain 'changeset' is not registered
env.note_versionchange(node['type'], node['version'], node, self.lineno)
return ret
示例4: parse_version_directive
def parse_version_directive(name, arguments, options, content, lineno,
content_offset, block_text, state, state_machine):
env = state.document.settings.env
is_nextversion = env.config.django_next_version == arguments[0]
ret = []
node = addnodes.versionmodified()
ret.append(node)
if not is_nextversion:
if len(arguments) == 1:
linktext = 'Please, see the release notes <releases-%s>' % (arguments[0])
try:
xrefs = roles.XRefRole()('ref', linktext, linktext, lineno, state) # Sphinx >= 1.0
except:
xrefs = roles.xfileref_role('ref', linktext, linktext, lineno, state) # Sphinx < 1.0
node.extend(xrefs[0])
node['version'] = arguments[0]
else:
node['version'] = "Development version"
node['type'] = name
if len(arguments) == 2:
inodes, messages = state.inline_text(arguments[1], lineno+1)
node.extend(inodes)
if content:
state.nested_parse(content, content_offset, node)
ret = ret + messages
env.note_versionchange(node['type'], node['version'], node, lineno)
return ret
示例5: run
def run(self):
node = addnodes.versionmodified()
node.document = self.state.document
node["type"] = "deprecated-removed"
version = (self.arguments[0], self.arguments[1])
node["version"] = version
text = self._label % version
if len(self.arguments) == 3:
inodes, messages = self.state.inline_text(self.arguments[2], self.lineno + 1)
para = nodes.paragraph(self.arguments[2], "", *inodes)
node.append(para)
else:
messages = []
if self.content:
self.state.nested_parse(self.content, self.content_offset, node)
if isinstance(node[0], nodes.paragraph) and node[0].rawsource:
content = nodes.inline(node[0].rawsource, translatable=True)
content.source = node[0].source
content.line = node[0].line
content += node[0].children
node[0].replace_self(nodes.paragraph("", "", content))
if not SPHINX11:
node[0].insert(0, nodes.inline("", "%s: " % text, classes=["versionmodified"]))
elif not SPHINX11:
para = nodes.paragraph("", "", nodes.inline("", "%s." % text, classes=["versionmodified"]))
if len(node):
node.insert(0, para)
else:
node.append(para)
env = self.state.document.settings.env
env.note_versionchange("deprecated", version[0], node, self.lineno)
return [node] + messages
示例6: run
def run(self):
node = addnodes.versionmodified()
node.document = self.state.document
set_source_info(self, node)
node['type'] = self.name
node['version'] = self.arguments[0]
text = versionlabels[self.name] % self.arguments[0]
if len(self.arguments) == 2:
inodes, messages = self.state.inline_text(self.arguments[1],
self.lineno+1)
para = nodes.paragraph(self.arguments[1], '', *inodes)
set_source_info(self, para)
node.append(para)
else:
messages = []
if self.content:
self.state.nested_parse(self.content, self.content_offset, node)
if len(node):
if isinstance(node[0], nodes.paragraph) and node[0].rawsource:
content = nodes.inline(node[0].rawsource, translatable=True)
content.source = node[0].source
content.line = node[0].line
content += node[0].children
node[0].replace_self(nodes.paragraph('', '', content))
node[0].insert(0, nodes.inline('', '%s: ' % text,
classes=['versionmodified']))
else:
para = nodes.paragraph('', '',
nodes.inline('', '%s.' % text,
classes=['versionmodified']))
node.append(para)
env = self.state.document.settings.env
# XXX should record node.source as well
env.note_versionchange(node['type'], node['version'], node, node.line)
return [node] + messages
示例7: run
def run(self):
env = self.state.document.settings.env
arg0 = self.arguments[0]
is_nextversion = env.config.django_next_version == arg0
ret = []
node = addnodes.versionmodified()
ret.append(node)
if not is_nextversion:
if len(self.arguments) == 1:
linktext = 'Please, see the release notes <releases-%s>' % \
(arg0,)
try:
# Sphinx >= 1.0
xrefs = roles.XRefRole()('std:ref', linktext, linktext,
self.lineno, self.state)
except AttributeError:
# Sphinx < 1.0
xrefs = roles.xfileref_role('ref', linktext, linktext,
self.lineno, self.state)
node.extend(xrefs[0])
node['version'] = arg0
else:
node['version'] = "Development version"
node['type'] = self.name
if len(self.arguments) == 2:
inodes, messages = self.state.inline_text(self.arguments[1],
self.lineno + 1)
node.extend(inodes)
if self.content:
self.state.nested_parse(self.content, self.content_offset,
node)
ret = ret + messages
env.note_versionchange(node['type'], node['version'], node,
self.lineno)
return ret
示例8: run
def run(self):
node = addnodes.versionmodified()
node.document = self.state.document
node['type'] = 'deprecated-removed'
version = (self.arguments[0], self.arguments[1])
node['version'] = version
label = translators['sphinx'].gettext(self._label)
text = label.format(deprecated=self.arguments[0], removed=self.arguments[1])
if len(self.arguments) == 3:
inodes, messages = self.state.inline_text(self.arguments[2],
self.lineno+1)
para = nodes.paragraph(self.arguments[2], '', *inodes, translatable=False)
node.append(para)
else:
messages = []
if self.content:
self.state.nested_parse(self.content, self.content_offset, node)
if len(node):
if isinstance(node[0], nodes.paragraph) and node[0].rawsource:
content = nodes.inline(node[0].rawsource, translatable=True)
content.source = node[0].source
content.line = node[0].line
content += node[0].children
node[0].replace_self(nodes.paragraph('', '', content, translatable=False))
node[0].insert(0, nodes.inline('', '%s: ' % text,
classes=['versionmodified']))
else:
para = nodes.paragraph('', '',
nodes.inline('', '%s.' % text,
classes=['versionmodified']),
translatable=False)
node.append(para)
env = self.state.document.settings.env
env.note_versionchange('deprecated', version[0], node, self.lineno)
return [node] + messages
示例9: version_directive
def version_directive(name, arguments, options, content, lineno,
content_offset, block_text, state, state_machine):
node = addnodes.versionmodified()
node['type'] = name
node['version'] = arguments[0]
if len(arguments) == 2:
inodes, messages = state.inline_text(arguments[1], lineno+1)
node.extend(inodes)
if content:
state.nested_parse(content, content_offset, node)
ret = [node] + messages
else:
ret = [node]
env = state.document.settings.env
env.note_versionchange(node['type'], node['version'], node, lineno)
return ret
示例10: run
def run(self):
node = addnodes.versionmodified()
node.document = self.state.document
node['type'] = self.name
node['version'] = self.arguments[0]
if len(self.arguments) == 2:
inodes, messages = self.state.inline_text(self.arguments[1],
self.lineno+1)
node.extend(inodes)
if self.content:
self.state.nested_parse(self.content, self.content_offset, node)
ret = [node] + messages
else:
ret = [node]
env = self.state.document.settings.env
env.note_versionchange(node['type'], node['version'], node, self.lineno)
return ret
示例11: run
def run(self):
if len(self.arguments) > 1:
msg = """Only one argument accepted for directive '{directive_name}::'.
Comments should be provided as content,
not as an extra argument.""".format(directive_name=self.name)
raise self.error(msg)
env = self.state.document.settings.env
ret = []
node = addnodes.versionmodified()
ret.append(node)
node['version'] = self.arguments[0]
node['type'] = self.name
if self.content:
self.state.nested_parse(self.content, self.content_offset, node)
env.note_versionchange(node['type'], node['version'], node, self.lineno)
return ret
示例12: run
def run(self):
node = addnodes.versionmodified()
node.document = self.state.document
node["type"] = "deprecated-removed"
version = (self.arguments[0], self.arguments[1])
node["version"] = version
if len(self.arguments) == 3:
inodes, messages = self.state.inline_text(self.arguments[2], self.lineno + 1)
node.extend(inodes)
if self.content:
self.state.nested_parse(self.content, self.content_offset, node)
ret = [node] + messages
else:
ret = [node]
env = self.state.document.settings.env
env.note_versionchange("deprecated", version[0], node, self.lineno)
return ret
示例13: run
def run(self):
env = self.state.document.settings.env
ret = []
node = addnodes.versionmodified()
ret.append(node)
if self.arguments[0] == env.config.django_next_version:
node['version'] = "Development version"
else:
node['version'] = self.arguments[0]
node['type'] = self.name
if len(self.arguments) == 2:
inodes, messages = self.state.inline_text(self.arguments[1], self.lineno+1)
node.extend(inodes)
if self.content:
self.state.nested_parse(self.content, self.content_offset, node)
ret = ret + messages
env.note_versionchange(node['type'], node['version'], node, self.lineno)
return ret
示例14: run
def run(self):
# type: () -> List[nodes.Node]
node = addnodes.versionmodified()
node.document = self.state.document
set_source_info(self, node)
node['type'] = self.name
node['version'] = self.arguments[0]
text = versionlabels[self.name] % self.arguments[0]
if len(self.arguments) == 2:
inodes, messages = self.state.inline_text(self.arguments[1],
self.lineno + 1)
para = nodes.paragraph(self.arguments[1], '', *inodes, translatable=False)
set_source_info(self, para)
node.append(para)
else:
messages = []
if self.content:
self.state.nested_parse(self.content, self.content_offset, node)
if len(node):
if isinstance(node[0], nodes.paragraph) and node[0].rawsource:
content = nodes.inline(node[0].rawsource, translatable=True)
content.source = node[0].source
content.line = node[0].line
content += node[0].children
node[0].replace_self(nodes.paragraph('', '', content, translatable=False))
para = cast(nodes.paragraph, node[0])
para.insert(0, nodes.inline('', '%s: ' % text, classes=['versionmodified']))
else:
para = nodes.paragraph('', '',
nodes.inline('', '%s.' % text,
classes=['versionmodified']),
translatable=False)
node.append(para)
domain = cast(ChangeSetDomain, self.env.get_domain('changeset'))
domain.note_changeset(node)
ret = [node] # type: List[nodes.Node]
ret += messages
return ret
示例15: run
def run(self):
"""Translate the directive to the appropriate markup."""
answer = []
# Sanity Check: This directive only understands one argument.
if len(self.arguments) != 1:
raise self.error('%s takes exactly one argument.' % self.name)
# Get the environment, which knows things like what
# the next version will be.
env = self.state.document.settings.env
# Determine what the version is
if self.arguments[0] == env.config.next_version:
version = 'Development'
version_string = 'development version'
else:
version = self.arguments[0]
version_string = 'version %s' % version
# Determine the proper node text.
# This should be simple, but Read the Docs misbehaves
# (and does so in a totally undocumented way). Sigh.
kwargs = {}
if not os.environ.get('READTHEDOCS', None):
kwargs['text'] = 'New in %s.' % version_string
# Create and append the node.
node = addnodes.versionmodified(**kwargs)
answer.append(node)
# Place the node into the contents.
node['type'] = self.name
node['version'] = version
node['style'] = 'font-size: 60%; text-style: italic;'
# Done. Return the answer.
return answer