In nipype/utils/spm_docs.py, the function _strip_header() has the code:
try:
index = doc.index(hdr)
...
except KeyError as e:
raise_from(IOError('This docstring was not generated by Nipype!\n'), e)
However, doc doesn't seem to be a dict type so KeyError wouldn't apply here.
If hdr is not found in doc, that would raise a ValueError, which is not caught by the code here.
This was the error I got
index = doc.index(hdr)
ValueError: substring not found
Ubuntu 18