summaryrefslogtreecommitdiff
path: root/sphinx/ext/autosummary/generate.py
diff options
context:
space:
mode:
authorPauli Virtanen <pav@iki.fi>2011-06-29 21:27:56 +0200
committerPauli Virtanen <pav@iki.fi>2011-06-29 21:27:56 +0200
commita239643f0b4fd463732ed3f4a5454d24f5941653 (patch)
tree110749e9ce00cd52e4f0425ab6c6ffda99cf8705 /sphinx/ext/autosummary/generate.py
parente1be6ef8f8e42147416671dda215ef5f4c1cc65c (diff)
downloadsphinx-git-a239643f0b4fd463732ed3f4a5454d24f5941653.tar.gz
autosummary/generate: slightly more robust parsing in find_autosummary_in_lines
Skip non-content lines of autosummary:: directives, if they have a greater leading indent.
Diffstat (limited to 'sphinx/ext/autosummary/generate.py')
-rw-r--r--sphinx/ext/autosummary/generate.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/sphinx/ext/autosummary/generate.py b/sphinx/ext/autosummary/generate.py
index fecb5689a..089d181fc 100644
--- a/sphinx/ext/autosummary/generate.py
+++ b/sphinx/ext/autosummary/generate.py
@@ -232,7 +232,7 @@ def find_autosummary_in_lines(lines, module=None, filename=None):
*template* ``None`` if the directive does not have the
corresponding options set.
"""
- autosummary_re = re.compile(r'^\s*\.\.\s+autosummary::\s*')
+ autosummary_re = re.compile(r'^(\s*)\.\.\s+autosummary::\s*')
automodule_re = re.compile(
r'^\s*\.\.\s+automodule::\s*([A-Za-z0-9_.]+)\s*$')
module_re = re.compile(
@@ -247,6 +247,7 @@ def find_autosummary_in_lines(lines, module=None, filename=None):
template = None
current_module = module
in_autosummary = False
+ base_indent = ""
for line in lines:
if in_autosummary:
@@ -277,7 +278,7 @@ def find_autosummary_in_lines(lines, module=None, filename=None):
documented.append((name, toctree, template))
continue
- if not line.strip():
+ if not line.strip() or line.startswith(base_indent + " "):
continue
in_autosummary = False
@@ -285,6 +286,7 @@ def find_autosummary_in_lines(lines, module=None, filename=None):
m = autosummary_re.match(line)
if m:
in_autosummary = True
+ base_indent = m.group(1)
toctree = None
template = None
continue