[PATCH 4 of 8 techdocs] help: teach loaddoc to load from a different directory

Gregory Szorc gregory.szorc at gmail.com
Sun Dec 13 13:46:57 CST 2015


# HG changeset patch
# User Gregory Szorc <gregory.szorc at gmail.com>
# Date 1450032327 28800
#      Sun Dec 13 10:45:27 2015 -0800
# Node ID ce51bf17fdc7482e8fa82ea4fb7042d976a5a1df
# Parent  0bc2c972900ff1a04d6fbfea0505aa82d673971e
help: teach loaddoc to load from a different directory

The help system currently only supports showing help topics from a
single directory. We'll need to teach it to show results from
different directories in order to show the internals topics.

The first step is to teach loaddoc() to load documentation from
a sub-directory.

diff --git a/mercurial/help.py b/mercurial/help.py
--- a/mercurial/help.py
+++ b/mercurial/help.py
@@ -141,21 +141,23 @@ def topicmatch(ui, kw):
                 cmdname = cmd.partition('|')[0].lstrip('^')
                 if entry[0].__doc__:
                     cmddoc = gettext(entry[0].__doc__).splitlines()[0]
                 else:
                     cmddoc = _('(no help text available)')
                 results['extensioncommands'].append((cmdname, cmddoc))
     return results
 
-def loaddoc(topic):
+def loaddoc(topic, subdir=None):
     """Return a delayed loader for help/topic.txt."""
 
     def loader(ui):
         docdir = os.path.join(util.datapath, 'help')
+        if subdir:
+            docdir = os.path.join(docdir, subdir)
         path = os.path.join(docdir, topic + ".txt")
         doc = gettext(util.readfile(path))
         for rewriter in helphooks.get(topic, []):
             doc = rewriter(ui, topic, doc)
         return doc
 
     return loader
 


More information about the Mercurial-devel mailing list