From c6173746289b1791df8ee481001ebd5daac55f16 Mon Sep 17 00:00:00 2001 From: Adorilson Bezerra Date: Sat, 7 Feb 2026 22:24:44 +0000 Subject: [PATCH 1/4] gh-106318: Add doctest role for str.title() examples --- Doc/library/stdtypes.rst | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst index 0f20163e69509c..c26996c0e3d0e7 100644 --- a/Doc/library/stdtypes.rst +++ b/Doc/library/stdtypes.rst @@ -2801,7 +2801,9 @@ expression support in the :mod:`re` module). Return a titlecased version of the string where words start with an uppercase character and the remaining characters are lowercase. - For example:: + For example: + + .. doctest:: >>> 'Hello world'.title() 'Hello World' @@ -2809,7 +2811,9 @@ expression support in the :mod:`re` module). The algorithm uses a simple language-independent definition of a word as groups of consecutive letters. The definition works in many contexts but it means that apostrophes in contractions and possessives form word - boundaries, which may not be the desired result:: + boundaries, which may not be the desired result: + + .. doctest:: >>> "they're bill's friends from the UK".title() "They'Re Bill'S Friends From The Uk" @@ -2818,7 +2822,9 @@ expression support in the :mod:`re` module). splits words on spaces only. Alternatively, a workaround for apostrophes can be constructed using regular - expressions:: + expressions: + + .. doctest:: >>> import re >>> def titlecase(s): @@ -2829,7 +2835,7 @@ expression support in the :mod:`re` module). >>> titlecase("they're bill's friends.") "They're Bill's Friends." - See also :meth:`istitle`. + See also :meth:`istitle` and :meth:`capitalize`. .. method:: str.translate(table, /) From 0fba00779ae49274ca73eb19ca69b86e5b7e6d6c Mon Sep 17 00:00:00 2001 From: Adorilson Bezerra Date: Sun, 1 Mar 2026 18:29:53 +0000 Subject: [PATCH 2/4] Revert "gh-106318: Add doctest role for str.title() examples" This reverts commit c6173746289b1791df8ee481001ebd5daac55f16. --- Doc/library/stdtypes.rst | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst index c26996c0e3d0e7..0f20163e69509c 100644 --- a/Doc/library/stdtypes.rst +++ b/Doc/library/stdtypes.rst @@ -2801,9 +2801,7 @@ expression support in the :mod:`re` module). Return a titlecased version of the string where words start with an uppercase character and the remaining characters are lowercase. - For example: - - .. doctest:: + For example:: >>> 'Hello world'.title() 'Hello World' @@ -2811,9 +2809,7 @@ expression support in the :mod:`re` module). The algorithm uses a simple language-independent definition of a word as groups of consecutive letters. The definition works in many contexts but it means that apostrophes in contractions and possessives form word - boundaries, which may not be the desired result: - - .. doctest:: + boundaries, which may not be the desired result:: >>> "they're bill's friends from the UK".title() "They'Re Bill'S Friends From The Uk" @@ -2822,9 +2818,7 @@ expression support in the :mod:`re` module). splits words on spaces only. Alternatively, a workaround for apostrophes can be constructed using regular - expressions: - - .. doctest:: + expressions:: >>> import re >>> def titlecase(s): @@ -2835,7 +2829,7 @@ expression support in the :mod:`re` module). >>> titlecase("they're bill's friends.") "They're Bill's Friends." - See also :meth:`istitle` and :meth:`capitalize`. + See also :meth:`istitle`. .. method:: str.translate(table, /) From b4c06463d3c490fe9d2e51cd84533ae0b2913f26 Mon Sep 17 00:00:00 2001 From: Adorilson Bezerra Date: Sun, 1 Mar 2026 18:34:12 +0000 Subject: [PATCH 3/4] gh-106318: Add link to str.capitalize on the str.title() docs --- Doc/library/stdtypes.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst index 0f20163e69509c..d5ad4e57958fc7 100644 --- a/Doc/library/stdtypes.rst +++ b/Doc/library/stdtypes.rst @@ -2829,7 +2829,7 @@ expression support in the :mod:`re` module). >>> titlecase("they're bill's friends.") "They're Bill's Friends." - See also :meth:`istitle`. + See also :meth:`istitle` and :meth:`capitalize`. .. method:: str.translate(table, /) From 7b02fbb3fea026588001a12078f9358a510cd5df Mon Sep 17 00:00:00 2001 From: Adorilson Bezerra Date: Sun, 1 Mar 2026 19:35:40 +0000 Subject: [PATCH 4/4] gh106318: Fix wrong indentation on str.title() docs --- Doc/library/stdtypes.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst index d5ad4e57958fc7..b9d5b6cb322c59 100644 --- a/Doc/library/stdtypes.rst +++ b/Doc/library/stdtypes.rst @@ -2829,7 +2829,7 @@ expression support in the :mod:`re` module). >>> titlecase("they're bill's friends.") "They're Bill's Friends." - See also :meth:`istitle` and :meth:`capitalize`. + See also :meth:`istitle` and :meth:`capitalize`. .. method:: str.translate(table, /)