[Python-checkins] r64715 - in doctools/branches/0.4.x: CHANGES sphinx/ext/autodoc.py
georg.brandl
python-checkins at python.org
Fri Jul 4 21:30:22 CEST 2008
Author: georg.brandl
Date: Fri Jul 4 21:30:22 2008
New Revision: 64715
Log:
Fix the delete() docstring processor function.
Modified:
doctools/branches/0.4.x/CHANGES
doctools/branches/0.4.x/sphinx/ext/autodoc.py
Modified: doctools/branches/0.4.x/CHANGES
==============================================================================
--- doctools/branches/0.4.x/CHANGES (original)
+++ doctools/branches/0.4.x/CHANGES Fri Jul 4 21:30:22 2008
@@ -14,15 +14,17 @@
can now write arbitrary "rubric" directives, and only those with
a title of "Footnotes" will be ignored.
-* Copy the HTML logo to the output "_static" directory.
+* Copy the HTML logo to the output ``_static`` directory.
* Fix LaTeX code for modules with underscores in names and platforms.
* Fix a crash with nonlocal image URIs.
-* Allow the usage of :noindex: in "automodule" directives, as
+* Allow the usage of :noindex: in ``automodule`` directives, as
documented.
+* Fix the ``delete()`` docstring processor function in autodoc.
+
Release 0.4 (Jun 23, 2008)
==========================
Modified: doctools/branches/0.4.x/sphinx/ext/autodoc.py
==============================================================================
--- doctools/branches/0.4.x/sphinx/ext/autodoc.py (original)
+++ doctools/branches/0.4.x/sphinx/ext/autodoc.py Fri Jul 4 21:30:22 2008
@@ -113,25 +113,33 @@
del lines[-post:]
return process
-def between(marker, what=None):
+def between(marker, what=None, keepempty=False):
"""
- Return a listener that only keeps lines between the first two lines that
- match the *marker* regular expression. If *what* is a sequence of strings,
- only docstrings of a type in *what* will be processed.
+ Return a listener that only keeps lines between lines that match the
+ *marker* regular expression. If no line matches, the resulting docstring
+ would be empty, so no change will be made unless *keepempty* is true.
+
+ If *what* is a sequence of strings, only docstrings of a type in *what* will
+ be processed.
"""
marker_re = re.compile(marker)
def process(app, what_, name, obj, options, lines):
if what and what_ not in what:
return
- seen = 0
- for i, line in enumerate(lines[:]):
+ deleted = 0
+ delete = True
+ orig_lines = lines[:]
+ for i, line in enumerate(orig_lines):
+ if delete:
+ lines.pop(i - deleted)
+ deleted += 1
if marker_re.match(line):
- if not seen:
- del lines[:i+1]
- seen = i+1
- else:
- del lines[i-seen:]
- break
+ delete = not delete
+ if delete:
+ lines.pop(i - deleted)
+ deleted += 1
+ if not lines and not keepempty:
+ lines[:] = orig_lines
return process
More information about the Python-checkins
mailing list