diff --git a/CHANGES b/CHANGES index 267afe9b1..9b966ab04 100644 --- a/CHANGES +++ b/CHANGES @@ -11,6 +11,9 @@ Changes in trunk * 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) ================================ diff --git a/sphinx/ext/autodoc.py b/sphinx/ext/autodoc.py index 9de0821c7..1356120d8 100644 --- a/sphinx/ext/autodoc.py +++ b/sphinx/ext/autodoc.py @@ -192,9 +192,20 @@ def _auto_directive(dirname, arguments, options, content, lineno, 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)