diff -r 18f3582d965e docs/_ext/djangodocs.py
a
|
b
|
|
88 | 88 | if not is_nextversion: |
89 | 89 | if len(arguments) == 1: |
90 | 90 | linktext = 'Please, see the release notes <releases-%s>' % (arguments[0]) |
91 | | xrefs = sphinx.roles.xfileref_role('ref', linktext, linktext, lineno, state) |
| 91 | try: |
| 92 | xrefs = sphinx.roles.XRefRole()('ref', linktext, linktext, lineno, state) # Sphinx >= 1.0 |
| 93 | except: |
| 94 | xrefs = sphinx.roles.xfileref_role('ref', linktext, linktext, lineno, state) # Sphinx < 1.0 |
92 | 95 | node.extend(xrefs[0]) |
93 | 96 | node['version'] = arguments[0] |
94 | 97 | else: |
… |
… |
|
100 | 103 | if content: |
101 | 104 | state.nested_parse(content, content_offset, node) |
102 | 105 | ret = ret + messages |
103 | | env.note_versionchange(node['type'], node['version'], node, lineno) |
| 106 | if sphinx.__version__ >= '1.0': |
| 107 | env.versionchanges.setdefault(node['version'], []).append( |
| 108 | (node['type'], env.temp_data['docname'], lineno, |
| 109 | env.temp_data.get('py_module'), |
| 110 | env.temp_data.get('object'), |
| 111 | node.astext())) |
| 112 | else: |
| 113 | env.note_versionchange(node['type'], node['version'], node, lineno) |
104 | 114 | return ret |
105 | 115 | |
106 | | |
| 116 | |
107 | 117 | class SuppressBlockquotes(docutils.transforms.Transform): |
108 | 118 | """ |
109 | 119 | Remove the default blockquotes that encase indented list, tables, etc. |
110 | 120 | """ |
111 | 121 | default_priority = 300 |
112 | | |
| 122 | |
113 | 123 | suppress_blockquote_child_nodes = ( |
114 | | docutils.nodes.bullet_list, |
115 | | docutils.nodes.enumerated_list, |
| 124 | docutils.nodes.bullet_list, |
| 125 | docutils.nodes.enumerated_list, |
116 | 126 | docutils.nodes.definition_list, |
117 | | docutils.nodes.literal_block, |
118 | | docutils.nodes.doctest_block, |
119 | | docutils.nodes.line_block, |
| 127 | docutils.nodes.literal_block, |
| 128 | docutils.nodes.doctest_block, |
| 129 | docutils.nodes.line_block, |
120 | 130 | docutils.nodes.table |
121 | 131 | ) |
122 | | |
| 132 | |
123 | 133 | def apply(self): |
124 | 134 | for node in self.document.traverse(docutils.nodes.block_quote): |
125 | 135 | if len(node.children) == 1 and isinstance(node.children[0], self.suppress_blockquote_child_nodes): |
… |
… |
|
133 | 143 | # Don't use border=1, which docutils does by default. |
134 | 144 | def visit_table(self, node): |
135 | 145 | self.body.append(self.starttag(node, 'table', CLASS='docutils')) |
136 | | |
| 146 | |
137 | 147 | # <big>? Really? |
138 | 148 | def visit_desc_parameterlist(self, node): |
139 | 149 | self.body.append('(') |
140 | 150 | self.first_param = 1 |
141 | | |
| 151 | |
142 | 152 | def depart_desc_parameterlist(self, node): |
143 | 153 | self.body.append(')') |
144 | 154 | pass |
145 | | |
| 155 | |
146 | 156 | # |
147 | 157 | # Don't apply smartypants to literal blocks |
148 | 158 | # |
… |
… |
|
153 | 163 | def depart_literal_block(self, node): |
154 | 164 | sphinx_htmlwriter.SmartyPantsHTMLTranslator.depart_literal_block(self, node) |
155 | 165 | self.no_smarty -= 1 |
156 | | |
| 166 | |
157 | 167 | # |
158 | 168 | # Turn the "new in version" stuff (versoinadded/versionchanged) into a |
159 | 169 | # better callout -- the Sphinx default is just a little span, |
160 | 170 | # which is a bit less obvious that I'd like. |
161 | 171 | # |
162 | | # FIXME: these messages are all hardcoded in English. We need to chanage |
| 172 | # FIXME: these messages are all hardcoded in English. We need to change |
163 | 173 | # that to accomodate other language docs, but I can't work out how to make |
164 | 174 | # that work and I think it'll require Sphinx 0.5 anyway. |
165 | 175 | # |
… |
… |
|
168 | 178 | 'versionchanged': 'Changed in Django %s', |
169 | 179 | 'versionadded': 'New in Django %s', |
170 | 180 | } |
171 | | |
| 181 | |
172 | 182 | def visit_versionmodified(self, node): |
173 | 183 | self.body.append( |
174 | 184 | self.starttag(node, 'div', CLASS=node['type']) |
… |
… |
|
178 | 188 | len(node) and ":" or "." |
179 | 189 | ) |
180 | 190 | self.body.append('<span class="title">%s</span> ' % title) |
181 | | |
| 191 | |
182 | 192 | def depart_versionmodified(self, node): |
183 | 193 | self.body.append("</div>\n") |
184 | | |
| 194 | |
185 | 195 | # Give each section a unique ID -- nice for custom CSS hooks |
186 | 196 | # This is different on docutils 0.5 vs. 0.4... |
187 | 197 | |
188 | 198 | if hasattr(sphinx_htmlwriter.SmartyPantsHTMLTranslator, 'start_tag_with_title') and sphinx.__version__ == '0.4.2': |
189 | 199 | def start_tag_with_title(self, node, tagname, **atts): |
190 | 200 | node = { |
191 | | 'classes': node.get('classes', []), |
| 201 | 'classes': node.get('classes', []), |
192 | 202 | 'ids': ['s-%s' % i for i in node.get('ids', [])] |
193 | 203 | } |
194 | 204 | return self.starttag(node, tagname, **atts) |
… |
… |
|
212 | 222 | def parse_django_adminopt_node(env, sig, signode): |
213 | 223 | """A copy of sphinx.directives.CmdoptionDesc.parse_signature()""" |
214 | 224 | from sphinx import addnodes |
215 | | from sphinx.directives.desc import option_desc_re |
| 225 | try: |
| 226 | from sphinx.domains.std import option_desc_re # Sphinx >= 1.0 |
| 227 | except: |
| 228 | from sphinx.directives.desc import option_desc_re # Sphinx < 1.0 |
216 | 229 | count = 0 |
217 | 230 | firstname = '' |
218 | 231 | for m in option_desc_re.finditer(sig): |
… |
… |
|
235 | 248 | import cPickle as pickle |
236 | 249 | except ImportError: |
237 | 250 | import pickle |
238 | | |
| 251 | |
239 | 252 | def handle_finish(self): |
240 | 253 | # dump the global context |
241 | 254 | outfilename = path.join(self.outdir, 'globalcontext.pickle') |