##// END OF EJS Templates
help: pass around ui to rewriter hooks (API)...
Yuya Nishihara -
r26414:c44b507e default
parent child Browse files
Show More
@@ -144,7 +144,7 def loaddoc(topic):
144 144 path = os.path.join(docdir, topic + ".txt")
145 145 doc = gettext(util.readfile(path))
146 146 for rewriter in helphooks.get(topic, []):
147 doc = rewriter(topic, doc)
147 doc = rewriter(ui, topic, doc)
148 148 return doc
149 149
150 150 return loader
@@ -184,7 +184,7 helphooks = {}
184 184 def addtopichook(topic, rewriter):
185 185 helphooks.setdefault(topic, []).append(rewriter)
186 186
187 def makeitemsdoc(topic, doc, marker, items, dedent=False):
187 def makeitemsdoc(ui, topic, doc, marker, items, dedent=False):
188 188 """Extract docstring from the items key to function mapping, build a
189 189 single documentation block and use it to overwrite the marker in doc.
190 190 """
@@ -211,8 +211,8 def makeitemsdoc(topic, doc, marker, ite
211 211 return doc.replace(marker, entries)
212 212
213 213 def addtopicsymbols(topic, marker, symbols, dedent=False):
214 def add(topic, doc):
215 return makeitemsdoc(topic, doc, marker, symbols, dedent=dedent)
214 def add(ui, topic, doc):
215 return makeitemsdoc(ui, topic, doc, marker, symbols, dedent=dedent)
216 216 addtopichook(topic, add)
217 217
218 218 addtopicsymbols('filesets', '.. predicatesmarker', fileset.symbols)
@@ -985,7 +985,7 Test help hooks
985 985 $ cat > helphook1.py <<EOF
986 986 > from mercurial import help
987 987 >
988 > def rewrite(topic, doc):
988 > def rewrite(ui, topic, doc):
989 989 > return doc + '\nhelphook1\n'
990 990 >
991 991 > def extsetup(ui):
@@ -994,7 +994,7 Test help hooks
994 994 $ cat > helphook2.py <<EOF
995 995 > from mercurial import help
996 996 >
997 > def rewrite(topic, doc):
997 > def rewrite(ui, topic, doc):
998 998 > return doc + '\nhelphook2\n'
999 999 >
1000 1000 > def extsetup(ui):
General Comments 0
You need to be logged in to leave comments. Login now