[PATCH 6 of 8 techdocs] help: pass subtopic into help()

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


# HG changeset patch
# User Gregory Szorc <gregory.szorc at gmail.com>
# Date 1450033485 28800
#      Sun Dec 13 11:04:45 2015 -0800
# Node ID 14773a1a68286d051a09979467bacd3b40d41114
# Parent  6c8bf9fa1a76c06aba2c554486c77f1c2a56788f
help: pass subtopic into help()

Now that we have multiple directories where help topics can live,
we need a mechanism to access them. We already use "." to
separate topic from section. So it seems logical to also use "." to
denote the sub-directory of a topic.

This patch teaches the help command to parse out the possible
sub-topic and pass it to the help system.

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -4362,21 +4362,26 @@ def help_(ui, name=None, **opts):
         keep.append('vms')
     elif sys.platform == 'plan9':
         keep.append('plan9')
     else:
         keep.append('unix')
         keep.append(sys.platform.lower())
 
     section = None
+    subtopic = None
     if name and '.' in name:
         name, section = name.split('.', 1)
         section = section.lower()
-
-    text = help.help_(ui, name, **opts)
+        if '.' in section:
+            subtopic, section = section.split('.', 1)
+        else:
+            subtopic = section
+
+    text = help.help_(ui, name, subtopic=subtopic, **opts)
 
     formatted, pruned = minirst.format(text, textwidth, keep=keep,
                                        section=section)
 
     # We could have been given a weird ".foo" section without a name
     # to look for, or we could have simply failed to found "foo.bar"
     # because bar isn't a section of foo
     if section and not (formatted and name):
diff --git a/mercurial/help.py b/mercurial/help.py
--- a/mercurial/help.py
+++ b/mercurial/help.py
@@ -250,17 +250,17 @@ addtopicsymbols('merge-tools', '.. inter
                 filemerge.internalsdoc)
 addtopicsymbols('revsets', '.. predicatesmarker', revset.symbols)
 addtopicsymbols('templates', '.. keywordsmarker', templatekw.keywords)
 addtopicsymbols('templates', '.. filtersmarker', templatefilters.filters)
 addtopicsymbols('templates', '.. functionsmarker', templater.funcs)
 addtopicsymbols('hgweb', '.. webcommandsmarker', webcommands.commands,
                 dedent=True)
 
-def help_(ui, name, unknowncmd=False, full=True, **opts):
+def help_(ui, name, unknowncmd=False, full=True, subtopic=None, **opts):
     '''
     Generate the help for 'name' as unformatted restructured text. If
     'name' is None, describe the commands available.
     '''
 
     import commands # avoid cycle
 
     def helpcmd(name):


More information about the Mercurial-devel mailing list