~ubuntu-branches/ubuntu/quantal/python-django/quantal

« back to all changes in this revision

Viewing changes to debian/patches/05_10539-sphinx06-compatibility.diff

  • Committer: Bazaar Package Importer
  • Author(s): Chris Lamb
  • Date: 2009-07-29 11:26:28 UTC
  • mfrom: (1.1.8 upstream) (4.1.5 sid)
  • Revision ID: james.westby@ubuntu.com-20090729112628-pg09ino8sz0sj21t
Tags: 1.1-1
* New upstream release.
* Merge from experimental:
  - Ship FastCGI initscript and /etc/default file in python-django's examples
    directory (Closes: #538863)
  - Drop "05_10539-sphinx06-compatibility.diff"; it has been applied
    upstream.
  - Bump Standards-Version to 3.8.2.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
Forwarded-Upstream: not needed
2
 
Comment:
3
 
 Backported version of patch from <http://code.djangoproject.com/ticket/10539>
4
 
 to fix compatibility with python-sphinx >= 0.6. This patch should retain
5
 
 compatibility with 0.4 too.
6
 
 
7
 
diff -urNad a/docs/_ext/djangodocs.py b/docs/_ext/djangodocs.py
8
 
--- Django-1.0.2-final.orig/docs/_ext/djangodocs.py     2009-05-07 22:14:38.000000000 +0100
9
 
+++ Django-1.0.2-final/docs/_ext/djangodocs.py  2009-05-07 22:16:39.000000000 +0100
10
 
@@ -6,10 +6,16 @@
11
 
 import docutils.transforms
12
 
 import sphinx
13
 
 import sphinx.addnodes
14
 
-import sphinx.builder
15
 
+try:
16
 
+    from sphinx import builders
17
 
+except ImportError:
18
 
+    import sphinx.builder as builders
19
 
 import sphinx.directives
20
 
 import sphinx.environment
21
 
-import sphinx.htmlwriter
22
 
+try:
23
 
+    import sphinx.writers.html as sphinx_htmlwriter
24
 
+except ImportError:
25
 
+    import sphinx.htmlwriter as sphinx_htmlwriter
26
 
 
27
 
 def setup(app):
28
 
     app.add_crossref_type(
29
 
@@ -42,7 +48,7 @@
30
 
         directivename = "django-admin-option",
31
 
         rolename      = "djadminopt",
32
 
         indextemplate = "pair: %s; django-admin command-line option",
33
 
-        parse_node    = lambda env, sig, signode: sphinx.directives.parse_option_desc(signode, sig),
34
 
+        parse_node    = parse_django_adminopt_node,
35
 
     )
36
 
     app.add_transform(SuppressBlockquotes)
37
 
     
38
 
@@ -71,7 +77,7 @@
39
 
             if len(node.children) == 1 and isinstance(node.children[0], self.suppress_blockquote_child_nodes):
40
 
                 node.replace_self(node.children[0])
41
 
 
42
 
-class DjangoHTMLTranslator(sphinx.htmlwriter.SmartyPantsHTMLTranslator):
43
 
+class DjangoHTMLTranslator(sphinx_htmlwriter.SmartyPantsHTMLTranslator):
44
 
     """
45
 
     Django-specific reST to HTML tweaks.
46
 
     """
47
 
@@ -94,10 +100,10 @@
48
 
     #
49
 
     def visit_literal_block(self, node):
50
 
         self.no_smarty += 1
51
 
-        sphinx.htmlwriter.SmartyPantsHTMLTranslator.visit_literal_block(self, node)
52
 
+        sphinx_htmlwriter.SmartyPantsHTMLTranslator.visit_literal_block(self, node)
53
 
         
54
 
     def depart_literal_block(self, node):
55
 
-        sphinx.htmlwriter.SmartyPantsHTMLTranslator.depart_literal_block(self, node) 
56
 
+        sphinx_htmlwriter.SmartyPantsHTMLTranslator.depart_literal_block(self, node) 
57
 
         self.no_smarty -= 1
58
 
         
59
 
     #
60
 
@@ -132,7 +138,7 @@
61
 
     # This is different on docutils 0.5 vs. 0.4...
62
 
     
63
 
     # The docutils 0.4 override.
64
 
-    if hasattr(sphinx.htmlwriter.SmartyPantsHTMLTranslator, 'start_tag_with_title'):
65
 
+    if hasattr(sphinx_htmlwriter.SmartyPantsHTMLTranslator, 'start_tag_with_title'):
66
 
         def start_tag_with_title(self, node, tagname, **atts):
67
 
             node = {
68
 
                 'classes': node.get('classes', []), 
69
 
@@ -145,7 +151,7 @@
70
 
         def visit_section(self, node):
71
 
             old_ids = node.get('ids', [])
72
 
             node['ids'] = ['s-' + i for i in old_ids]
73
 
-            sphinx.htmlwriter.SmartyPantsHTMLTranslator.visit_section(self, node)
74
 
+            sphinx_htmlwriter.SmartyPantsHTMLTranslator.visit_section(self, node)
75
 
             node['ids'] = old_ids
76
 
 
77
 
 def parse_django_admin_node(env, sig, signode):
78
 
@@ -155,6 +161,25 @@
79
 
     signode += sphinx.addnodes.desc_name(title, title)
80
 
     return sig
81
 
 
82
 
+def parse_django_adminopt_node(env, sig, signode):
83
 
+    """A copy of sphinx.directives.CmdoptionDesc.parse_signature()"""
84
 
+    from sphinx import addnodes
85
 
+    from sphinx.directives.desc import option_desc_re
86
 
+    count = 0
87
 
+    firstname = ''
88
 
+    for m in option_desc_re.finditer(sig):
89
 
+        optname, args = m.groups()
90
 
+        if count:
91
 
+            signode += addnodes.desc_addname(', ', ', ')
92
 
+        signode += addnodes.desc_name(optname, optname)
93
 
+        signode += addnodes.desc_addname(args, args)
94
 
+        if not count:
95
 
+            firstname = optname
96
 
+        count += 1
97
 
+    if not firstname:
98
 
+        raise ValueError
99
 
+    return firstname
100
 
+
101
 
 def monkeypatch_pickle_builder():
102
 
     import shutil
103
 
     from os import path
104
 
@@ -183,12 +208,12 @@
105
 
 
106
 
         # copy the environment file from the doctree dir to the output dir
107
 
         # as needed by the web app
108
 
-        shutil.copyfile(path.join(self.doctreedir, sphinx.builder.ENV_PICKLE_FILENAME),
109
 
-                        path.join(self.outdir, sphinx.builder.ENV_PICKLE_FILENAME))
110
 
+        shutil.copyfile(path.join(self.doctreedir, builders.ENV_PICKLE_FILENAME),
111
 
+                        path.join(self.outdir, builders.ENV_PICKLE_FILENAME))
112
 
 
113
 
         # touch 'last build' file, used by the web application to determine
114
 
         # when to reload its environment and clear the cache
115
 
-        open(path.join(self.outdir, sphinx.builder.LAST_BUILD_FILENAME), 'w').close()
116
 
+        open(path.join(self.outdir, builders.LAST_BUILD_FILENAME), 'w').close()
117
 
 
118
 
-    sphinx.builder.PickleHTMLBuilder.handle_finish = handle_finish
119
 
+    builders.PickleHTMLBuilder.handle_finish = handle_finish
120
 
     
121
 
diff -urNad a/docs/_templates/layout.html b/docs/_templates/layout.html
122
 
--- a/docs/_templates/layout.html       2009-05-07 22:14:38.000000000 +0100
123
 
+++ b/docs/_templates/layout.html       2009-05-07 22:17:03.000000000 +0100
124
 
@@ -1,6 +1,6 @@
125
 
 {% extends "!layout.html" %}
126
 
 
127
 
-{%- macro secondnav %}
128
 
+{%- macro secondnav() %}
129
 
   {%- if prev %}
130
 
     &laquo; <a href="{{ prev.link|e }}" title="{{ prev.title|e }}">previous</a> 
131
 
     {{ reldelim2 }}