[PATCH 3 of 6] help: ReST tweaks

Dan Villiom Podlaski Christiansen danchr at gmail.com
Sat Feb 9 07:00:37 CST 2013


# HG changeset patch
# User Dan Villiom Podlaski Christiansen  <danchr at gmail.com>
# Date 1360414103 0
# Node ID 03c9cfc461cce54da65f0ad0529a734181022b83
# Parent  aa74feb1f11d43453e6ef3797e6c4c24f950a9dc
help: ReST tweaks

Use a full header for topic titles; make the indent configurable by
the caller

diff --git a/mercurial/help.py b/mercurial/help.py
--- a/mercurial/help.py
+++ b/mercurial/help.py
@@ -389,12 +389,17 @@ def help_(ui, name, unknowncmd=False, fu
         else:
             raise error.UnknownCommand(name)
 
-        rst = ["%s\n\n" % header]
+        headerstyleline = '=' * encoding.colwidth(header)
+        rst = ["%s\n%s\n%s\n\n" % (headerstyleline, header, headerstyleline)]
+
         # description
         if not doc:
-            rst.append("    %s\n" % _("(no help text available)"))
+            doc = _("(no help text available)")
         if util.safehasattr(doc, '__call__'):
-            rst += ["    %s\n" % l for l in doc().splitlines()]
+            doc = doc()
+
+        indent = ' ' * int(opts.get('indent', 4))
+        rst += ["%s%s\n" % (indent, l) for l in doc.splitlines()]
 
         if not ui.verbose:
             omitted = (_('use "hg help -v %s" to show more complete help') %


More information about the Mercurial-devel mailing list