[PATCH 3 of 4] help: format topic help using RST

Olav Reinert seroton10 at gmail.com
Fri Jun 1 06:41:47 CDT 2012


# HG changeset patch
# User Olav Reinert <seroton10 at gmail.com>
# Date 1338545745 -7200
# Node ID 1af1e72fd4927a7a872c6a4ebf1106d542828b07
# Parent  f7176d2d5d9e9a5fe8d454ad9668795d5fbbc749
help: format topic help using RST

diff -r f7176d2d5d9e -r 1af1e72fd492 mercurial/commands.py
--- a/mercurial/commands.py	Fri Jun 01 12:01:33 2012 +0200
+++ b/mercurial/commands.py	Fri Jun 01 12:15:45 2012 +0200
@@ -3268,20 +3268,20 @@
         else:
             raise error.UnknownCommand(name)
 
+        rst = ["%s\n\n" % header]
         # description
         if not doc:
-            doc = _("(no help text available)")
+            rst.append("    %s\n" % _("(no help text available)"))
         if util.safehasattr(doc, '__call__'):
-            doc = doc()
-
-        ui.write("%s\n\n" % header)
-        ui.write(minirst.format(doc, textwidth, indent=4))
+            rst.extend(map(lambda l: "    %s\n" % l, doc().splitlines()))
+
         try:
             cmdutil.findcmd(name, table)
-            ui.write(_('\nuse "hg help -c %s" to see help for '
+            rst.append(_('\nuse "hg help -c %s" to see help for '
                        'the %s command\n') % (name, name))
         except error.UnknownCommand:
             pass
+        ui.write(minirst.format(''.join(rst), textwidth))
 
     def helpext(name):
         try:


More information about the Mercurial-devel mailing list