From 7cebf060720495962392bf324f75b4d03d43174e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Pit-Claudel?= Date: Sun, 7 Jun 2020 13:34:13 -0400 Subject: [PATCH] [sphinx] Fix regexp used in coqdomain.CoqtopBlocksTransform.split_lines (cherry picked from commit 761261041ee4c0f44c536d4ea18037c1ccaed2a4) --- doc/tools/coqrst/coqdomain.py | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/doc/tools/coqrst/coqdomain.py b/doc/tools/coqrst/coqdomain.py index b0bbbf33b308..aec36073491d 100644 --- a/doc/tools/coqrst/coqdomain.py +++ b/doc/tools/coqrst/coqdomain.py @@ -923,12 +923,32 @@ def is_coqtop_block(node): @staticmethod def split_lines(source): - """Split Coq input in chunks + r"""Split Coq input in chunks A chunk is a minimal sequence of consecutive lines of the input that ends with a '.' + + >>> split_lines('A.\nB.''') + ['A.', 'B.'] + + >>> split_lines('A.\n\nB.''') + ['A.', '\nB.'] + + >>> split_lines('A.\n\nB.\n''') + ['A.', '\nB.'] + + >>> split_lines("SearchPattern (_ + _ = _ + _).\n" + ... "SearchPattern (nat -> bool).\n" + ... "SearchPattern (forall l : list _, _ l l).") + ... # doctest: +NORMALIZE_WHITESPACE + ['SearchPattern (_ + _ = _ + _).', + 'SearchPattern (nat -> bool).', + 'SearchPattern (forall l : list _, _ l l).'] + + >>> split_lines('SearchHead le.\nSearchHead (@eq bool).') + ['SearchHead le.', 'SearchHead (@eq bool).'] """ - return re.split(r"(?<=(?