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
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)) else: para = nodes.paragraph('', '', nodes.inline('', '%s.' % text)) 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
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
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
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
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.django_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
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
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
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 = u'リリースノートを参照してください </releases/%s>' % (arg0) xrefs = roles.XRefRole()('doc', 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
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
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
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
def run(self) -> List[Node]: node = addnodes.versionmodified() node.document = self.state.document self.set_source_info(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) self.set_source_info(para) node.append(para) else: messages = [] if self.content: self.state.nested_parse(self.content, self.content_offset, node) classes = ['versionmodified', versionlabel_classes[self.name]] if len(node) > 0 and isinstance(node[0], nodes.paragraph): # the contents start with a paragraph if node[0].rawsource: # make the first paragraph translatable 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=classes)) elif len(node) > 0: # the contents do not starts with a paragraph para = nodes.paragraph('', '', nodes.inline('', '%s: ' % text, classes=classes), translatable=False) node.insert(0, para) else: # the contents are empty para = nodes.paragraph('', '', nodes.inline('', '%s.' % text, classes=classes), translatable=False) node.append(para) domain = cast(ChangeSetDomain, self.env.get_domain('changeset')) domain.note_changeset(node) ret: List[Node] = [node] ret += messages return ret
def run(self) -> List[nodes.Node]: # Some Sphinx stuff node = addnodes.versionmodified() node.document = self.state.document self.set_source_info(node) node["type"] = self.name node["version"] = tuple(self.arguments) 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) self.set_source_info(para) node.append(para) else: messages = [] # Text generation deprecation_version = self.arguments[0] minimum_days = int(self.arguments[1]) tag_date = _TAGS.get_tag_date(deprecation_version) text = ( f"Will be deprecated in version {deprecation_version}," " and removed in the first minor version that gets released" f" after {minimum_days} days since deprecation" if tag_date is None else f"Deprecated since version {deprecation_version}," " will be removed in the first minor version that gets released" f" after {tag_date + datetime.timedelta(days=minimum_days)}") # More Sphinx stuff if self.content: self.state.nested_parse(self.content, self.content_offset, node) classes = ["versionmodified"] 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("", f"{text}: ", classes=classes)) else: para = nodes.paragraph("", "", nodes.inline("", f"{text}.", classes=classes), translatable=False) node.append(para) ret = [node] ret += messages return ret
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 env = self.state.document.settings.env current_version = tuple(int(e) for e in env.config.version.split('.')) removed_version = tuple(int(e) for e in self.arguments[1].split('.')) if current_version < removed_version: label = self._deprecated_label else: label = self._removed_label label = translators['sphinx'].gettext(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 # deprecated pre-Sphinx-2 method if hasattr(env, 'note_versionchange'): env.note_versionchange('deprecated', version[0], node, self.lineno) # new method else: env.get_domain('changeset').note_changeset(node) return [node] + messages
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
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
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
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
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
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
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
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
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
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
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'] = '%s %s.' % (self._prefix, 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
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) xrefs = roles.XRefRole()("doc", 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
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 = 'Пожалуйста, обратитесь к описанию релиза </releases/%s>' % (arg0) xrefs = roles.XRefRole()('doc', 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
def run(self): env = self.state.document.settings.env arg0 = self.arguments[0] ret = [] node = addnodes.versionmodified() ret.append(node) node['type'] = self.name if env.config.next_version == arg0: version = "Development version" link = None else: version = arg0 link = 'release-%s' % arg0 node['version'] = version # inodes, messages = self.state.inline_text(self.version_text[self.name] % version, self.lineno+1) # node.extend(inodes) if link: text = ' Please see the changelog <%s>' % link xrefs = roles.XRefRole()('std:ref', text, text, self.lineno, self.state) node.extend(xrefs[0]) env.note_versionchange(node['type'], node['version'], node, self.lineno) return ret
def run(self) -> List[Node]: """ Process the content of the directive. """ node = addnodes.versionmodified() node.document = self.state.document self.set_source_info(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) self.set_source_info(para) node.append(para) else: messages = [] if self.content: self.state.nested_parse(self.content, self.content_offset, node) classes = ["versionmodified", versionlabel_classes[self.name]] if len(node): to_add: Optional[nodes.Node] = None 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)) elif isinstance(node[0], (nodes.bullet_list, nodes.enumerated_list)): # Fix for incorrect ordering with bullet lists node.insert(0, nodes.compound('')) to_add = nodes.paragraph('', '') para = cast(nodes.paragraph, node[0]) para.insert(0, nodes.inline('', f'{text}: ', classes=classes)) if to_add is not None: node.insert(0, to_add) else: para = nodes.paragraph( '', '', nodes.inline('', f'{text}.', classes=classes), translatable=False, ) node.append(para) domain = cast( sphinx.domains.changeset.ChangeSetDomain, self.env.get_domain("changeset"), ) domain.note_changeset(node) ret = [node] # type: List[Node] ret += messages return ret