Error in restructuredtext.py:307 - can't make reference docs
Brought to you by:
edloper
I'm getting an error when making my code documentation - even if I want to make the documentation for epydoc's __init__.py, it gives me the following error:
File "C:\Program Files\Python\lib\site-packages\epydoc\markup\restructuredtext.py", line 308, in visit_paragraph
m = self._SUMMARY_RE.match(child.data)
AttributeError: 'Text' object has no attribute 'data'
Could you please fix that? Adding a try-except-pass workaround will work for the moment:
try:
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
except:
pass
I get the same error using Python 2.6, docutils 0.5 and epydoc 3.0.1. As
far as I can tell, it is caused by a change in docutils `nodes.Text` API.
`Text` used to derive from `UserString`, which contains the mutable field
`data`. Epydoc is trying to access and modify this field, but in docutils 0.5
it no longer exists.
The following patch works for me. However, without knowing more about the
internals of Epydoc, I'm not sure if the last part of the patch is correct.
The problem is that I'm creating new `Text` nodes because the `str` base class of
the `Text` node is no longer mutable. By doing the next `Text` loses some
information stored in its base class `Node`, such as `Node.parent`.
------------------
307c307
< m = self._SUMMARY_RE.match(child.data)
---
> m = self._SUMMARY_RE.match(child)
310c310
< other = child.data[m.end():]
---
> other = child[m.end():]
492,495c492,495
< if child.data[:1] in ':-':
< child.data = child.data[1:].lstrip()
< elif child.data[:2] in (' -', ' :'):
< child.data = child.data[2:].lstrip()
---
> if child[:1] in ':-':
> fbody[0][0] = docutils.nodes.Text(child[1:].lstrip(), child.rawsource)
> elif child[:2] in (' -', ' :'):
> fbody[0][0] = docutils.nodes.Text(child[2:].lstrip(), child.rawsource)
------------------
Sorry, forgot to state that the patch is to be applied to epydoc\markup\restructuredtext.py