comparison mercurial/help.py @ 16250:684864d54903

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>
author "Yann E. MORIN" <yann.morin.1998@free.fr>
date Fri, 09 Mar 2012 22:54:17 +0100
parents 0c4bec9596d8
children 23072be2eaa3
comparison
equal deleted inserted replaced
16249:0d175ac527c1 16250:684864d54903
92 text = (items[name].__doc__ or '').rstrip() 92 text = (items[name].__doc__ or '').rstrip()
93 if not text: 93 if not text:
94 continue 94 continue
95 text = gettext(text) 95 text = gettext(text)
96 lines = text.splitlines() 96 lines = text.splitlines()
97 lines[1:] = [(' ' + l.strip()) for l in lines[1:]] 97 doclines = [(lines[0])]
98 entries.append('\n'.join(lines)) 98 for l in lines[1:]:
99 # Stop once we find some Python doctest
100 if l.strip().startswith('>>>'):
101 break
102 doclines.append(' ' + l.strip())
103 entries.append('\n'.join(doclines))
99 entries = '\n\n'.join(entries) 104 entries = '\n\n'.join(entries)
100 return doc.replace(marker, entries) 105 return doc.replace(marker, entries)
101 106
102 def addtopicsymbols(topic, marker, symbols): 107 def addtopicsymbols(topic, marker, symbols):
103 def add(topic, doc): 108 def add(topic, doc):