Skip to content

Commit cb9812b

Browse files
committed
Add Doc for new CJK option and functions
1 parent 8337ce5 commit cb9812b

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed

Doc/library/textwrap.rst

+29
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,28 @@ functions should be good enough; otherwise, you should use an instance of
117117
.. versionadded:: 3.3
118118

119119

120+
.. function:: cjk_wide(char)
121+
122+
Return ``True`` if *char* is Fullwidth or Wide, ``False`` otherwise.
123+
Fullwidth and Wide CJK chars are double-width.
124+
125+
.. versionadded:: 3.7
126+
127+
128+
.. function:: cjk_len(text)
129+
130+
Return the real width of *text* (its len if not a string).
131+
132+
.. versionadded:: 3.7
133+
134+
135+
.. function:: cjk_slices(text, index)
136+
137+
Return the two slices of *text* cut to *index*.
138+
139+
.. versionadded:: 3.7
140+
141+
120142
:func:`wrap`, :func:`fill` and :func:`shorten` work by creating a
121143
:class:`TextWrapper` instance and calling a single method on it. That
122144
instance is not reused, so for applications that process many text
@@ -276,6 +298,13 @@ hyphenated words; only then will long words be broken if necessary, unless
276298
.. versionadded:: 3.4
277299

278300

301+
.. attribute:: cjk
302+
303+
(default: ``False``) Handle double-width CJK chars.
304+
305+
.. versionadded:: 3.7
306+
307+
279308
:class:`TextWrapper` also provides some public methods, analogous to the
280309
module-level convenience functions:
281310

Lib/textwrap.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,7 @@ def cjk_len(text):
440440

441441

442442
def cjk_slices(text, index):
443-
"""Return the two slices of text cut to the index.
443+
"""Return the two slices of text cut to index.
444444
"""
445445
if not isinstance(text, str):
446446
return text[:index], text[index:]

0 commit comments

Comments
 (0)