summaryrefslogtreecommitdiff
path: root/docs/_ext/djangodocs.py
diff options
context:
space:
mode:
authorJacob Kaplan-Moss <jacob@jacobian.org>2008-09-02 03:40:42 +0000
committerJacob Kaplan-Moss <jacob@jacobian.org>2008-09-02 03:40:42 +0000
commit64a94691277db17e87614f125d8da78a9995076b (patch)
tree8850007d024ada1901a8965c01e7c6f74ebe0172 /docs/_ext/djangodocs.py
parentc435975cc779a4549591a1c2b32e91f409c33757 (diff)
downloaddjango-64a94691277db17e87614f125d8da78a9995076b.tar.gz
Fixed #8753: converted "new in ..." callouts to proper Sphinx "versionadded/versionchanged" directives. Thanks to Marc Fargas for all the heavy lifting here.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@8843 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'docs/_ext/djangodocs.py')
-rw-r--r--docs/_ext/djangodocs.py28
1 files changed, 28 insertions, 0 deletions
diff --git a/docs/_ext/djangodocs.py b/docs/_ext/djangodocs.py
index 61561e7972..560cae7ac7 100644
--- a/docs/_ext/djangodocs.py
+++ b/docs/_ext/djangodocs.py
@@ -88,6 +88,34 @@ class DjangoHTMLTranslator(sphinx.htmlwriter.SmartyPantsHTMLTranslator):
def depart_desc_parameterlist(self, node):
self.body.append(')')
pass
+
+ #
+ # Turn the "new in version" stuff (versoinadded/versionchanged) into a
+ # better callout -- the Sphinx default is just a little span,
+ # which is a bit less obvious that I'd like.
+ #
+ # FIXME: these messages are all hardcoded in English. We need to chanage
+ # that to accomodate other language docs, but I can't work out how to make
+ # that work and I think it'll require Sphinx 0.5 anyway.
+ #
+ version_text = {
+ 'deprecated': 'Deprecated in Django %s',
+ 'versionchanged': 'Changed in Django %s',
+ 'versionadded': 'New in Django %s',
+ }
+
+ def visit_versionmodified(self, node):
+ self.body.append(
+ self.starttag(node, 'div', CLASS=node['type'])
+ )
+ title = "%s%s" % (
+ self.version_text[node['type']] % node['version'],
+ len(node) and ":" or "."
+ )
+ self.body.append('<span class="title">%s</span> ' % title)
+
+ def depart_versionmodified(self, node):
+ self.body.append("</div>\n")
# Give each section a unique ID -- nice for custom CSS hooks
# This is different on docutils 0.5 vs. 0.4...