[Python-checkins] r61789 - in doctools/trunk: CHANGES sphinx/ext/autodoc.py

georg.brandl python-checkins at python.org
Sun Mar 23 09:28:14 CET 2008


Author: georg.brandl
Date: Sun Mar 23 09:28:14 2008
New Revision: 61789

Modified:
   doctools/trunk/CHANGES
   doctools/trunk/sphinx/ext/autodoc.py
Log:
Render .. automodule:: docstrings in a section node, and
ignore section styles in the document, so that module docstrings
can contain proper sections.


Modified: doctools/trunk/CHANGES
==============================================================================
--- doctools/trunk/CHANGES	(original)
+++ doctools/trunk/CHANGES	Sun Mar 23 09:28:14 2008
@@ -11,6 +11,9 @@
 * sphinx.environment: Move doctest_blocks out of block_quotes to
   support indented doctest blocks.
 
+* sphinx.ext.autodoc: Render .. automodule:: docstrings in a setion
+  node, so that module docstrings can contain proper sectioning.
+
 
 Release 0.1.61611 (Mar 21, 2008)
 ================================

Modified: doctools/trunk/sphinx/ext/autodoc.py
==============================================================================
--- doctools/trunk/sphinx/ext/autodoc.py	(original)
+++ doctools/trunk/sphinx/ext/autodoc.py	Sun Mar 23 09:28:14 2008
@@ -192,9 +192,20 @@
     warnings, result = generate_rst(what, name, members, undoc, content,
                                     state.document, lineno)
 
-    node = nodes.paragraph()
-    state.nested_parse(result, content_offset, node)
-    return warnings + [node]
+    if dirname == 'automodule':
+        node = nodes.section()
+        # hack around title style bookkeeping
+        surrounding_title_styles = state.memo.title_styles
+        surrounding_section_level = state.memo.section_level
+        state.memo.title_styles = []
+        state.memo.section_level = 0
+        state.nested_parse(result, content_offset, node, match_titles=1)
+        state.memo.title_styles = surrounding_title_styles
+        state.memo.section_level = surrounding_section_level
+    else:
+        node = nodes.paragraph()
+        state.nested_parse(result, content_offset, node)
+    return warnings + node.children
 
 def auto_directive(*args, **kwds):
     return _auto_directive(*args, **kwds)


More information about the Python-checkins mailing list