From 059765fa6c273af584ad255eb1395dea6f0e2307 Mon Sep 17 00:00:00 2001 From: Malcolm Tredinnick Date: Mon, 9 Mar 2009 01:37:17 +0000 Subject: [PATCH] Fixed #9436 -- Updated docs build code to create "new in development version". Patch from Marc Fargas. git-svn-id: http://code.djangoproject.com/svn/django/trunk@10006 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- docs/_ext/djangodocs.py | 31 +++++++++++++++++++++++++++++++ docs/conf.py | 2 ++ 2 files changed, 33 insertions(+) diff --git a/docs/_ext/djangodocs.py b/docs/_ext/djangodocs.py index bda7d3e4ce..65a823e10b 100644 --- a/docs/_ext/djangodocs.py +++ b/docs/_ext/djangodocs.py @@ -10,6 +10,8 @@ import sphinx.builder import sphinx.directives import sphinx.environment import sphinx.htmlwriter +import sphinx.roles +from docutils import nodes def setup(app): app.add_crossref_type( @@ -44,11 +46,40 @@ def setup(app): indextemplate = "pair: %s; django-admin command-line option", parse_node = lambda env, sig, signode: sphinx.directives.parse_option_desc(signode, sig), ) + app.add_config_value('django_next_version', '0.0', True) + app.add_directive('versionadded', parse_version_directive, 1, (1, 1, 1)) + app.add_directive('versionchanged', parse_version_directive, 1, (1, 1, 1)) app.add_transform(SuppressBlockquotes) # Monkeypatch PickleHTMLBuilder so that it doesn't die in Sphinx 0.4.2 if sphinx.__version__ == '0.4.2': monkeypatch_pickle_builder() + +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 = sphinx.addnodes.versionmodified() + ret.append(node) + if not is_nextversion: + if len(arguments) == 1: + linktext = 'Please, see the release notes ' % (arguments[0]) + xrefs = sphinx.roles.xfileref_role('ref', linktext, linktext, lineno, state) + 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 + class SuppressBlockquotes(docutils.transforms.Transform): """ diff --git a/docs/conf.py b/docs/conf.py index 0d41b053b2..f7ff45264f 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -44,6 +44,8 @@ copyright = 'Django Software Foundation and contributors' version = '1.0' # The full version, including alpha/beta/rc tags. release = version +# The next version to be released +django_next_version = '1.1' # There are two options for replacing |today|: either, you set today to some # non-false value, then it is used: