Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 9d19da7

Browse files
committed
merge 3.4 (#13223)
2 parents edb07d2 + ed1160b commit 9d19da7

4 files changed

Lines changed: 64 additions & 2 deletions

File tree

Lib/pydoc.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -593,10 +593,15 @@ def markup(self, text, escape=None, funcs={}, classes={}, methods={}):
593593
elif pep:
594594
url = 'http://www.python.org/dev/peps/pep-%04d/' % int(pep)
595595
results.append('<a href="%s">%s</a>' % (url, escape(all)))
596+
elif selfdot:
597+
# Create a link for methods like 'self.method(...)'
598+
# and use <strong> for attributes like 'self.attr'
599+
if text[end:end+1] == '(':
600+
results.append('self.' + self.namelink(name, methods))
601+
else:
602+
results.append('self.<strong>%s</strong>' % name)
596603
elif text[end:end+1] == '(':
597604
results.append(self.namelink(name, methods, funcs, classes))
598-
elif selfdot:
599-
results.append('self.<strong>%s</strong>' % name)
600605
else:
601606
results.append(self.namelink(name, classes))
602607
here = end

Lib/test/pydoc_mod.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,16 @@ class B(object):
1515
NO_MEANING = "eggs"
1616
pass
1717

18+
class C(object):
19+
def say_no(self):
20+
return "no"
21+
def get_answer(self):
22+
""" Return say_no() """
23+
return self.say_no()
24+
def is_it_true(self):
25+
""" Return self.get_answer() """
26+
return self.get_answer()
27+
1828
def doc_func():
1929
"""
2030
This function solves all of the world's problems:

Lib/test/test_pydoc.py

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
builtins.object
4848
A
4949
B
50+
C
5051
\x20\x20\x20\x20
5152
class A(builtins.object)
5253
| Hello and goodbye
@@ -74,6 +75,26 @@ class B(builtins.object)
7475
| Data and other attributes defined here:
7576
|\x20\x20
7677
| NO_MEANING = 'eggs'
78+
\x20\x20\x20\x20
79+
class C(builtins.object)
80+
| Methods defined here:
81+
|\x20\x20
82+
| get_answer(self)
83+
| Return say_no()
84+
|\x20\x20
85+
| is_it_true(self)
86+
| Return self.get_answer()
87+
|\x20\x20
88+
| say_no(self)
89+
|\x20\x20
90+
| ----------------------------------------------------------------------
91+
| Data descriptors defined here:
92+
|\x20\x20
93+
| __dict__
94+
| dictionary for instance variables (if defined)
95+
|\x20\x20
96+
| __weakref__
97+
| list of weak references to the object (if defined)
7798
7899
FUNCTIONS
79100
doc_func()
@@ -124,6 +145,7 @@ class B(builtins.object)
124145
<dl>
125146
<dt><font face="helvetica, arial"><a href="test.pydoc_mod.html#A">A</a>
126147
</font></dt><dt><font face="helvetica, arial"><a href="test.pydoc_mod.html#B">B</a>
148+
</font></dt><dt><font face="helvetica, arial"><a href="test.pydoc_mod.html#C">C</a>
127149
</font></dt></dl>
128150
</dd>
129151
</dl>
@@ -165,6 +187,28 @@ class B(builtins.object)
165187
Data and other attributes defined here:<br>
166188
<dl><dt><strong>NO_MEANING</strong> = 'eggs'</dl>
167189
190+
</td></tr></table> <p>
191+
<table width="100%%" cellspacing=0 cellpadding=2 border=0 summary="section">
192+
<tr bgcolor="#ffc8d8">
193+
<td colspan=3 valign=bottom>&nbsp;<br>
194+
<font color="#000000" face="helvetica, arial"><a name="C">class <strong>C</strong></a>(<a href="builtins.html#object">builtins.object</a>)</font></td></tr>
195+
\x20\x20\x20\x20
196+
<tr><td bgcolor="#ffc8d8"><tt>&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td>
197+
<td width="100%%">Methods defined here:<br>
198+
<dl><dt><a name="C-get_answer"><strong>get_answer</strong></a>(self)</dt><dd><tt>Return&nbsp;<a href="#C-say_no">say_no</a>()</tt></dd></dl>
199+
200+
<dl><dt><a name="C-is_it_true"><strong>is_it_true</strong></a>(self)</dt><dd><tt>Return&nbsp;self.<a href="#C-get_answer">get_answer</a>()</tt></dd></dl>
201+
202+
<dl><dt><a name="C-say_no"><strong>say_no</strong></a>(self)</dt></dl>
203+
204+
<hr>
205+
Data descriptors defined here:<br>
206+
<dl><dt><strong>__dict__</strong></dt>
207+
<dd><tt>dictionary&nbsp;for&nbsp;instance&nbsp;variables&nbsp;(if&nbsp;defined)</tt></dd>
208+
</dl>
209+
<dl><dt><strong>__weakref__</strong></dt>
210+
<dd><tt>list&nbsp;of&nbsp;weak&nbsp;references&nbsp;to&nbsp;the&nbsp;object&nbsp;(if&nbsp;defined)</tt></dd>
211+
</dl>
168212
</td></tr></table></td></tr></table><p>
169213
<table width="100%%" cellspacing=0 cellpadding=2 border=0 summary="section">
170214
<tr bgcolor="#eeaa77">

Misc/NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,9 @@ Library
9494

9595
- Issue #21515: tempfile.TemporaryFile now uses os.O_TMPFILE flag is available.
9696

97+
- Issue #13223: Fix pydoc.writedoc so that the HTML documentation for methods
98+
that use 'self' in the example code is generated correctly.
99+
97100
- Issue #21463: In urllib.request, fix pruning of the FTP cache.
98101

99102
- Issue #21618: The subprocess module could fail to close open fds that were

0 commit comments

Comments
 (0)