summaryrefslogtreecommitdiffstats
path: root/Lib/pydoc.py
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2014-06-07 23:44:00 (GMT)
committerBenjamin Peterson <benjamin@python.org>2014-06-07 23:44:00 (GMT)
commited1160b39c23c4b035b6c203cc6df53274d08939 (patch)
treecb26a22336a58700237f07d8c8fa1402ee8b0a0a /Lib/pydoc.py
parent3c2dca67ac9cdc26fb02473e05723486ffc8d52b (diff)
downloadcpython-ed1160b39c23c4b035b6c203cc6df53274d08939.zip
cpython-ed1160b39c23c4b035b6c203cc6df53274d08939.tar.gz
cpython-ed1160b39c23c4b035b6c203cc6df53274d08939.tar.bz2
don't remove self from example code in the HTML output (closes #13223)
Patch by Víctor Terrón.
Diffstat (limited to 'Lib/pydoc.py')
-rwxr-xr-xLib/pydoc.py9
1 files changed, 7 insertions, 2 deletions
diff --git a/Lib/pydoc.py b/Lib/pydoc.py
index 220a3cb..2dee6ee 100755
--- a/Lib/pydoc.py
+++ b/Lib/pydoc.py
@@ -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