55
66 Sphinx extension with Python doc-specific markup.
77
8- :copyright: 2008-2013 by Georg Brandl.
8+ :copyright: 2008-2014 by Georg Brandl.
99 :license: Python license.
1010"""
1111
@@ -145,8 +145,6 @@ def run(self):
145145from sphinx .locale import versionlabels
146146from sphinx .util .compat import Directive
147147
148- versionlabels ['deprecated-removed' ] = \
149- 'Deprecated since version %s, will be removed in version %s'
150148
151149class DeprecatedRemoved (Directive ):
152150 has_content = True
@@ -155,24 +153,40 @@ class DeprecatedRemoved(Directive):
155153 final_argument_whitespace = True
156154 option_spec = {}
157155
156+ _label = 'Deprecated since version %s, will be removed in version %s'
157+
158158 def run (self ):
159159 node = addnodes .versionmodified ()
160160 node .document = self .state .document
161161 node ['type' ] = 'deprecated-removed'
162162 version = (self .arguments [0 ], self .arguments [1 ])
163163 node ['version' ] = version
164+ text = self ._label % version
164165 if len (self .arguments ) == 3 :
165166 inodes , messages = self .state .inline_text (self .arguments [2 ],
166167 self .lineno + 1 )
167- node .extend (inodes )
168- if self .content :
169- self .state .nested_parse (self .content , self .content_offset , node )
170- ret = [node ] + messages
168+ para = nodes .paragraph (self .arguments [2 ], '' , * inodes )
169+ node .append (para )
170+ else :
171+ messages = []
172+ if self .content :
173+ self .state .nested_parse (self .content , self .content_offset , node )
174+ if len (node ):
175+ if isinstance (node [0 ], nodes .paragraph ) and node [0 ].rawsource :
176+ content = nodes .inline (node [0 ].rawsource , translatable = True )
177+ content .source = node [0 ].source
178+ content .line = node [0 ].line
179+ content += node [0 ].children
180+ node [0 ].replace_self (nodes .paragraph ('' , '' , content ))
181+ node [0 ].insert (0 , nodes .inline ('' , '%s: ' % text ,
182+ classes = ['versionmodified' ]))
171183 else :
172- ret = [node ]
184+ para = nodes .paragraph ('' , '' ,
185+ nodes .inline ('' , '%s.' % text , classes = ['versionmodified' ]))
186+ node .append (para )
173187 env = self .state .document .settings .env
174188 env .note_versionchange ('deprecated' , version [0 ], node , self .lineno )
175- return ret
189+ return [ node ] + messages
176190
177191
178192# Support for including Misc/NEWS
0 commit comments