##// END OF EJS Templates
gendoc: dedent documentation from docstrings...
Erik Zielke -
r12780:bdc1cf69 default
parent child Browse files
Show More
@@ -1,4 +1,4 b''
1 import os, sys
1 import os, sys, textwrap
2 2 # import from the live mercurial repo
3 3 sys.path.insert(0, "..")
4 4 # fall back to pure modules if required C extensions are not available
@@ -21,7 +21,10 b' def get_desc(docstr):'
21 21 if i != -1:
22 22 desc = docstr[i + 2:]
23 23 else:
24 desc = " %s" % shortdesc
24 desc = shortdesc
25
26 desc = textwrap.dedent(desc)
27
25 28 return (shortdesc, desc)
26 29
27 30 def get_opts(opts):
@@ -69,7 +72,7 b' def show_doc(ui):'
69 72 # print options
70 73 section(ui, _("Options"))
71 74 for optstr, desc in get_opts(globalopts):
72 ui.write("%s\n %s\n\n" % (optstr, desc))
75 ui.write("%s\n%s\n\n" % (optstr, desc))
73 76
74 77 # print cmds
75 78 section(ui, _("Commands"))
@@ -102,19 +105,20 b' def commandprinter(ui, cmdtable):'
102 105 subsection(ui, d['cmd'])
103 106 # synopsis
104 107 ui.write("``%s``\n" % d['synopsis'].replace("hg ","", 1))
108 ui.write("\n")
105 109 # description
106 110 ui.write("%s\n\n" % d['desc'][1])
107 111 # options
108 112 opt_output = list(d['opts'])
109 113 if opt_output:
110 114 opts_len = max([len(line[0]) for line in opt_output])
111 ui.write(_(" options:\n\n"))
115 ui.write(_("options:\n\n"))
112 116 for optstr, desc in opt_output:
113 117 if desc:
114 118 s = "%-*s %s" % (opts_len, optstr, desc)
115 119 else:
116 120 s = optstr
117 ui.write(" %s\n" % s)
121 ui.write("%s\n" % s)
118 122 ui.write("\n")
119 123 # aliases
120 124 if d['aliases']:
General Comments 0
You need to be logged in to leave comments. Login now