[PATCH 4 of 5] help: pass around ui to rewriter hooks (API)
Yuya Nishihara
yuya at tcha.org
Tue Sep 29 10:59:35 CDT 2015
# HG changeset patch
# User Yuya Nishihara <yuya at tcha.org>
# Date 1443237106 -32400
# Sat Sep 26 12:11:46 2015 +0900
# Node ID bdd845598bdef799ec0d03a63c6eaf1a631d59db
# Parent d5f153597bd786bd50c8fa16d11d21bcc9fa55aa
help: pass around ui to rewriter hooks (API)
makeitemsdoc() will hide DEPRECATED items conditionally.
diff --git a/mercurial/help.py b/mercurial/help.py
--- a/mercurial/help.py
+++ b/mercurial/help.py
@@ -144,7 +144,7 @@ def loaddoc(topic):
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 @@ helphooks = {}
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 @@ def makeitemsdoc(topic, doc, marker, ite
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 --git a/tests/test-help.t b/tests/test-help.t
--- a/tests/test-help.t
+++ b/tests/test-help.t
@@ -985,7 +985,7 @@ Test help hooks
$ cat > helphook1.py <<EOF
> from mercurial import help
>
- > def rewrite(topic, doc):
+ > def rewrite(ui, topic, doc):
> return doc + '\nhelphook1\n'
>
> def extsetup(ui):
@@ -994,7 +994,7 @@ Test help hooks
$ cat > helphook2.py <<EOF
> from mercurial import help
>
- > def rewrite(topic, doc):
+ > def rewrite(ui, topic, doc):
> return doc + '\nhelphook2\n'
>
> def extsetup(ui):
More information about the Mercurial-devel
mailing list