aboutsummaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorThéo Zimmermann2020-06-08 11:22:03 +0200
committerThéo Zimmermann2020-06-08 11:22:03 +0200
commit3b030bff4c10b8d25635913cdc037df35f142813 (patch)
treebdaa1955a1d352589cf92610484fcc113403b220 /doc
parent61744ac741b52d01467f3dec682b62fc241a95a5 (diff)
parent761261041ee4c0f44c536d4ea18037c1ccaed2a4 (diff)
Merge PR #12477: [sphinx] Fix regexp used in coqdomain.CoqtopBlocksTransform.split_lines
Reviewed-by: Zimmi48
Diffstat (limited to 'doc')
-rw-r--r--doc/tools/coqrst/coqdomain.py24
1 files changed, 22 insertions, 2 deletions
diff --git a/doc/tools/coqrst/coqdomain.py b/doc/tools/coqrst/coqdomain.py
index b0bbbf33b3..aec3607349 100644
--- a/doc/tools/coqrst/coqdomain.py
+++ b/doc/tools/coqrst/coqdomain.py
@@ -923,12 +923,32 @@ class CoqtopBlocksTransform(Transform):
@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"(?<=(?<!\.)\.)\s+\n", source)
+ return re.split(r"(?<=(?<!\.)\.)\n", source.strip())
@staticmethod
def parse_options(node):