Commits

Yann E. MORIN  committed 684864d

help: strip doctest from dochelp

When a dochelp string contains doctest code, the doctest
code is not stripped, so the help also displays the doctest.

Just stop parsing dochelp at the first hint of a doctest
section (starting with >>>).

Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>

  • Participants
  • Parent commits 0d175ac

Comments (0)

Files changed (1)

File mercurial/help.py

             continue
         text = gettext(text)
         lines = text.splitlines()
-        lines[1:] = [('  ' + l.strip()) for l in lines[1:]]
-        entries.append('\n'.join(lines))
+        doclines = [(lines[0])]
+        for l in lines[1:]:
+            # Stop once we find some Python doctest
+            if l.strip().startswith('>>>'):
+                break
+            doclines.append('  ' + l.strip())
+        entries.append('\n'.join(doclines))
     entries = '\n\n'.join(entries)
     return doc.replace(marker, entries)