[PATCH 1 of 2] help: strip doctest from dochelp
Yann E. MORIN
yann.morin.1998 at free.fr
Fri Mar 9 16:36:45 CST 2012
# HG changeset patch
# User "Yann E. MORIN" <yann.morin.1998 at free.fr>
# Date 1331330057 -3600
# Node ID de00e433c8be1b7538ee675c31905468603c31e8
# Parent 60cc3a0d224972e0fca00fe93f0488b5e4a60c7c
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 at free.fr>
diff --git a/mercurial/help.py b/mercurial/help.py
--- a/mercurial/help.py
+++ b/mercurial/help.py
@@ -94,8 +94,13 @@
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)
More information about the Mercurial-devel
mailing list