comparison mercurial/help.py @ 27323:0fe93498ef07

help: refactor filtercmd
author timeless <timeless@mozdev.org>
date Wed, 09 Dec 2015 19:09:06 +0000
parents ac27b1b3be85
children 5456374561a7
comparison
equal deleted inserted replaced
27322:84e85f461b79 27323:0fe93498ef07
81 81
82 def indicateomitted(rst, omitted, notomitted=None): 82 def indicateomitted(rst, omitted, notomitted=None):
83 rst.append('\n\n.. container:: omitted\n\n %s\n\n' % omitted) 83 rst.append('\n\n.. container:: omitted\n\n %s\n\n' % omitted)
84 if notomitted: 84 if notomitted:
85 rst.append('\n\n.. container:: notomitted\n\n %s\n\n' % notomitted) 85 rst.append('\n\n.. container:: notomitted\n\n %s\n\n' % notomitted)
86
87 def filtercmd(ui, cmd, kw, doc):
88 if not ui.debugflag and cmd.startswith("debug") and kw != "debug":
89 return True
90 if not ui.verbose and doc and any(w in doc for w in _exclkeywords):
91 return True
92 return False
86 93
87 def topicmatch(ui, kw): 94 def topicmatch(ui, kw):
88 """Return help topics matching kw. 95 """Return help topics matching kw.
89 96
90 Returns {'section': [(name, summary), ...], ...} where section is 97 Returns {'section': [(name, summary), ...], ...} where section is
338 e[0].__module__ != commands.__name__): 345 e[0].__module__ != commands.__name__):
339 continue 346 continue
340 if name == "shortlist" and not f.startswith("^"): 347 if name == "shortlist" and not f.startswith("^"):
341 continue 348 continue
342 f = f.lstrip("^") 349 f = f.lstrip("^")
343 if not ui.debugflag and f.startswith("debug") and name != "debug":
344 continue
345 doc = e[0].__doc__ 350 doc = e[0].__doc__
346 if not ui.verbose and doc and any(w in doc for w in _exclkeywords): 351 if filtercmd(ui, f, name, doc):
347 continue 352 continue
348 doc = gettext(doc) 353 doc = gettext(doc)
349 if not doc: 354 if not doc:
350 doc = _("(no help text available)") 355 doc = _("(no help text available)")
351 h[f] = doc.splitlines()[0].rstrip() 356 h[f] = doc.splitlines()[0].rstrip()