Ticket #10539: sphinx.diff

File sphinx.diff, 4.2 KB (added by Simon Blanchard, 15 years ago)
  • docs/_templates/layout.html

     
    11{% extends "!layout.html" %}
    22
    3 {%- macro secondnav %}
     3{%- macro secondnav() %}
    44  {%- if prev %}
    55    &laquo; <a href="{{ prev.link|e }}" title="{{ prev.title|e }}">previous</a>
    66    {{ reldelim2 }}
  • docs/_ext/djangodocs.py

     
    22Sphinx plugins for Django documentation.
    33"""
    44
     5import re
    56import docutils.nodes
    67import docutils.transforms
    78import sphinx
     
    910import sphinx.builder
    1011import sphinx.directives
    1112import sphinx.environment
    12 import sphinx.htmlwriter
     13import sphinx.writers.html
    1314import sphinx.roles
    1415from docutils import nodes
    1516
     
    4445        directivename = "django-admin-option",
    4546        rolename      = "djadminopt",
    4647        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),
    4849    )
    4950    app.add_config_value('django_next_version', '0.0', True)
    5051    app.add_directive('versionadded', parse_version_directive, 1, (1, 1, 1))
     
    5556    if sphinx.__version__ == '0.4.2':
    5657        monkeypatch_pickle_builder()
    5758
     59option_desc_re = re.compile(
     60    r'((?:/|-|--)[-_a-zA-Z0-9]+)(\s*.*?)(?=,\s+(?:/|-|--)|$)')
     61
     62def 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
    5879def parse_version_directive(name, arguments, options, content, lineno,
    5980                      content_offset, block_text, state, state_machine):
    6081    env = state.document.settings.env
     
    102123            if len(node.children) == 1 and isinstance(node.children[0], self.suppress_blockquote_child_nodes):
    103124                node.replace_self(node.children[0])
    104125
    105 class DjangoHTMLTranslator(sphinx.htmlwriter.SmartyPantsHTMLTranslator):
     126class DjangoHTMLTranslator(sphinx.writers.html.SmartyPantsHTMLTranslator):
    106127    """
    107128    Django-specific reST to HTML tweaks.
    108129    """
     
    125146    #
    126147    def visit_literal_block(self, node):
    127148        self.no_smarty += 1
    128         sphinx.htmlwriter.SmartyPantsHTMLTranslator.visit_literal_block(self, node)
     149        sphinx.writers.html.SmartyPantsHTMLTranslator.visit_literal_block(self, node)
    129150       
    130151    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)
    132153        self.no_smarty -= 1
    133154       
    134155    #
     
    162183    # Give each section a unique ID -- nice for custom CSS hooks
    163184    # This is different on docutils 0.5 vs. 0.4...
    164185
    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':
    166187        def start_tag_with_title(self, node, tagname, **atts):
    167188            node = {
    168189                'classes': node.get('classes', []),
     
    176197            node['ids'] = ['s-' + i for i in old_ids]
    177198            if sphinx.__version__ != '0.4.2':
    178199                node['ids'].extend(old_ids)
    179             sphinx.htmlwriter.SmartyPantsHTMLTranslator.visit_section(self, node)
     200            sphinx.writers.html.SmartyPantsHTMLTranslator.visit_section(self, node)
    180201            node['ids'] = old_ids
    181202
    182203def parse_django_admin_node(env, sig, signode):
Back to Top