comparison mercurial/help.py @ 40489:1ddd202c47d9

help: allow hiding of help topics Differential Revision: https://phab.mercurial-scm.org/D5077
author rdamazio@google.com
date Sat, 13 Oct 2018 05:43:39 -0700
parents ab09e797fbed
children 444861dc1e55
comparison
equal deleted inserted replaced
40488:ab09e797fbed 40489:1ddd202c47d9
196 return True 196 return True
197 if ui.configbool('help', 'hidden-command.%s' % cmd): 197 if ui.configbool('help', 'hidden-command.%s' % cmd):
198 return True 198 return True
199 return False 199 return False
200 200
201 def filtertopic(ui, topic):
202 return ui.configbool('help', 'hidden-topic.%s' % topic, False)
203
201 def topicmatch(ui, commands, kw): 204 def topicmatch(ui, commands, kw):
202 """Return help topics matching kw. 205 """Return help topics matching kw.
203 206
204 Returns {'section': [(name, summary), ...], ...} where section is 207 Returns {'section': [(name, summary), ...], ...} where section is
205 one of topics, commands, extensions, or extensioncommands. 208 one of topics, commands, extensions, or extensioncommands.
216 names, header, doc = topic[0:3] 219 names, header, doc = topic[0:3]
217 # Old extensions may use a str as doc. 220 # Old extensions may use a str as doc.
218 if (sum(map(lowercontains, names)) 221 if (sum(map(lowercontains, names))
219 or lowercontains(header) 222 or lowercontains(header)
220 or (callable(doc) and lowercontains(doc(ui)))): 223 or (callable(doc) and lowercontains(doc(ui)))):
221 results['topics'].append((names[0], header)) 224 name = names[0]
225 if not filtertopic(ui, name):
226 results['topics'].append((names[0], header))
222 for cmd, entry in commands.table.iteritems(): 227 for cmd, entry in commands.table.iteritems():
223 if len(entry) == 3: 228 if len(entry) == 3:
224 summary = entry[2] 229 summary = entry[2]
225 else: 230 else:
226 summary = '' 231 summary = ''
597 if len(topic) > 3 and topic[3]: 602 if len(topic) > 3 and topic[3]:
598 category = topic[3] 603 category = topic[3]
599 else: 604 else:
600 category = TOPIC_CATEGORY_NONE 605 category = TOPIC_CATEGORY_NONE
601 606
602 topiccats.setdefault(category, []).append((names[0], header)) 607 topicname = names[0]
608 if not filtertopic(ui, topicname):
609 topiccats.setdefault(category, []).append(
610 (topicname, header))
603 611
604 # Check that all categories have an order. 612 # Check that all categories have an order.
605 missing_order = set(topiccats.keys()) - set(TOPIC_CATEGORY_ORDER) 613 missing_order = set(topiccats.keys()) - set(TOPIC_CATEGORY_ORDER)
606 if missing_order: 614 if missing_order:
607 ui.develwarn( 615 ui.develwarn(