cpython: 7aa72075d440 (original) (raw)
Mercurial > cpython
changeset 91072:7aa72075d440 3.4
don't remove self from example code in the HTML output (closes #13223) Patch by Víctor Terrón. [#13223]
Benjamin Peterson benjamin@python.org | |
---|---|
date | Sat, 07 Jun 2014 16:44:00 -0700 |
parents | b8f9ae84d211 |
children | cddb17c4975e ddc174c4c7e5 |
files | Lib/pydoc.py Lib/test/pydoc_mod.py Lib/test/test_pydoc.py Misc/NEWS |
diffstat | 4 files changed, 64 insertions(+), 2 deletions(-)[+] [-] Lib/pydoc.py 9 Lib/test/pydoc_mod.py 10 Lib/test/test_pydoc.py 44 Misc/NEWS 3 |
line wrap: on
line diff
--- 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('%s' % (url, escape(all)))
elif selfdot:[](#l1.7)
# Create a link for methods like 'self.method(...)'[](#l1.8)
# and use <strong> for attributes like 'self.attr'[](#l1.9)
if text[end:end+1] == '(':[](#l1.10)
results.append('self.' + self.namelink(name, methods))[](#l1.11)
else:[](#l1.12)
results.append('self.<strong>%s</strong>' % name)[](#l1.13) elif text[end:end+1] == '(':[](#l1.14) results.append(self.namelink(name, methods, funcs, classes))[](#l1.15)
elif selfdot:[](#l1.16)
results.append('self.<strong>%s</strong>' % name)[](#l1.17) else:[](#l1.18) results.append(self.namelink(name, classes))[](#l1.19) here = end[](#l1.20)
--- a/Lib/test/pydoc_mod.py +++ b/Lib/test/pydoc_mod.py @@ -15,6 +15,16 @@ class B(object): NO_MEANING = "eggs" pass +class C(object):
- def say_no(self):
return "no"[](#l2.9)
- def get_answer(self):
""" Return say_no() """[](#l2.11)
return self.say_no()[](#l2.12)
- def is_it_true(self):
""" Return self.get_answer() """[](#l2.14)
return self.get_answer()[](#l2.15)
+ def doc_func(): """ This function solves all of the world's problems:
--- a/Lib/test/test_pydoc.py +++ b/Lib/test/test_pydoc.py @@ -47,6 +47,7 @@ CLASSES builtins.object A B
C[](#l3.7)
\x20\x20\x20\x20 class A(builtins.object) | Hello and goodbye @@ -74,6 +75,26 @@ CLASSES | Data and other attributes defined here: |\x20\x20 | NO_MEANING = 'eggs' +\x20\x20\x20\x20
- class C(builtins.object)
| Methods defined here:[](#l3.17)
|\x20\x20[](#l3.18)
| get_answer(self)[](#l3.19)
| Return say_no()[](#l3.20)
|\x20\x20[](#l3.21)
| is_it_true(self)[](#l3.22)
| Return self.get_answer()[](#l3.23)
|\x20\x20[](#l3.24)
| say_no(self)[](#l3.25)
|\x20\x20[](#l3.26)
| ----------------------------------------------------------------------[](#l3.27)
| Data descriptors defined here:[](#l3.28)
|\x20\x20[](#l3.29)
| __dict__[](#l3.30)
| dictionary for instance variables (if defined)[](#l3.31)
|\x20\x20[](#l3.32)
| __weakref__[](#l3.33)
| list of weak references to the object (if defined)[](#l3.34)
FUNCTIONS doc_func() @@ -124,6 +145,7 @@ expected_html_pattern = """
- A
- B +
- C
Data and other attributes defined here:
- NO_MEANING = 'eggs'
+class C(builtins.object) | ||
+ | Methods defined here: +
+Data descriptors defined here: + + |