diff options
author | Benjamin Peterson <benjamin@python.org> | 2014-06-07 23:44:00 (GMT) |
---|---|---|
committer | Benjamin Peterson <benjamin@python.org> | 2014-06-07 23:44:00 (GMT) |
commit | ed1160b39c23c4b035b6c203cc6df53274d08939 (patch) | |
tree | cb26a22336a58700237f07d8c8fa1402ee8b0a0a /Lib/pydoc.py | |
parent | 3c2dca67ac9cdc26fb02473e05723486ffc8d52b (diff) | |
download | cpython-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-x | Lib/pydoc.py | 9 |
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 |