diff mercurial/help.py @ 14318:1f46be4689ed

help: consolidate topic hooks in help.py This removes loops like cmdutil->revset->help->extensions->cmdutil and simplifies the code.
author Matt Mackall <mpm@selenic.com>
date Fri, 13 May 2011 12:57:27 -0500
parents 660b0c1b6196
children 6ab8b17adc03
line wrap: on
line diff
--- a/mercurial/help.py	Fri May 13 11:04:51 2011 -0500
+++ b/mercurial/help.py	Fri May 13 12:57:27 2011 -0500
@@ -7,7 +7,7 @@
 
 from i18n import gettext, _
 import sys, os
-import extensions
+import extensions, revset, templatekw, templatefilters
 import util
 
 def listexts(header, exts, indent=1):
@@ -76,8 +76,7 @@
 
 # Map topics to lists of callable taking the current topic help and
 # returning the updated version
-helphooks = {
-}
+helphooks = {}
 
 def addtopichook(topic, rewriter):
     helphooks.setdefault(topic, []).append(rewriter)
@@ -97,3 +96,12 @@
         entries.append('\n'.join(lines))
     entries = '\n\n'.join(entries)
     return doc.replace(marker, entries)
+
+def addtopicsymbols(topic, marker, symbols):
+    def add(topic, doc):
+        return makeitemsdoc(topic, doc, marker, symbols)
+    addtopichook(topic, add)
+
+addtopicsymbols('revsets', '.. predicatesmarker', revset.symbols)
+addtopicsymbols('templates', '.. keywordsmarker', templatekw.keywords)
+addtopicsymbols('templates', '.. filtersmarker', templatefilters.filters)