Here is the diff for the proposed patch, including a test case to show what is actually addressed. The crash and its fix have been tested against the docutils from their repository, svn version 5693. It may be a bug in docutils actually in which case this patch is just a workaround!
--- test/restructuredtext.doctest (revision 1810)
+++ test/restructuredtext.doctest (working copy)
@@ -80,6 +80,13 @@
... """)
(u'This is the first line.', True)
+>>> getsummary("""
+... exercise( (float)arg1) -> object :
+...
+... C++ signature :
+... boost::optional<int> exercise(boost::optional<double>)""")
+(u'exercise( (float)arg1) -> object :', True)
+
Python code
===========
reStructuredText markup defines a ``python`` directive to represent a block
Index: markup/restructuredtext.py
===================================================================
--- markup/restructuredtext.py (revision 1810)
+++ markup/restructuredtext.py (working copy)
@@ -308,7 +308,10 @@
# Extract the first sentence.
for child in node:
if isinstance(child, docutils.nodes.Text):
- m = self._SUMMARY_RE.match(child.data)
+ try:
+ m = self._SUMMARY_RE.match(child.data)
+ except AttributeError:
+ m = None
if m:
summary_pieces.append(docutils.nodes.Text(m.group(1)))
other = child.data[m.end():]
For completeness here is the traceback that this fix addresses:
File "/Users/luc/Developer/cctbx/cctbx_project/libtbx/command_line/epydoc_run.py", line 73, in <module>
run()
File "/Users/luc/Developer/cctbx/cctbx_project/libtbx/command_line/epydoc_run.py", line 70, in run
epydoc.cli.main(options)
File "/Users/luc/Developer/cctbx/cctbx_project/epydoc/cli.py", line 920, in main
inherit_from_object=inherit_from_object)
File "/Users/luc/Developer/cctbx/cctbx_project/epydoc/docbuilder.py", line 284, in build_doc_index
parse_docstring(val_doc, docindex, suppress_warnings)
File "/Users/luc/Developer/cctbx/cctbx_project/epydoc/docstringparser.py", line 265, in parse_docstring
api_doc.summary, api_doc.other_docs = api_doc.descr.summary()
File "/Users/luc/Developer/cctbx/cctbx_project/epydoc/markup/restructuredtext.py", line 181, in summary
try: self._document.walk(visitor)
File "/Users/luc/Developer/cctbx/docutils/docutils/nodes.py", line 135, in walk
if child.walk(visitor):
File "/Users/luc/Developer/cctbx/docutils/docutils/nodes.py", line 127, in walk
visitor.dispatch_visit(self)
File "/Users/luc/Developer/cctbx/docutils/docutils/nodes.py", line 1556, in dispatch_visit
return method(node)
File "/Users/luc/Developer/cctbx/cctbx_project/epydoc/markup/restructuredtext.py", line 315, in visit_paragraph
m = self._SUMMARY_RE.match(child.data)
I suggest this patch instead, because it does not rely on an exception.
--- epydoc/markup/restructuredtext.py 2008-01-28 19:15:33.000000000 +0100
+++ /home/black/files/restructuredtext.py 2009-12-21 11:19:20.000000000 +0100
@@ -304,13 +304,14 @@
# Extract the first sentence.
for child in node:
if isinstance(child, docutils.nodes.Text):
- m = self._SUMMARY_RE.match(child.data)
- if m:
- summary_pieces.append(docutils.nodes.Text(m.group(1)))
- other = child.data[m.end():]
- if other and not other.isspace():
- self.other_docs = True
- break
+ if hasattr(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():]
+ if other and not other.isspace():
+ self.other_docs = True
+ break
summary_pieces.append(child)
summary_doc = self.document.copy() # shallow copy