# HG changeset patch # User Yuya Nishihara # Date 1443237106 -32400 # Node ID c44b507e7c7854ac6b50c7e96769acca10c75a4d # Parent e0c572d4d112471d876ef05bf34dc1d56857088e help: pass around ui to rewriter hooks (API) makeitemsdoc() will hide DEPRECATED items conditionally. diff -r e0c572d4d112 -r c44b507e7c78 mercurial/help.py --- a/mercurial/help.py Sat Sep 26 12:06:30 2015 +0900 +++ b/mercurial/help.py Sat Sep 26 12:11:46 2015 +0900 @@ -144,7 +144,7 @@ path = os.path.join(docdir, topic + ".txt") doc = gettext(util.readfile(path)) for rewriter in helphooks.get(topic, []): - doc = rewriter(topic, doc) + doc = rewriter(ui, topic, doc) return doc return loader @@ -184,7 +184,7 @@ def addtopichook(topic, rewriter): helphooks.setdefault(topic, []).append(rewriter) -def makeitemsdoc(topic, doc, marker, items, dedent=False): +def makeitemsdoc(ui, topic, doc, marker, items, dedent=False): """Extract docstring from the items key to function mapping, build a single documentation block and use it to overwrite the marker in doc. """ @@ -211,8 +211,8 @@ return doc.replace(marker, entries) def addtopicsymbols(topic, marker, symbols, dedent=False): - def add(topic, doc): - return makeitemsdoc(topic, doc, marker, symbols, dedent=dedent) + def add(ui, topic, doc): + return makeitemsdoc(ui, topic, doc, marker, symbols, dedent=dedent) addtopichook(topic, add) addtopicsymbols('filesets', '.. predicatesmarker', fileset.symbols) diff -r e0c572d4d112 -r c44b507e7c78 tests/test-help.t --- a/tests/test-help.t Sat Sep 26 12:06:30 2015 +0900 +++ b/tests/test-help.t Sat Sep 26 12:11:46 2015 +0900 @@ -985,7 +985,7 @@ $ cat > helphook1.py < from mercurial import help > - > def rewrite(topic, doc): + > def rewrite(ui, topic, doc): > return doc + '\nhelphook1\n' > > def extsetup(ui): @@ -994,7 +994,7 @@ $ cat > helphook2.py < from mercurial import help > - > def rewrite(topic, doc): + > def rewrite(ui, topic, doc): > return doc + '\nhelphook2\n' > > def extsetup(ui):