diff -r 3ecddf168f1f Lib/pydoc.py --- a/Lib/pydoc.py Tue Nov 29 00:53:09 2011 +0100 +++ b/Lib/pydoc.py Tue Nov 29 05:47:21 2011 +0100 @@ -549,10 +549,16 @@ elif pep: url = 'http://www.python.org/dev/peps/pep-%04d/' % int(pep) results.append('%s' % (url, escape(all))) + elif selfdot: + # If what follows to 'self.' is a left parenthesis we have + # matched a method, so a link is added. Otherwise, the + # match is an instance attribute, rendered as strong text. + if text[end:end+1] == '(': + results.append('self.' + self.namelink(name, methods)) + else: + results.append('self.%s' % name) elif text[end:end+1] == '(': results.append(self.namelink(name, methods, funcs, classes)) - elif selfdot: - results.append('self.%s' % name) else: results.append(self.namelink(name, classes)) here = end diff -r 3ecddf168f1f Lib/test/pydoc_mod.py --- a/Lib/test/pydoc_mod.py Tue Nov 29 00:53:09 2011 +0100 +++ b/Lib/test/pydoc_mod.py Tue Nov 29 05:47:21 2011 +0100 @@ -15,6 +15,16 @@ NO_MEANING = "eggs" pass +class C(object): + def say_no(self): + return "no" + def get_answer(self): + """ Return say_no() """ + return self.say_no() + def is_it_true(self): + """ Return self.get_answer() """ + return self.get_answer() + def doc_func(): """ This function solves all of the world's problems: diff -r 3ecddf168f1f Lib/test/test_pydoc.py --- a/Lib/test/test_pydoc.py Tue Nov 29 00:53:09 2011 +0100 +++ b/Lib/test/test_pydoc.py Tue Nov 29 05:47:21 2011 +0100 @@ -27,6 +27,7 @@ CLASSES __builtin__.object B + C A \x20\x20\x20\x20 class A @@ -50,6 +51,26 @@ | Data and other attributes defined here: |\x20\x20 | NO_MEANING = 'eggs' +\x20\x20\x20\x20 + class C(__builtin__.object) + | Methods defined here: + |\x20\x20 + | get_answer(self) + | Return say_no() + |\x20\x20 + | is_it_true(self) + | Return self.get_answer() + |\x20\x20 + | say_no(self) + |\x20\x20 + | ---------------------------------------------------------------------- + | Data descriptors defined here: + |\x20\x20 + | __dict__ + | dictionary for instance variables (if defined) + |\x20\x20 + | __weakref__ + | list of weak references to the object (if defined) FUNCTIONS doc_func() @@ -96,6 +117,7 @@
B +
C
A @@ -130,6 +152,28 @@ Data and other attributes defined here:
NO_MEANING = 'eggs'
+

+ + + +\x20\x20\x20\x20 + +
 
+class C(__builtin__.object)
    Methods defined here:
+
get_answer(self)
Return say_no()
+ +
is_it_true(self)
Return self.get_answer()
+ +
say_no(self)
+ +
+Data descriptors defined here:
+
__dict__
+
dictionary for instance variables (if defined)
+
+
__weakref__
+
list of weak references to the object (if defined)
+