##// END OF EJS Templates
gendoc: nest command headers under category headers...
Sietse Brouwer -
r42438:a42cc325 default
parent child Browse files
Show More
@@ -120,7 +120,7 def showdoc(ui):
120
120
121 # print cmds
121 # print cmds
122 ui.write(minirst.section(_(b"Commands")))
122 ui.write(minirst.section(_(b"Commands")))
123 commandprinter(ui, table, minirst.subsection)
123 commandprinter(ui, table, minirst.subsection, minirst.subsubsection)
124
124
125 # print help topics
125 # print help topics
126 # The config help topic is included in the hgrc.5 man page.
126 # The config help topic is included in the hgrc.5 man page.
@@ -143,7 +143,8 def showdoc(ui):
143 cmdtable = getattr(mod, 'cmdtable', None)
143 cmdtable = getattr(mod, 'cmdtable', None)
144 if cmdtable:
144 if cmdtable:
145 ui.write(minirst.subsubsection(_(b'Commands')))
145 ui.write(minirst.subsubsection(_(b'Commands')))
146 commandprinter(ui, cmdtable, minirst.subsubsubsection)
146 commandprinter(ui, cmdtable, minirst.subsubsubsection,
147 minirst.subsubsubsubsection)
147
148
148 def showtopic(ui, topic):
149 def showtopic(ui, topic):
149 extrahelptable = [
150 extrahelptable = [
@@ -177,7 +178,27 def helpprinter(ui, helptable, sectionfu
177 ui.write(doc)
178 ui.write(doc)
178 ui.write(b"\n")
179 ui.write(b"\n")
179
180
180 def commandprinter(ui, cmdtable, sectionfunc):
181 def commandprinter(ui, cmdtable, sectionfunc, subsectionfunc):
182 """Render restructuredtext describing a list of commands and their
183 documentations, grouped by command category.
184
185 Args:
186 ui: UI object to write the output to
187 cmdtable: a dict that maps a string of the command name plus its aliases
188 (separated with pipes) to a 3-tuple of (the command's function, a list
189 of its option descriptions, and a string summarizing available
190 options). Example, with aliases added for demonstration purposes:
191
192 'phase|alias1|alias2': (
193 <function phase at 0x7f0816b05e60>,
194 [ ('p', 'public', False, 'set changeset phase to public'),
195 ...,
196 ('r', 'rev', [], 'target revision', 'REV')],
197 '[-p|-d|-s] [-f] [-r] [REV...]'
198 )
199 sectionfunc: minirst function to format command category headers
200 subsectionfunc: minirst function to format command headers
201 """
181 h = {}
202 h = {}
182 for c, attr in cmdtable.items():
203 for c, attr in cmdtable.items():
183 f = c.split(b"|")[0]
204 f = c.split(b"|")[0]
@@ -221,7 +242,7 def commandprinter(ui, cmdtable, section
221 if f.startswith(b"debug"):
242 if f.startswith(b"debug"):
222 continue
243 continue
223 d = get_cmd(h[f], cmdtable)
244 d = get_cmd(h[f], cmdtable)
224 ui.write(sectionfunc(d[b'cmd']))
245 ui.write(subsectionfunc(d[b'cmd']))
225 # short description
246 # short description
226 ui.write(d[b'desc'][0])
247 ui.write(d[b'desc'][0])
227 # synopsis
248 # synopsis
General Comments 0
You need to be logged in to leave comments. Login now