Ticket #10539: sphinx.diff
File sphinx.diff, 4.2 KB (added by , 16 years ago) |
---|
-
docs/_templates/layout.html
1 1 {% extends "!layout.html" %} 2 2 3 {%- macro secondnav %}3 {%- macro secondnav() %} 4 4 {%- if prev %} 5 5 « <a href="{{ prev.link|e }}" title="{{ prev.title|e }}">previous</a> 6 6 {{ reldelim2 }} -
docs/_ext/djangodocs.py
2 2 Sphinx plugins for Django documentation. 3 3 """ 4 4 5 import re 5 6 import docutils.nodes 6 7 import docutils.transforms 7 8 import sphinx … … 9 10 import sphinx.builder 10 11 import sphinx.directives 11 12 import sphinx.environment 12 import sphinx. htmlwriter13 import sphinx.writers.html 13 14 import sphinx.roles 14 15 from docutils import nodes 15 16 … … 44 45 directivename = "django-admin-option", 45 46 rolename = "djadminopt", 46 47 indextemplate = "pair: %s; django-admin command-line option", 47 parse_node = lambda env, sig, signode: sphinx.directives.parse_option_desc(signode, sig),48 parse_node = lambda env, sig, signode: parse_option_desc(signode, sig), 48 49 ) 49 50 app.add_config_value('django_next_version', '0.0', True) 50 51 app.add_directive('versionadded', parse_version_directive, 1, (1, 1, 1)) … … 55 56 if sphinx.__version__ == '0.4.2': 56 57 monkeypatch_pickle_builder() 57 58 59 option_desc_re = re.compile( 60 r'((?:/|-|--)[-_a-zA-Z0-9]+)(\s*.*?)(?=,\s+(?:/|-|--)|$)') 61 62 def parse_option_desc(signode, sig): 63 """Transform an option description into RST nodes.""" 64 count = 0 65 firstname = '' 66 for m in option_desc_re.finditer(sig): 67 optname, args = m.groups() 68 if count: 69 signode += sphinx.addnodes.desc_addname(', ', ', ') 70 signode += sphinx.addnodes.desc_name(optname, optname) 71 signode += sphinx.addnodes.desc_addname(args, args) 72 if not count: 73 firstname = optname 74 count += 1 75 if not firstname: 76 raise ValueError 77 return firstname 78 58 79 def parse_version_directive(name, arguments, options, content, lineno, 59 80 content_offset, block_text, state, state_machine): 60 81 env = state.document.settings.env … … 102 123 if len(node.children) == 1 and isinstance(node.children[0], self.suppress_blockquote_child_nodes): 103 124 node.replace_self(node.children[0]) 104 125 105 class DjangoHTMLTranslator(sphinx. htmlwriter.SmartyPantsHTMLTranslator):126 class DjangoHTMLTranslator(sphinx.writers.html.SmartyPantsHTMLTranslator): 106 127 """ 107 128 Django-specific reST to HTML tweaks. 108 129 """ … … 125 146 # 126 147 def visit_literal_block(self, node): 127 148 self.no_smarty += 1 128 sphinx. htmlwriter.SmartyPantsHTMLTranslator.visit_literal_block(self, node)149 sphinx.writers.html.SmartyPantsHTMLTranslator.visit_literal_block(self, node) 129 150 130 151 def depart_literal_block(self, node): 131 sphinx. htmlwriter.SmartyPantsHTMLTranslator.depart_literal_block(self, node)152 sphinx.writers.html.SmartyPantsHTMLTranslator.depart_literal_block(self, node) 132 153 self.no_smarty -= 1 133 154 134 155 # … … 162 183 # Give each section a unique ID -- nice for custom CSS hooks 163 184 # This is different on docutils 0.5 vs. 0.4... 164 185 165 if hasattr(sphinx. htmlwriter.SmartyPantsHTMLTranslator, 'start_tag_with_title') and sphinx.__version__ == '0.4.2':186 if hasattr(sphinx.writers.html.SmartyPantsHTMLTranslator, 'start_tag_with_title') and sphinx.__version__ == '0.4.2': 166 187 def start_tag_with_title(self, node, tagname, **atts): 167 188 node = { 168 189 'classes': node.get('classes', []), … … 176 197 node['ids'] = ['s-' + i for i in old_ids] 177 198 if sphinx.__version__ != '0.4.2': 178 199 node['ids'].extend(old_ids) 179 sphinx. htmlwriter.SmartyPantsHTMLTranslator.visit_section(self, node)200 sphinx.writers.html.SmartyPantsHTMLTranslator.visit_section(self, node) 180 201 node['ids'] = old_ids 181 202 182 203 def parse_django_admin_node(env, sig, signode):