Mercurial > hg
comparison mercurial/help.py @ 27375:c4a062d090ee
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.
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Sun, 13 Dec 2015 10:45:27 -0800 |
parents | eadbbd14bdc1 |
children | fc810d950278 |
comparison
equal
deleted
inserted
replaced
27374:7a70ae647e54 | 27375:c4a062d090ee |
---|---|
144 else: | 144 else: |
145 cmddoc = _('(no help text available)') | 145 cmddoc = _('(no help text available)') |
146 results['extensioncommands'].append((cmdname, cmddoc)) | 146 results['extensioncommands'].append((cmdname, cmddoc)) |
147 return results | 147 return results |
148 | 148 |
149 def loaddoc(topic): | 149 def loaddoc(topic, subdir=None): |
150 """Return a delayed loader for help/topic.txt.""" | 150 """Return a delayed loader for help/topic.txt.""" |
151 | 151 |
152 def loader(ui): | 152 def loader(ui): |
153 docdir = os.path.join(util.datapath, 'help') | 153 docdir = os.path.join(util.datapath, 'help') |
154 if subdir: | |
155 docdir = os.path.join(docdir, subdir) | |
154 path = os.path.join(docdir, topic + ".txt") | 156 path = os.path.join(docdir, topic + ".txt") |
155 doc = gettext(util.readfile(path)) | 157 doc = gettext(util.readfile(path)) |
156 for rewriter in helphooks.get(topic, []): | 158 for rewriter in helphooks.get(topic, []): |
157 doc = rewriter(ui, topic, doc) | 159 doc = rewriter(ui, topic, doc) |
158 return doc | 160 return doc |