Skip to content

Commit 019a8b0

Browse files
bpo-44544: [doc] list all textwrap func kwargs (GH-26999) (GH-27425)
(cherry picked from commit c1e39d6) Co-authored-by: Jack DeVries <[email protected]>
1 parent debb751 commit 019a8b0

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

Doc/library/textwrap.rst

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,11 @@ If you're just wrapping or filling one or two text strings, the convenience
1717
functions should be good enough; otherwise, you should use an instance of
1818
:class:`TextWrapper` for efficiency.
1919

20-
.. function:: wrap(text, width=70, **kwargs)
20+
.. function:: wrap(text, width=70, *, initial_indent="", \
21+
subsequent_indent="", expand_tabs=True, \
22+
replace_whitespace=True, fix_sentence_endings=False, \
23+
break_long_words=True, drop_whitespace=True, \
24+
break_on_hyphens=True, tabsize=8, max_lines=None)
2125

2226
Wraps the single paragraph in *text* (a string) so every line is at most
2327
*width* characters long. Returns a list of output lines, without final
@@ -30,7 +34,12 @@ functions should be good enough; otherwise, you should use an instance of
3034
:func:`wrap` behaves.
3135

3236

33-
.. function:: fill(text, width=70, **kwargs)
37+
.. function:: fill(text, width=70, *, initial_indent="", \
38+
subsequent_indent="", expand_tabs=True, \
39+
replace_whitespace=True, fix_sentence_endings=False, \
40+
break_long_words=True, drop_whitespace=True, \
41+
break_on_hyphens=True, tabsize=8, \
42+
max_lines=None)
3443

3544
Wraps the single paragraph in *text*, and returns a single string containing the
3645
wrapped paragraph. :func:`fill` is shorthand for ::
@@ -41,7 +50,9 @@ functions should be good enough; otherwise, you should use an instance of
4150
:func:`wrap`.
4251

4352

44-
.. function:: shorten(text, width, **kwargs)
53+
.. function:: shorten(text, width, *, fix_sentence_endings=False, \
54+
break_long_words=True, break_on_hyphens=True, \
55+
placeholder=' [...]')
4556

4657
Collapse and truncate the given *text* to fit in the given *width*.
4758

@@ -65,7 +76,6 @@ functions should be good enough; otherwise, you should use an instance of
6576

6677
.. versionadded:: 3.4
6778

68-
6979
.. function:: dedent(text)
7080

7181
Remove any common leading whitespace from every line in *text*.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
List all kwargs for :func:`textwrap.wrap`, :func:`textwrap.fill`, and
2+
:func:`textwrap.shorten`. Now, there are nav links to attributes of
3+
:class:`TextWrap`, which makes navigation much easier while minimizing
4+
duplication in the documentation.

0 commit comments

Comments
 (0)