# HG changeset patch # User Erik Zielke # Date 1287489003 -7200 # Node ID bdc1cf6924479ec4ea43433f1689a8d9465ac3a3 # Parent 891ddf76b73eebc86b773fbb17c145bad387496b gendoc: dedent documentation from docstrings When getting docstrings from the source they are indented to look good in the code. This indentation interferes with how the text is parsed by rst. Therefore this indentation is removed. diff -r 891ddf76b73e -r bdc1cf692447 doc/gendoc.py --- a/doc/gendoc.py Tue Oct 19 13:43:40 2010 +0200 +++ b/doc/gendoc.py Tue Oct 19 13:50:03 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 = shortdesc + + desc = textwrap.dedent(desc) + return (shortdesc, desc) def get_opts(opts): @@ -69,7 +72,7 @@ # print options section(ui, _("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(ui, _("Commands")) @@ -102,19 +105,20 @@ subsection(ui, d['cmd']) # synopsis 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']: