mirror of https://github.com/python/cpython
gh-94318: Strip trailing spaces in pydoc text output (GH-94319)
This commit is contained in:
parent
f5c85aa3ee
commit
33fc3b5e42
|
@ -1171,8 +1171,7 @@ class TextDoc(Doc):
|
|||
def indent(self, text, prefix=' '):
|
||||
"""Indent text by prepending a given prefix to each line."""
|
||||
if not text: return ''
|
||||
lines = [prefix + line for line in text.split('\n')]
|
||||
if lines: lines[-1] = lines[-1].rstrip()
|
||||
lines = [(prefix + line).rstrip() for line in text.split('\n')]
|
||||
return '\n'.join(lines)
|
||||
|
||||
def section(self, title, contents):
|
||||
|
|
|
@ -4093,54 +4093,54 @@ Help on class Color in module %s:
|
|||
|
||||
class Color(enum.Enum)
|
||||
| Color(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)
|
||||
|\x20\x20
|
||||
|
|
||||
| Method resolution order:
|
||||
| Color
|
||||
| enum.Enum
|
||||
| builtins.object
|
||||
|\x20\x20
|
||||
|
|
||||
| Data and other attributes defined here:
|
||||
|\x20\x20
|
||||
|
|
||||
| CYAN = <Color.CYAN: 1>
|
||||
|\x20\x20
|
||||
|
|
||||
| MAGENTA = <Color.MAGENTA: 2>
|
||||
|\x20\x20
|
||||
|
|
||||
| YELLOW = <Color.YELLOW: 3>
|
||||
|\x20\x20
|
||||
|
|
||||
| ----------------------------------------------------------------------
|
||||
| Data descriptors inherited from enum.Enum:
|
||||
|\x20\x20
|
||||
|
|
||||
| name
|
||||
| The name of the Enum member.
|
||||
|\x20\x20
|
||||
|
|
||||
| value
|
||||
| The value of the Enum member.
|
||||
|\x20\x20
|
||||
|
|
||||
| ----------------------------------------------------------------------
|
||||
| Methods inherited from enum.EnumType:
|
||||
|\x20\x20
|
||||
|
|
||||
| __contains__(value) from enum.EnumType
|
||||
| Return True if `value` is in `cls`.
|
||||
|
|
||||
|
|
||||
| `value` is in `cls` if:
|
||||
| 1) `value` is a member of `cls`, or
|
||||
| 2) `value` is the value of one of the `cls`'s members.
|
||||
|\x20\x20
|
||||
|
|
||||
| __getitem__(name) from enum.EnumType
|
||||
| Return the member matching `name`.
|
||||
|\x20\x20
|
||||
|
|
||||
| __iter__() from enum.EnumType
|
||||
| Return members in definition order.
|
||||
|\x20\x20
|
||||
|
|
||||
| __len__() from enum.EnumType
|
||||
| Return the number of members (no aliases)
|
||||
|\x20\x20
|
||||
|
|
||||
| ----------------------------------------------------------------------
|
||||
| Readonly properties inherited from enum.EnumType:
|
||||
|\x20\x20
|
||||
|
|
||||
| __members__
|
||||
| Returns a mapping of member name->value.
|
||||
|\x20\x20\x20\x20\x20\x20
|
||||
|
|
||||
| This mapping lists all enum members, including aliases. Note that this
|
||||
| is a read-only view of the internal mapping."""
|
||||
|
||||
|
@ -4149,30 +4149,30 @@ Help on class Color in module %s:
|
|||
|
||||
class Color(enum.Enum)
|
||||
| Color(value, names=None, *, module=None, qualname=None, type=None, start=1)
|
||||
|\x20\x20
|
||||
|
|
||||
| Method resolution order:
|
||||
| Color
|
||||
| enum.Enum
|
||||
| builtins.object
|
||||
|\x20\x20
|
||||
|
|
||||
| Data and other attributes defined here:
|
||||
|\x20\x20
|
||||
|
|
||||
| YELLOW = <Color.YELLOW: 3>
|
||||
|\x20\x20
|
||||
|
|
||||
| MAGENTA = <Color.MAGENTA: 2>
|
||||
|\x20\x20
|
||||
|
|
||||
| CYAN = <Color.CYAN: 1>
|
||||
|\x20\x20
|
||||
|
|
||||
| ----------------------------------------------------------------------
|
||||
| Data descriptors inherited from enum.Enum:
|
||||
|\x20\x20
|
||||
|
|
||||
| name
|
||||
|\x20\x20
|
||||
|
|
||||
| value
|
||||
|\x20\x20
|
||||
|
|
||||
| ----------------------------------------------------------------------
|
||||
| Data descriptors inherited from enum.EnumType:
|
||||
|\x20\x20
|
||||
|
|
||||
| __members__"""
|
||||
|
||||
class TestStdLib(unittest.TestCase):
|
||||
|
|
|
@ -54,58 +54,58 @@ CLASSES
|
|||
A
|
||||
B
|
||||
C
|
||||
\x20\x20\x20\x20
|
||||
|
||||
class A(builtins.object)
|
||||
| Hello and goodbye
|
||||
|\x20\x20
|
||||
|
|
||||
| Methods defined here:
|
||||
|\x20\x20
|
||||
|
|
||||
| __init__()
|
||||
| Wow, I have no function!
|
||||
|\x20\x20
|
||||
|
|
||||
| ----------------------------------------------------------------------
|
||||
| Data descriptors defined here:
|
||||
|\x20\x20
|
||||
|
|
||||
| __dict__%s
|
||||
|\x20\x20
|
||||
|
|
||||
| __weakref__%s
|
||||
\x20\x20\x20\x20
|
||||
|
||||
class B(builtins.object)
|
||||
| Data descriptors defined here:
|
||||
|\x20\x20
|
||||
|
|
||||
| __dict__%s
|
||||
|\x20\x20
|
||||
|
|
||||
| __weakref__%s
|
||||
|\x20\x20
|
||||
|
|
||||
| ----------------------------------------------------------------------
|
||||
| Data and other attributes defined here:
|
||||
|\x20\x20
|
||||
|
|
||||
| NO_MEANING = 'eggs'
|
||||
|\x20\x20
|
||||
|
|
||||
| __annotations__ = {'NO_MEANING': <class 'str'>}
|
||||
\x20\x20\x20\x20
|
||||
|
||||
class C(builtins.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
|
||||
|
|
||||
| ----------------------------------------------------------------------
|
||||
| Class methods defined here:
|
||||
|\x20\x20
|
||||
|
|
||||
| __class_getitem__(item) from builtins.type
|
||||
|\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)
|
||||
|
||||
|
@ -115,7 +115,7 @@ FUNCTIONS
|
|||
hunger
|
||||
lack of Python
|
||||
war
|
||||
\x20\x20\x20\x20
|
||||
|
||||
nodoc_func()
|
||||
|
||||
DATA
|
||||
|
@ -235,16 +235,16 @@ Help on class DA in module %s:
|
|||
|
||||
class DA(builtins.object)
|
||||
| Data descriptors defined here:
|
||||
|\x20\x20
|
||||
|
|
||||
| __dict__%s
|
||||
|\x20\x20
|
||||
|
|
||||
| __weakref__%s
|
||||
|\x20\x20
|
||||
|
|
||||
| ham
|
||||
|\x20\x20
|
||||
|
|
||||
| ----------------------------------------------------------------------
|
||||
| Data and other attributes inherited from Meta:
|
||||
|\x20\x20
|
||||
|
|
||||
| ham = 'spam'
|
||||
""".strip()
|
||||
|
||||
|
@ -253,7 +253,7 @@ Help on class Class in module %s:
|
|||
|
||||
class Class(builtins.object)
|
||||
| Data and other attributes inherited from Meta:
|
||||
|\x20\x20
|
||||
|
|
||||
| LIFE = 42
|
||||
""".strip()
|
||||
|
||||
|
@ -262,7 +262,7 @@ Help on class Class1 in module %s:
|
|||
|
||||
class Class1(builtins.object)
|
||||
| Data and other attributes inherited from Meta1:
|
||||
|\x20\x20
|
||||
|
|
||||
| one = 1
|
||||
""".strip()
|
||||
|
||||
|
@ -274,19 +274,19 @@ class Class2(Class1)
|
|||
| Class2
|
||||
| Class1
|
||||
| builtins.object
|
||||
|\x20\x20
|
||||
|
|
||||
| Data and other attributes inherited from Meta1:
|
||||
|\x20\x20
|
||||
|
|
||||
| one = 1
|
||||
|\x20\x20
|
||||
|
|
||||
| ----------------------------------------------------------------------
|
||||
| Data and other attributes inherited from Meta3:
|
||||
|\x20\x20
|
||||
|
|
||||
| three = 3
|
||||
|\x20\x20
|
||||
|
|
||||
| ----------------------------------------------------------------------
|
||||
| Data and other attributes inherited from Meta2:
|
||||
|\x20\x20
|
||||
|
|
||||
| two = 2
|
||||
""".strip()
|
||||
|
||||
|
@ -295,7 +295,7 @@ Help on class C in module %s:
|
|||
|
||||
class C(builtins.object)
|
||||
| Data and other attributes defined here:
|
||||
|\x20\x20
|
||||
|
|
||||
| here = 'present!'
|
||||
""".strip()
|
||||
|
||||
|
@ -785,33 +785,33 @@ class B(A)
|
|||
| B
|
||||
| A
|
||||
| builtins.object
|
||||
|\x20\x20
|
||||
|
|
||||
| Methods defined here:
|
||||
|\x20\x20
|
||||
|
|
||||
| b_size = a_size(self)
|
||||
|\x20\x20
|
||||
|
|
||||
| itemconfig = itemconfigure(self, tagOrId, cnf=None, **kw)
|
||||
|\x20\x20
|
||||
|
|
||||
| itemconfigure(self, tagOrId, cnf=None, **kw)
|
||||
| Configure resources of an item TAGORID.
|
||||
|\x20\x20
|
||||
|
|
||||
| ----------------------------------------------------------------------
|
||||
| Methods inherited from A:
|
||||
|\x20\x20
|
||||
|
|
||||
| a_size(self)
|
||||
| Return size
|
||||
|\x20\x20
|
||||
|
|
||||
| lift = tkraise(self, aboveThis=None)
|
||||
|\x20\x20
|
||||
|
|
||||
| tkraise(self, aboveThis=None)
|
||||
| Raise this widget in the stacking order.
|
||||
|\x20\x20
|
||||
|
|
||||
| ----------------------------------------------------------------------
|
||||
| Data descriptors inherited from A:
|
||||
|\x20\x20
|
||||
|
|
||||
| __dict__
|
||||
| dictionary for instance variables (if defined)
|
||||
|\x20\x20
|
||||
|
|
||||
| __weakref__
|
||||
| list of weak references to the object (if defined)
|
||||
''' % __name__)
|
||||
|
@ -1180,7 +1180,7 @@ sm(x, y)
|
|||
""")
|
||||
self.assertIn("""
|
||||
| Static methods defined here:
|
||||
|\x20\x20
|
||||
|
|
||||
| sm(x, y)
|
||||
| A static method
|
||||
""", pydoc.plain(pydoc.render_doc(X)))
|
||||
|
@ -1201,7 +1201,7 @@ cm(x) method of builtins.type instance
|
|||
""")
|
||||
self.assertIn("""
|
||||
| Class methods defined here:
|
||||
|\x20\x20
|
||||
|
|
||||
| cm(x) from builtins.type
|
||||
| A class method
|
||||
""", pydoc.plain(pydoc.render_doc(X)))
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
Strip trailing spaces in :mod:`pydoc` text output.
|
Loading…
Reference in New Issue