[PATCH 5 of 6] gendoc: dedent documentation from docstrings

Erik Zielke ez at aragost.com
Mon Oct 18 07:54:06 CDT 2010


# HG changeset patch
# User Erik Zielke <ez at aragost.com>
# Date 1287406349 -7200
# Node ID bc4f8b25cbbf1de33ba54dec5e662411086e9489
# Parent  b0e7b4e632aa861d09b18f23a4b1d6860904879b
gendoc: dedent documentation from docstrings

diff -r b0e7b4e632aa -r bc4f8b25cbbf doc/gendoc.py
--- a/doc/gendoc.py	Mon Oct 18 14:37:58 2010 +0200
+++ b/doc/gendoc.py	Mon Oct 18 14:52:29 2010 +0200
@@ -1,4 +1,4 @@
-import os, sys
+import os, sys, textwrap
 # import from the live mercurial repo
 sys.path.insert(0, "..")
 # fall back to pure modules if required C extensions are not available
@@ -21,7 +21,10 @@
     if i != -1:
         desc = docstr[i + 2:]
     else:
-        desc = "    %s" % shortdesc
+        desc = "%s" % shortdesc
+
+    desc = textwrap.dedent(desc)
+
     return (shortdesc, desc)
 
 def get_opts(opts):
@@ -67,7 +70,7 @@
     # print options
     section(_("Options"))
     for optstr, desc in get_opts(globalopts):
-        ui.write("%s\n    %s\n\n" % (optstr, desc))
+        ui.write("%s\n%s\n\n" % (optstr, desc))
 
     # print cmds
     section(_("Commands"))
@@ -100,19 +103,20 @@
         # synopsis
         ui.write(".. _%s:\n\n" % d['cmd'])
         ui.write("``%s``\n" % d['synopsis'].replace("hg ","", 1))
+        ui.write("\n")
         # description
         ui.write("%s\n\n" % d['desc'][1])
         # options
         opt_output = list(d['opts'])
         if opt_output:
             opts_len = max([len(line[0]) for line in opt_output])
-            ui.write(_("    options:\n\n"))
+            ui.write(_("options:\n\n"))
             for optstr, desc in opt_output:
                 if desc:
                     s = "%-*s  %s" % (opts_len, optstr, desc)
                 else:
                     s = optstr
-                ui.write("    %s\n" % s)
+                ui.write("%s\n" % s)
             ui.write("\n")
         # aliases
         if d['aliases']:


More information about the Mercurial-devel mailing list