summaryrefslogtreecommitdiff
path: root/sphinx/directives
diff options
context:
space:
mode:
authorNozomu Kaneko <nozom.kaneko@gmail.com>2013-01-06 18:37:21 +0900
committerNozomu Kaneko <nozom.kaneko@gmail.com>2013-01-06 18:37:21 +0900
commit2ce5da1c1866e2bc52d97fa2118d82590e302ae3 (patch)
tree9e33f0b054cbc7b7545fc24d040f015eef0b89ca /sphinx/directives
parenta4efeb35deb15f9d27ad0a4f2d76195b8c993d84 (diff)
downloadsphinx-2ce5da1c1866e2bc52d97fa2118d82590e302ae3.tar.gz
versionlabels are handled entirely in the versionmodified directive, instead of the writers.
Now it returns a versionmodified node with the versionlabel already inserted.
Diffstat (limited to 'sphinx/directives')
-rw-r--r--sphinx/directives/other.py15
1 files changed, 10 insertions, 5 deletions
diff --git a/sphinx/directives/other.py b/sphinx/directives/other.py
index 40640415..50188ea4 100644
--- a/sphinx/directives/other.py
+++ b/sphinx/directives/other.py
@@ -14,7 +14,7 @@ from docutils.parsers.rst.directives.misc import Class
from docutils.parsers.rst.directives.misc import Include as BaseInclude
from sphinx import addnodes
-from sphinx.locale import _
+from sphinx.locale import versionlabels, _
from sphinx.util import url_re, docname_join
from sphinx.util.nodes import explicit_title_re, set_source_info, \
process_index_entry
@@ -190,19 +190,24 @@ class VersionChange(Directive):
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)
- node.extend(inodes)
- ret = [node] + messages
+ node.append(nodes.paragraph('', '', *inodes))
else:
- ret = [node]
+ messages = []
if self.content:
self.state.nested_parse(self.content, self.content_offset, node)
+ if len(node):
+ 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 ret
+ return [node] + messages
class SeeAlso(BaseAdmonition):