Mercurial > public > mercurial-scm > hg
diff mercurial/help.py @ 12820:0edc0aa7432d stable
help: add topic rewriting hooks
They are useful when updating help topics dynamically from extensions.
author | Patrick Mezard <pmezard@gmail.com> |
---|---|
date | Sat, 23 Oct 2010 19:21:49 +0200 |
parents | 019b8e1e0402 |
children | af1006d2f970 |
line wrap: on
line diff
--- a/mercurial/help.py Sat Oct 23 17:30:08 2010 +0200 +++ b/mercurial/help.py Sat Oct 23 19:21:49 2010 +0200 @@ -79,7 +79,11 @@ break path = os.path.join(docdir, topic + ".txt") - return gettext(open(path).read()) + doc = gettext(open(path).read()) + for rewriter in helphooks.get(topic, []): + doc = rewriter(topic, doc) + return doc + return loader helptable = [ @@ -102,3 +106,11 @@ (["hgweb"], _("Configuring hgweb"), loaddoc('hgweb')), (["glossary"], _("Glossary"), loaddoc('glossary')), ] + +# Map topics to lists of callable taking the current topic help and +# returning the updated version +helphooks = { +} + +def addtopichook(topic, rewriter): + helphooks.setdefault(topic, []).append(rewriter)