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