Skip to content

Commit

Permalink
Backport PR #12477: [sphinx] Fix regexp used in coqdomain.CoqtopBlock…
Browse files Browse the repository at this point in the history
…sTransform.split_lines
  • Loading branch information
Zimmi48 committed Jun 8, 2020
2 parents 01477d8 + 7cebf06 commit 91c065b
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions doc/tools/coqrst/coqdomain.py
Expand Up @@ -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"(?<=(?<!\.)\.)\s+\n", source)
return re.split(r"(?<=(?<!\.)\.)\n", source.strip())

@staticmethod
def parse_options(node):
Expand Down

0 comments on commit 91c065b

Please sign in to comment.