Anonymous avatar Anonymous committed 6d93c72

Make sphinx compatible with docutils SVN snapshots.

Comments (0)

Files changed (8)

-Changes in trunk
-================
+Release 0.1.61798 (Mar 23, 2008)
+================================
+
+* sphinx: Work with docutils SVN snapshots as well as 0.4.
 
 * sphinx.ext.doctest: Make the group in which doctest blocks are
   placed selectable, and default to ``'default'``.

doc/ext/doctest.rst

    They will be respected when the test is run, but stripped from presentation
    output.
 
-   .. versionadded:: 0.2
+   .. versionadded:: 0.1.61798
       Removal of ``<BLANKLINE>`` and inline options in presentation output.
 
 
 
 Sphinx needs at least **Python 2.4** to run.  If you like to have source code
 highlighting support, you must also install the Pygments_ library, which you can
-do via setuptools' easy_install.  Also, you need docutils version 0.4 (not some
-SVN trunk snapshot, because of incompatible API changes).
+do via setuptools' easy_install.  Sphinx should work with docutils version 0.4
+or some (not broken) SVN trunk snapshot.
 
 .. _reStructuredText: http://docutils.sf.net/rst.html
 .. _Pygments: http://pygments.org
             'sphinx-quickstart = sphinx.quickstart:main'
         ]
     },
-    install_requires=['Pygments>=0.8', 'docutils==0.4']
+    install_requires=['Pygments>=0.8', 'docutils>=0.4']
 )

sphinx/directives.py

 
 from docutils import nodes
 from docutils.parsers.rst import directives
-from docutils.parsers.rst.directives import admonitions
 
 from sphinx import addnodes
+from sphinx.util.compat import make_admonition
 
 # ------ index markup --------------------------------------------------------------
 
 
 def seealso_directive(name, arguments, options, content, lineno,
                       content_offset, block_text, state, state_machine):
-    rv = admonitions.make_admonition(
+    rv = make_admonition(
         addnodes.seealso, name, ['See also'], options, content,
         lineno, content_offset, block_text, state, state_machine)
     return rv

sphinx/ext/autodoc.py

         indent += '   '
 
     # add docstring content
-    if what == 'module' and env.config.automodule_skip_lines:
+    if what == 'module' and env.config.automodule_skip_lines and docstring:
         docstring = '\n'.join(docstring.splitlines()
                               [env.config.automodule_skip_lines:])
 
     # get the encoding of the docstring
     module = getattr(todoc, '__module__', None)
-    if module is not None:
+    if module is not None and docstring is not None:
         docstring = docstring.decode(get_module_charset(module))
 
     docstring = prepare_docstring(docstring)

sphinx/htmlwriter.py

         self.output = visitor.astext()
         for attr in ('head_prefix', 'stylesheet', 'head', 'body_prefix',
                      'body_pre_docinfo', 'docinfo', 'body', 'fragment',
-                     'body_suffix'):
-            setattr(self, attr, getattr(visitor, attr))
+                     'body_suffix', 'meta', 'title', 'subtitle', 'header',
+                     'footer', 'html_prolog', 'html_head', 'html_title',
+                     'html_subtitle', 'html_body', ):
+            setattr(self, attr, getattr(visitor, attr, None))
 
 
 version_text = {
 
     # overwritten
     def visit_admonition(self, node, name=''):
-        self.body.append(self.start_tag_with_title(
+        self.body.append(self.starttag(
             node, 'div', CLASS=('admonition ' + name)))
         if name and name != 'seealso':
             node.insert(0, nodes.title(name, self.language.labels[name]))
     def depart_seealso(self, node):
         self.depart_admonition(node)
 
-    # overwritten
-    def visit_title(self, node, move_ids=1):
+    # overwritten (args/kwds due to docutils 0.4/0.5 incompatibility)
+    def visit_title(self, node, *args, **kwds):
         # if we have a section we do our own processing in order
         # to have ids in the hN-tags and not in additional a-tags
         if isinstance(node.parent, nodes.section):
             self.body.append(self.starttag(node, 'h%d' % h_level, '', **attrs))
             self.context.append('</h%d>\n' % h_level)
         else:
-            BaseTranslator.visit_title(self, node, move_ids)
+            BaseTranslator.visit_title(self, node, *args, **kwds)
 
     # overwritten
     def visit_literal_block(self, node):
     def depart_module(self, node):
         pass
 
+    # docutils 0.5 compatibility
+    def visit_note(self, node):
+        self.visit_admonition(node, 'note')
+    def depart_note(self, node):
+        self.depart_admonition(node)
+
+    # docutils 0.5 compatibility
+    def visit_warning(self, node):
+        self.visit_admonition(node, 'warning')
+    def depart_warning(self, node):
+        self.depart_admonition(node)
+
     # these are only handled specially in the SmartyPantsHTMLTranslator
     def visit_literal_emphasis(self, node):
         return self.visit_emphasis(node)

sphinx/util/compat.py

+# -*- coding: utf-8 -*-
+"""
+    sphinx.util.compat
+    ~~~~~~~~~~~~~~~~~~
+
+    Stuff for docutils compatibility.
+
+    :copyright: 2008 by Georg Brandl.
+    :license: BSD.
+"""
+
+from docutils import nodes
+
+
+# function missing in 0.5 SVN
+def make_admonition(node_class, name, arguments, options, content, lineno,
+                    content_offset, block_text, state, state_machine):
+    if not content:
+        error = state_machine.reporter.error(
+            'The "%s" admonition is empty; content required.' % (name),
+            nodes.literal_block(block_text, block_text), line=lineno)
+        return [error]
+    text = '\n'.join(content)
+    admonition_node = node_class(text)
+    if arguments:
+        title_text = arguments[0]
+        textnodes, messages = state.inline_text(title_text, lineno)
+        admonition_node += nodes.title(title_text, '', *textnodes)
+        admonition_node += messages
+        if options.has_key('class'):
+            classes = options['class']
+        else:
+            classes = ['admonition-' + nodes.make_id(title_text)]
+        admonition_node['classes'] += classes
+    state.nested_parse(content, content_offset, admonition_node)
+    return [admonition_node]
+
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.