Ticket #14005: 14005.diff
File 14005.diff, 7.3 KB (added by , 14 years ago) |
---|
-
docs/_ext/djangodocs.py
diff --git a/docs/_ext/djangodocs.py b/docs/_ext/djangodocs.py
a b 17 17 import os 18 18 import sphinx 19 19 import sphinx.addnodes 20 try: 21 from sphinx import builders 22 except ImportError: 23 import sphinx.builder as builders 24 try: 25 import sphinx.builders.html as builders_html 26 except ImportError: 27 builders_html = builders 20 import sphinx.builders.html as html_builder 28 21 from sphinx.util.console import bold 29 22 import sphinx.directives 30 23 import sphinx.environment 31 try: 32 import sphinx.writers.html as sphinx_htmlwriter 33 except ImportError: 34 import sphinx.htmlwriter as sphinx_htmlwriter 24 import sphinx.writers.html as sphinx_htmlwriter 35 25 import sphinx.roles 36 26 from docutils import nodes 37 27 … … 74 64 app.add_transform(SuppressBlockquotes) 75 65 app.add_builder(DjangoStandaloneHTMLBuilder) 76 66 77 # Monkeypatch PickleHTMLBuilder so that it doesn't die in Sphinx 0.4.278 if sphinx.__version__ == '0.4.2':79 monkeypatch_pickle_builder()80 81 67 def parse_version_directive(name, arguments, options, content, lineno, 82 68 content_offset, block_text, state, state_machine): 83 69 env = state.document.settings.env … … 106 92 env.note_versionchange(node['type'], node['version'], node, lineno) 107 93 return ret 108 94 109 95 110 96 class SuppressBlockquotes(docutils.transforms.Transform): 111 97 """ 112 98 Remove the default blockquotes that encase indented list, tables, etc. 113 99 """ 114 100 default_priority = 300 115 101 116 102 suppress_blockquote_child_nodes = ( 117 docutils.nodes.bullet_list, 118 docutils.nodes.enumerated_list, 103 docutils.nodes.bullet_list, 104 docutils.nodes.enumerated_list, 119 105 docutils.nodes.definition_list, 120 docutils.nodes.literal_block, 121 docutils.nodes.doctest_block, 122 docutils.nodes.line_block, 106 docutils.nodes.literal_block, 107 docutils.nodes.doctest_block, 108 docutils.nodes.line_block, 123 109 docutils.nodes.table 124 110 ) 125 111 126 112 def apply(self): 127 113 for node in self.document.traverse(docutils.nodes.block_quote): 128 114 if len(node.children) == 1 and isinstance(node.children[0], self.suppress_blockquote_child_nodes): … … 136 122 # Don't use border=1, which docutils does by default. 137 123 def visit_table(self, node): 138 124 self.body.append(self.starttag(node, 'table', CLASS='docutils')) 139 125 140 126 # <big>? Really? 141 127 def visit_desc_parameterlist(self, node): 142 128 self.body.append('(') 143 129 self.first_param = 1 144 130 145 131 def depart_desc_parameterlist(self, node): 146 132 self.body.append(')') 147 pass 148 133 149 134 # 150 135 # Don't apply smartypants to literal blocks 151 136 # … … 156 141 def depart_literal_block(self, node): 157 142 sphinx_htmlwriter.SmartyPantsHTMLTranslator.depart_literal_block(self, node) 158 143 self.no_smarty -= 1 159 144 160 145 # 161 # Turn the "new in version" stuff (vers oinadded/versionchanged) into a146 # Turn the "new in version" stuff (versionadded/versionchanged) into a 162 147 # better callout -- the Sphinx default is just a little span, 163 148 # which is a bit less obvious that I'd like. 164 149 # 165 150 # FIXME: these messages are all hardcoded in English. We need to change 166 151 # that to accomodate other language docs, but I can't work out how to make 167 # that work and I think it'll require Sphinx 0.5 anyway.152 # that work. 168 153 # 169 154 version_text = { 170 155 'deprecated': 'Deprecated in Django %s', 171 156 'versionchanged': 'Changed in Django %s', 172 157 'versionadded': 'New in Django %s', 173 158 } 174 159 175 160 def visit_versionmodified(self, node): 176 161 self.body.append( 177 162 self.starttag(node, 'div', CLASS=node['type']) … … 181 166 len(node) and ":" or "." 182 167 ) 183 168 self.body.append('<span class="title">%s</span> ' % title) 184 169 185 170 def depart_versionmodified(self, node): 186 171 self.body.append("</div>\n") 187 172 188 173 # Give each section a unique ID -- nice for custom CSS hooks 189 # This is different on docutils 0.5 vs. 0.4... 190 191 if hasattr(sphinx_htmlwriter.SmartyPantsHTMLTranslator, 'start_tag_with_title') and sphinx.__version__ == '0.4.2': 192 def start_tag_with_title(self, node, tagname, **atts): 193 node = { 194 'classes': node.get('classes', []), 195 'ids': ['s-%s' % i for i in node.get('ids', [])] 196 } 197 return self.starttag(node, tagname, **atts) 198 199 else: 200 def visit_section(self, node): 201 old_ids = node.get('ids', []) 202 node['ids'] = ['s-' + i for i in old_ids] 203 if sphinx.__version__ != '0.4.2': 204 node['ids'].extend(old_ids) 205 sphinx_htmlwriter.SmartyPantsHTMLTranslator.visit_section(self, node) 206 node['ids'] = old_ids 174 def visit_section(self, node): 175 old_ids = node.get('ids', []) 176 node['ids'] = ['s-' + i for i in old_ids] 177 node['ids'].extend(old_ids) 178 sphinx_htmlwriter.SmartyPantsHTMLTranslator.visit_section(self, node) 179 node['ids'] = old_ids 207 180 208 181 def parse_django_admin_node(env, sig, signode): 209 182 command = sig.split(' ')[0] … … 234 207 raise ValueError 235 208 return firstname 236 209 237 def monkeypatch_pickle_builder(): 238 import shutil 239 from os import path 240 try: 241 import cPickle as pickle 242 except ImportError: 243 import pickle 244 245 def handle_finish(self): 246 # dump the global context 247 outfilename = path.join(self.outdir, 'globalcontext.pickle') 248 f = open(outfilename, 'wb') 249 try: 250 pickle.dump(self.globalcontext, f, 2) 251 finally: 252 f.close() 253 254 self.info(bold('dumping search index...')) 255 self.indexer.prune(self.env.all_docs) 256 f = open(path.join(self.outdir, 'searchindex.pickle'), 'wb') 257 try: 258 self.indexer.dump(f, 'pickle') 259 finally: 260 f.close() 261 262 # copy the environment file from the doctree dir to the output dir 263 # as needed by the web app 264 shutil.copyfile(path.join(self.doctreedir, builders.ENV_PICKLE_FILENAME), 265 path.join(self.outdir, builders.ENV_PICKLE_FILENAME)) 266 267 # touch 'last build' file, used by the web application to determine 268 # when to reload its environment and clear the cache 269 open(path.join(self.outdir, builders.LAST_BUILD_FILENAME), 'w').close() 270 271 builders.PickleHTMLBuilder.handle_finish = handle_finish 272 273 274 class DjangoStandaloneHTMLBuilder(builders_html.StandaloneHTMLBuilder): 210 class DjangoStandaloneHTMLBuilder(html_builder.StandaloneHTMLBuilder): 275 211 """ 276 212 Subclass to add some extra things we need. 277 213 """ -
docs/internals/documentation.txt
diff --git a/docs/internals/documentation.txt b/docs/internals/documentation.txt
a b 15 15 To actually build the documentation locally, you'll currently need to install 16 16 Sphinx -- ``easy_install Sphinx`` should do the trick. 17 17 18 .. note:: 19 20 Generation of the Django documentation will work with Sphinx version 0.6 21 or newer, but we recommend going straigh to Sphinx 1.0 or newer. 22 18 23 Then, building the html is easy; just ``make html`` from the ``docs`` directory. 19 24 20 25 To get started contributing, you'll want to read the `ReStructuredText