bpo-44544: [doc] list all textwrap func kwargs (GH-26999)

This commit is contained in:
Jack DeVries 2021-07-28 11:14:54 -04:00 committed by GitHub
parent 56c1f6d7ed
commit c1e39d6b11
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 4 deletions

View File

@ -17,7 +17,11 @@ If you're just wrapping or filling one or two text strings, the convenience
functions should be good enough; otherwise, you should use an instance of functions should be good enough; otherwise, you should use an instance of
:class:`TextWrapper` for efficiency. :class:`TextWrapper` for efficiency.
.. function:: wrap(text, width=70, **kwargs) .. function:: wrap(text, width=70, *, initial_indent="", \
subsequent_indent="", expand_tabs=True, \
replace_whitespace=True, fix_sentence_endings=False, \
break_long_words=True, drop_whitespace=True, \
break_on_hyphens=True, tabsize=8, max_lines=None)
Wraps the single paragraph in *text* (a string) so every line is at most Wraps the single paragraph in *text* (a string) so every line is at most
*width* characters long. Returns a list of output lines, without final *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
:func:`wrap` behaves. :func:`wrap` behaves.
.. function:: fill(text, width=70, **kwargs) .. function:: fill(text, width=70, *, initial_indent="", \
subsequent_indent="", expand_tabs=True, \
replace_whitespace=True, fix_sentence_endings=False, \
break_long_words=True, drop_whitespace=True, \
break_on_hyphens=True, tabsize=8, \
max_lines=None)
Wraps the single paragraph in *text*, and returns a single string containing the Wraps the single paragraph in *text*, and returns a single string containing the
wrapped paragraph. :func:`fill` is shorthand for :: wrapped paragraph. :func:`fill` is shorthand for ::
@ -41,7 +50,9 @@ functions should be good enough; otherwise, you should use an instance of
:func:`wrap`. :func:`wrap`.
.. function:: shorten(text, width, **kwargs) .. function:: shorten(text, width, *, fix_sentence_endings=False, \
break_long_words=True, break_on_hyphens=True, \
placeholder=' [...]')
Collapse and truncate the given *text* to fit in the given *width*. Collapse and truncate the given *text* to fit in the given *width*.
@ -65,7 +76,6 @@ functions should be good enough; otherwise, you should use an instance of
.. versionadded:: 3.4 .. versionadded:: 3.4
.. function:: dedent(text) .. function:: dedent(text)
Remove any common leading whitespace from every line in *text*. Remove any common leading whitespace from every line in *text*.

View File

@ -0,0 +1,4 @@
List all kwargs for :func:`textwrap.wrap`, :func:`textwrap.fill`, and
:func:`textwrap.shorten`. Now, there are nav links to attributes of
:class:`TextWrap`, which makes navigation much easier while minimizing
duplication in the documentation.