Ticket #10539: 10539-sphinx06-compatibility.diff

File 10539-sphinx06-compatibility.diff, 4.9 KB (added by Ramiro Morales, 16 years ago)
  • docs/_ext/djangodocs.py

    diff --git a/docs/_ext/djangodocs.py b/docs/_ext/djangodocs.py
    a b  
    66import docutils.transforms
    77import sphinx
    88import sphinx.addnodes
    9 import sphinx.builder
     9try:
     10    from sphinx import builders
     11except ImportError:
     12    import sphinx.builder as builders
    1013import sphinx.directives
    1114import sphinx.environment
    12 import sphinx.htmlwriter
     15try:
     16    import sphinx.writers.html as sphinx_htmlwriter
     17except ImportError:
     18    import sphinx.htmlwriter as sphinx_htmlwriter
    1319import sphinx.roles
    1420from docutils import nodes
    1521
     
    4450        directivename = "django-admin-option",
    4551        rolename      = "djadminopt",
    4652        indextemplate = "pair: %s; django-admin command-line option",
    47         parse_node    = lambda env, sig, signode: sphinx.directives.parse_option_desc(signode, sig),
     53        parse_node    = parse_django_adminopt_node,
    4854    )
    4955    app.add_config_value('django_next_version', '0.0', True)
    5056    app.add_directive('versionadded', parse_version_directive, 1, (1, 1, 1))
     
    102108            if len(node.children) == 1 and isinstance(node.children[0], self.suppress_blockquote_child_nodes):
    103109                node.replace_self(node.children[0])
    104110
    105 class DjangoHTMLTranslator(sphinx.htmlwriter.SmartyPantsHTMLTranslator):
     111class DjangoHTMLTranslator(sphinx_htmlwriter.SmartyPantsHTMLTranslator):
    106112    """
    107113    Django-specific reST to HTML tweaks.
    108114    """
     
    125131    #
    126132    def visit_literal_block(self, node):
    127133        self.no_smarty += 1
    128         sphinx.htmlwriter.SmartyPantsHTMLTranslator.visit_literal_block(self, node)
    129        
     134        sphinx_htmlwriter.SmartyPantsHTMLTranslator.visit_literal_block(self, node)
     135
    130136    def depart_literal_block(self, node):
    131         sphinx.htmlwriter.SmartyPantsHTMLTranslator.depart_literal_block(self, node)
     137        sphinx_htmlwriter.SmartyPantsHTMLTranslator.depart_literal_block(self, node)
    132138        self.no_smarty -= 1
    133139       
    134140    #
     
    162168    # Give each section a unique ID -- nice for custom CSS hooks
    163169    # This is different on docutils 0.5 vs. 0.4...
    164170
    165     if hasattr(sphinx.htmlwriter.SmartyPantsHTMLTranslator, 'start_tag_with_title') and sphinx.__version__ == '0.4.2':
     171    if hasattr(sphinx_htmlwriter.SmartyPantsHTMLTranslator, 'start_tag_with_title') and sphinx.__version__ == '0.4.2':
    166172        def start_tag_with_title(self, node, tagname, **atts):
    167173            node = {
    168174                'classes': node.get('classes', []),
     
    176182            node['ids'] = ['s-' + i for i in old_ids]
    177183            if sphinx.__version__ != '0.4.2':
    178184                node['ids'].extend(old_ids)
    179             sphinx.htmlwriter.SmartyPantsHTMLTranslator.visit_section(self, node)
     185            sphinx_htmlwriter.SmartyPantsHTMLTranslator.visit_section(self, node)
    180186            node['ids'] = old_ids
    181187
    182188def parse_django_admin_node(env, sig, signode):
     
    186192    signode += sphinx.addnodes.desc_name(title, title)
    187193    return sig
    188194
     195def parse_django_adminopt_node(env, sig, signode):
     196    """A copy of sphinx.directives.CmdoptionDesc.parse_signature()"""
     197    from sphinx import addnodes
     198    from sphinx.directives.desc import option_desc_re
     199    count = 0
     200    firstname = ''
     201    for m in option_desc_re.finditer(sig):
     202        optname, args = m.groups()
     203        if count:
     204            signode += addnodes.desc_addname(', ', ', ')
     205        signode += addnodes.desc_name(optname, optname)
     206        signode += addnodes.desc_addname(args, args)
     207        if not count:
     208            firstname = optname
     209        count += 1
     210    if not firstname:
     211        raise ValueError
     212    return firstname
     213
    189214def monkeypatch_pickle_builder():
    190215    import shutil
    191216    from os import path
     
    214239
    215240        # copy the environment file from the doctree dir to the output dir
    216241        # as needed by the web app
    217         shutil.copyfile(path.join(self.doctreedir, sphinx.builder.ENV_PICKLE_FILENAME),
    218                         path.join(self.outdir, sphinx.builder.ENV_PICKLE_FILENAME))
     242        shutil.copyfile(path.join(self.doctreedir, builders.ENV_PICKLE_FILENAME),
     243                        path.join(self.outdir, builders.ENV_PICKLE_FILENAME))
    219244
    220245        # touch 'last build' file, used by the web application to determine
    221246        # when to reload its environment and clear the cache
    222         open(path.join(self.outdir, sphinx.builder.LAST_BUILD_FILENAME), 'w').close()
     247        open(path.join(self.outdir, builders.LAST_BUILD_FILENAME), 'w').close()
    223248
    224     sphinx.builder.PickleHTMLBuilder.handle_finish = handle_finish
    225    
     249    builders.PickleHTMLBuilder.handle_finish = handle_finish
     250
  • docs/_templates/layout.html

    diff --git a/docs/_templates/layout.html b/docs/_templates/layout.html
    a b  
    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 }}
Back to Top