Mercurial > hg-stable
changeset 26414:c44b507e7c78
help: pass around ui to rewriter hooks (API)
makeitemsdoc() will hide DEPRECATED items conditionally.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Sat, 26 Sep 2015 12:11:46 +0900 |
parents | e0c572d4d112 |
children | 46af0adb5c37 |
files | mercurial/help.py tests/test-help.t |
diffstat | 2 files changed, 6 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- 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)
--- 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 <<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 @@ $ cat > helphook2.py <<EOF > from mercurial import help > - > def rewrite(topic, doc): + > def rewrite(ui, topic, doc): > return doc + '\nhelphook2\n' > > def extsetup(ui):