mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
#5660 add classes for different version modications
Generic class: ``versionmodified` *Changed* class: ``changed`` *Added* class: ``added`` *Deprecated* class: ``deprecated``
This commit is contained in:
parent
60ef37ce33
commit
98040af245
@ -27,13 +27,18 @@ if False:
|
|||||||
from sphinx.application import Sphinx # NOQA
|
from sphinx.application import Sphinx # NOQA
|
||||||
from sphinx.environment import BuildEnvironment # NOQA
|
from sphinx.environment import BuildEnvironment # NOQA
|
||||||
|
|
||||||
|
|
||||||
versionlabels = {
|
versionlabels = {
|
||||||
'versionadded': _('New in version %s'),
|
'versionadded': _('New in version %s'),
|
||||||
'versionchanged': _('Changed in version %s'),
|
'versionchanged': _('Changed in version %s'),
|
||||||
'deprecated': _('Deprecated since version %s'),
|
'deprecated': _('Deprecated since version %s'),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
versionlabel_classes = {
|
||||||
|
'versionadded': 'added',
|
||||||
|
'versionchanged': 'changed',
|
||||||
|
'deprecated': 'deprecated',
|
||||||
|
}
|
||||||
|
|
||||||
locale.versionlabels = DeprecatedDict(
|
locale.versionlabels = DeprecatedDict(
|
||||||
versionlabels,
|
versionlabels,
|
||||||
'sphinx.locale.versionlabels is deprecated. '
|
'sphinx.locale.versionlabels is deprecated. '
|
||||||
@ -78,6 +83,7 @@ class VersionChange(SphinxDirective):
|
|||||||
messages = []
|
messages = []
|
||||||
if self.content:
|
if self.content:
|
||||||
self.state.nested_parse(self.content, self.content_offset, node)
|
self.state.nested_parse(self.content, self.content_offset, node)
|
||||||
|
classes = ['versionmodified', versionlabel_classes[self.name]]
|
||||||
if len(node):
|
if len(node):
|
||||||
if isinstance(node[0], nodes.paragraph) and node[0].rawsource:
|
if isinstance(node[0], nodes.paragraph) and node[0].rawsource:
|
||||||
content = nodes.inline(node[0].rawsource, translatable=True)
|
content = nodes.inline(node[0].rawsource, translatable=True)
|
||||||
@ -87,11 +93,11 @@ class VersionChange(SphinxDirective):
|
|||||||
node[0].replace_self(nodes.paragraph('', '', content, translatable=False))
|
node[0].replace_self(nodes.paragraph('', '', content, translatable=False))
|
||||||
|
|
||||||
para = cast(nodes.paragraph, node[0])
|
para = cast(nodes.paragraph, node[0])
|
||||||
para.insert(0, nodes.inline('', '%s: ' % text, classes=['versionmodified']))
|
para.insert(0, nodes.inline('', '%s: ' % text, classes=classes))
|
||||||
else:
|
else:
|
||||||
para = nodes.paragraph('', '',
|
para = nodes.paragraph('', '',
|
||||||
nodes.inline('', '%s.' % text,
|
nodes.inline('', '%s.' % text,
|
||||||
classes=['versionmodified']),
|
classes=classes),
|
||||||
translatable=False)
|
translatable=False)
|
||||||
node.append(para)
|
node.append(para)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user