[Epydoc-commits] SF.net SVN: epydoc: [1574] trunk/epydoc/src/epydoc
Brought to you by:
edloper
|
From: <dva...@us...> - 2007-03-07 02:55:15
|
Revision: 1574
http://svn.sourceforge.net/epydoc/?rev=1574&view=rev
Author: dvarrazzo
Date: 2007-03-06 18:55:14 -0800 (Tue, 06 Mar 2007)
Log Message:
-----------
- Fixed summarization for plaintext markup.
If a docstring had one (or more) line not ending with a full stop, but
separated from the rest of the docstring by a blank line, and there was a
full stop somewhere in the following paragraphs, the docstring was summarized
up to the full stop instead of the blank line. Such docstrings appear in
many places in the stdlib.
- Test case added.
- Pre-compiling the regular expression to recognize the summary.
Modified Paths:
--------------
trunk/epydoc/src/epydoc/markup/epytext.py
trunk/epydoc/src/epydoc/markup/javadoc.py
trunk/epydoc/src/epydoc/markup/plaintext.py
trunk/epydoc/src/epydoc/markup/restructuredtext.py
trunk/epydoc/src/epydoc/test/plaintext.doctest
Modified: trunk/epydoc/src/epydoc/markup/epytext.py
===================================================================
--- trunk/epydoc/src/epydoc/markup/epytext.py 2007-03-07 01:26:50 UTC (rev 1573)
+++ trunk/epydoc/src/epydoc/markup/epytext.py 2007-03-07 02:55:14 UTC (rev 1574)
@@ -1969,6 +1969,8 @@
# Assume that anything else can be passed through.
return childstr
+ _SUMMARY_RE = re.compile(r'(\s*[\w\W]*?\.)(\s|$)')
+
def summary(self):
if self._tree is None: return self, False
tree = self._tree
@@ -2008,7 +2010,7 @@
doc.children.append(para)
for parachild in parachildren:
if isinstance(parachild, basestring):
- m = re.match(r'(\s*[\w\W]*?\.)(\s|$)', parachild)
+ m = self._SUMMARY_RE.match(parachild)
if m:
para.children.append(m.group(1))
long_docs |= parachild is not parachildren[-1]
Modified: trunk/epydoc/src/epydoc/markup/javadoc.py
===================================================================
--- trunk/epydoc/src/epydoc/markup/javadoc.py 2007-03-07 01:26:50 UTC (rev 1573)
+++ trunk/epydoc/src/epydoc/markup/javadoc.py 2007-03-07 02:55:14 UTC (rev 1574)
@@ -219,13 +219,15 @@
def to_plaintext(self, docstring_linker, **options):
return self._docstring
+ _SUMMARY_RE = re.compile(r'(\s*[\w\W]*?\.)(\s|$)')
+
# Jeff's hack to get summary working
def summary(self):
# Drop tags
doc = "\n".join([ row for row in self._docstring.split('\n')
if not row.lstrip().startswith('@') ])
- m = re.match(r'(\s*[\w\W]*?\.)(\s|$)', doc)
+ m = self._SUMMARY_RE.match(doc)
if m:
other = doc[m.end():]
return (ParsedJavadocDocstring(m.group(1)),
Modified: trunk/epydoc/src/epydoc/markup/plaintext.py
===================================================================
--- trunk/epydoc/src/epydoc/markup/plaintext.py 2007-03-07 01:26:50 UTC (rev 1573)
+++ trunk/epydoc/src/epydoc/markup/plaintext.py 2007-03-07 02:55:14 UTC (rev 1574)
@@ -50,8 +50,10 @@
return '\n'.join([' '*indent+l for l in lines])+'\n'
return self._text+'\n'
+ _SUMMARY_RE = re.compile(r'(\s*[\w\W]*?(?:\.(\s|$)|[\n][\t ]*[\n]))')
+
def summary(self):
- m = re.match(r'(\s*[\w\W]*?\.)(\s|$)', self._text)
+ m = self._SUMMARY_RE.match(self._text)
if m:
other = self._text[m.end():]
return (ParsedPlaintextDocstring(m.group(1), verbatim=0),
Modified: trunk/epydoc/src/epydoc/markup/restructuredtext.py
===================================================================
--- trunk/epydoc/src/epydoc/markup/restructuredtext.py 2007-03-07 01:26:50 UTC (rev 1573)
+++ trunk/epydoc/src/epydoc/markup/restructuredtext.py 2007-03-07 02:55:14 UTC (rev 1574)
@@ -291,6 +291,7 @@
def visit_document(self, node):
self.summary = None
+ _SUMMARY_RE = re.compile(r'(\s*[\w\W]*?\.)(\s|$)')
def visit_paragraph(self, node):
if self.summary is not None:
# found a paragraph after the first one
@@ -302,7 +303,7 @@
# Extract the first sentence.
for child in node:
if isinstance(child, docutils.nodes.Text):
- m = re.match(r'(\s*[\w\W]*?\.)(\s|$)', child.data)
+ m = self._SUMMARY_RE.match(child.data)
if m:
summary_pieces.append(docutils.nodes.Text(m.group(1)))
other = child.data[m.end():]
Modified: trunk/epydoc/src/epydoc/test/plaintext.doctest
===================================================================
--- trunk/epydoc/src/epydoc/test/plaintext.doctest 2007-03-07 01:26:50 UTC (rev 1573)
+++ trunk/epydoc/src/epydoc/test/plaintext.doctest 2007-03-07 02:55:14 UTC (rev 1574)
@@ -52,3 +52,19 @@
... This is detached
... """)
('Other lines without period...', True)
+
+In 3.0beta1 docstrings such this were not correctly summarized.
+
+>>> getsummary("""A user-defined wrapper around string objects
+...
+... Note: string objects have grown methods in Python 1.6
+... This module requires Python 1.6 or later.
+... """)
+('A user-defined wrapper around string objects', True)
+
+>>> getsummary("""This is more tricky
+... than the test before
+...
+... but i am looking for the same bug.
+... """)
+('This is more tricky\nthan the test before', True)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|