From 7f7b98d27b853b3c32277dfe0502f6955e29ba8d Mon Sep 17 00:00:00 2001 From: Adorilson Bezerra Date: Sat, 31 Jan 2026 21:00:49 +0000 Subject: [PATCH] gh-106318: Add doctest role for str.splitlines() examples --- Doc/library/stdtypes.rst | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst index ce0d7cbb2e4276..eb0fbf7108671a 100644 --- a/Doc/library/stdtypes.rst +++ b/Doc/library/stdtypes.rst @@ -2704,7 +2704,9 @@ expression support in the :mod:`re` module). ``\v`` and ``\f`` added to list of line boundaries. - For example:: + For example: + + .. doctest:: >>> 'ab c\n\nde fg\rkl\r\n'.splitlines() ['ab c', '', 'de fg', 'kl'] @@ -2713,14 +2715,18 @@ expression support in the :mod:`re` module). Unlike :meth:`~str.split` when a delimiter string *sep* is given, this method returns an empty list for the empty string, and a terminal line - break does not result in an extra line:: + break does not result in an extra line: + + .. doctest:: >>> "".splitlines() [] >>> "One line\n".splitlines() ['One line'] - For comparison, ``split('\n')`` gives:: + For comparison, ``split('\n')`` gives: + + .. doctest:: >>> ''.split('\n') ['']