don't remove self from example code in the HTML output (closes #13223)

Patch by Víctor Terrón.
This commit is contained in:
Benjamin Peterson 2014-06-07 16:44:00 -07:00
parent 3c2dca67ac
commit ed1160b39c
4 changed files with 64 additions and 2 deletions

View file

@ -595,10 +595,15 @@ class HTMLDoc(Doc):
elif pep:
url = 'http://www.python.org/dev/peps/pep-%04d/' % int(pep)
results.append('<a href="%s">%s</a>' % (url, escape(all)))
elif selfdot:
# Create a link for methods like 'self.method(...)'
# and use <strong> for attributes like 'self.attr'
if text[end:end+1] == '(':
results.append('self.' + self.namelink(name, methods))
else:
results.append('self.<strong>%s</strong>' % name)
elif text[end:end+1] == '(':
results.append(self.namelink(name, methods, funcs, classes))
elif selfdot:
results.append('self.<strong>%s</strong>' % name)
else:
results.append(self.namelink(name, classes))
here = end