diff mercurial/commands.py @ 31079:2a0c8e3636b0

help: move rst formatting of help documents into help.py This slight refactor will help me improve the 'unknown command' experience in our new glorious pager future.
author Augie Fackler <augie@google.com>
date Tue, 21 Feb 2017 14:17:31 -0500
parents d2ed0abce08e
children be74ce1b930f
line wrap: on
line diff
--- a/mercurial/commands.py	Tue Feb 21 11:06:02 2017 -0500
+++ b/mercurial/commands.py	Tue Feb 21 14:17:31 2017 -0500
@@ -39,7 +39,6 @@
     hg,
     lock as lockmod,
     merge as mergemod,
-    minirst,
     obsolete,
     patch,
     phases,
@@ -2721,10 +2720,6 @@
 
     Returns 0 if successful.
     """
-    textwidth = ui.configint('ui', 'textwidth', 78)
-    termwidth = ui.termwidth() - 2
-    if textwidth <= 0 or termwidth < textwidth:
-        textwidth = termwidth
 
     keep = opts.get('system') or []
     if len(keep) == 0:
@@ -2740,37 +2735,7 @@
     if ui.verbose:
         keep.append('verbose')
 
-    fullname = name
-    section = None
-    subtopic = None
-    if name and '.' in name:
-        name, remaining = name.split('.', 1)
-        remaining = encoding.lower(remaining)
-        if '.' in remaining:
-            subtopic, section = remaining.split('.', 1)
-        else:
-            if name in help.subtopics:
-                subtopic = remaining
-            else:
-                section = remaining
-
-    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):
-        raise error.Abort(_("help section not found: %s") % fullname)
-
-    if 'verbose' in pruned:
-        keep.append('omitted')
-    else:
-        keep.append('notomitted')
-    formatted, pruned = minirst.format(text, textwidth, keep=keep,
-                                       section=section)
+    formatted = help.formattedhelp(ui, name, keep=keep, **opts)
     ui.pager('help')
     ui.write(formatted)