##// END OF EJS Templates
gendoc: refactor get_cmd...
Erik Zielke -
r12756:13f0acfa default
parent child Browse files
Show More
@@ -38,9 +38,9 b' def get_opts(opts):'
38 desc += default and _(" (default: %s)") % default or ""
38 desc += default and _(" (default: %s)") % default or ""
39 yield(", ".join(allopts), desc)
39 yield(", ".join(allopts), desc)
40
40
41 def get_cmd(cmd):
41 def get_cmd(cmd, cmdtable):
42 d = {}
42 d = {}
43 attr = table[cmd]
43 attr = cmdtable[cmd]
44 cmds = cmd.lstrip("^").split("|")
44 cmds = cmd.lstrip("^").split("|")
45
45
46 d['cmd'] = cmds[0]
46 d['cmd'] = cmds[0]
@@ -71,8 +71,22 b' def show_doc(ui):'
71
71
72 # print cmds
72 # print cmds
73 section(_("Commands"))
73 section(_("Commands"))
74 commandprinter(ui, table)
75
76 # print topics
77 for names, sec, doc in helptable:
78 for name in names:
79 ui.write(".. _%s:\n" % name)
80 ui.write("\n")
81 section(sec)
82 if hasattr(doc, '__call__'):
83 doc = doc()
84 ui.write(doc)
85 ui.write("\n")
86
87 def commandprinter(ui, cmdtable):
74 h = {}
88 h = {}
75 for c, attr in table.items():
89 for c, attr in cmdtable.items():
76 f = c.split("|")[0]
90 f = c.split("|")[0]
77 f = f.lstrip("^")
91 f = f.lstrip("^")
78 h[f] = c
92 h[f] = c
@@ -82,7 +96,7 b' def show_doc(ui):'
82 for f in cmds:
96 for f in cmds:
83 if f.startswith("debug"):
97 if f.startswith("debug"):
84 continue
98 continue
85 d = get_cmd(h[f])
99 d = get_cmd(h[f], cmdtable)
86 # synopsis
100 # synopsis
87 ui.write(".. _%s:\n\n" % d['cmd'])
101 ui.write(".. _%s:\n\n" % d['cmd'])
88 ui.write("``%s``\n" % d['synopsis'].replace("hg ","", 1))
102 ui.write("``%s``\n" % d['synopsis'].replace("hg ","", 1))
@@ -104,16 +118,6 b' def show_doc(ui):'
104 if d['aliases']:
118 if d['aliases']:
105 ui.write(_(" aliases: %s\n\n") % " ".join(d['aliases']))
119 ui.write(_(" aliases: %s\n\n") % " ".join(d['aliases']))
106
120
107 # print topics
108 for names, sec, doc in helptable:
109 for name in names:
110 ui.write(".. _%s:\n" % name)
111 ui.write("\n")
112 section(sec)
113 if hasattr(doc, '__call__'):
114 doc = doc()
115 ui.write(doc)
116 ui.write("\n")
117
121
118 if __name__ == "__main__":
122 if __name__ == "__main__":
119 show_doc(sys.stdout)
123 show_doc(sys.stdout)
General Comments 0
You need to be logged in to leave comments. Login now