Show More
@@ -8,6 +8,7 b' from mercurial import encoding' | |||||
8 | from mercurial.commands import table, globalopts |
|
8 | from mercurial.commands import table, globalopts | |
9 | from mercurial.i18n import _ |
|
9 | from mercurial.i18n import _ | |
10 | from mercurial.help import helptable |
|
10 | from mercurial.help import helptable | |
|
11 | from mercurial import extensions | |||
11 |
|
12 | |||
12 | def get_desc(docstr): |
|
13 | def get_desc(docstr): | |
13 | if not docstr: |
|
14 | if not docstr: | |
@@ -67,6 +68,12 b' def section(ui, s):' | |||||
67 | def subsection(ui, s): |
|
68 | def subsection(ui, s): | |
68 | ui.write("%s\n%s\n\n" % (s, '"' * encoding.colwidth(s))) |
|
69 | ui.write("%s\n%s\n\n" % (s, '"' * encoding.colwidth(s))) | |
69 |
|
70 | |||
|
71 | def subsubsection(ui, s): | |||
|
72 | ui.write("%s\n%s\n\n" % (s, "." * encoding.colwidth(s))) | |||
|
73 | ||||
|
74 | def subsubsubsection(ui, s): | |||
|
75 | ui.write("%s\n%s\n\n" % (s, "#" * encoding.colwidth(s))) | |||
|
76 | ||||
70 |
|
77 | |||
71 | def show_doc(ui): |
|
78 | def show_doc(ui): | |
72 | # print options |
|
79 | # print options | |
@@ -76,7 +83,7 b' def show_doc(ui):' | |||||
76 |
|
83 | |||
77 | # print cmds |
|
84 | # print cmds | |
78 | section(ui, _("Commands")) |
|
85 | section(ui, _("Commands")) | |
79 | commandprinter(ui, table) |
|
86 | commandprinter(ui, table, subsection) | |
80 |
|
87 | |||
81 | # print topics |
|
88 | # print topics | |
82 | for names, sec, doc in helptable: |
|
89 | for names, sec, doc in helptable: | |
@@ -89,7 +96,26 b' def show_doc(ui):' | |||||
89 | ui.write(doc) |
|
96 | ui.write(doc) | |
90 | ui.write("\n") |
|
97 | ui.write("\n") | |
91 |
|
98 | |||
92 | def commandprinter(ui, cmdtable): |
|
99 | section(ui, _("Extensions")) | |
|
100 | ui.write(_("This section contains help for extensions that is distributed " | |||
|
101 | "together with Mercurial. Help for other extensions is available " | |||
|
102 | "in the help system.")) | |||
|
103 | ui.write("\n\n" | |||
|
104 | ".. contents::\n" | |||
|
105 | " :class: htmlonly\n" | |||
|
106 | " :local:\n" | |||
|
107 | " :depth: 1\n\n") | |||
|
108 | ||||
|
109 | for extensionname in sorted(allextensionnames()): | |||
|
110 | mod = extensions.load(None, extensionname, None) | |||
|
111 | subsection(ui, extensionname) | |||
|
112 | ui.write("%s\n\n" % mod.__doc__) | |||
|
113 | cmdtable = getattr(mod, 'cmdtable', None) | |||
|
114 | if cmdtable: | |||
|
115 | subsubsection(ui, _('Commands')) | |||
|
116 | commandprinter(ui, cmdtable, subsubsubsection) | |||
|
117 | ||||
|
118 | def commandprinter(ui, cmdtable, sectionfunc): | |||
93 | h = {} |
|
119 | h = {} | |
94 | for c, attr in cmdtable.items(): |
|
120 | for c, attr in cmdtable.items(): | |
95 | f = c.split("|")[0] |
|
121 | f = c.split("|")[0] | |
@@ -102,7 +128,7 b' def commandprinter(ui, cmdtable):' | |||||
102 | if f.startswith("debug"): |
|
128 | if f.startswith("debug"): | |
103 | continue |
|
129 | continue | |
104 | d = get_cmd(h[f], cmdtable) |
|
130 | d = get_cmd(h[f], cmdtable) | |
105 |
|
|
131 | sectionfunc(ui, d['cmd']) | |
106 | # synopsis |
|
132 | # synopsis | |
107 | ui.write("``%s``\n" % d['synopsis'].replace("hg ","", 1)) |
|
133 | ui.write("``%s``\n" % d['synopsis'].replace("hg ","", 1)) | |
108 | ui.write("\n") |
|
134 | ui.write("\n") | |
@@ -125,5 +151,17 b' def commandprinter(ui, cmdtable):' | |||||
125 | ui.write(_(" aliases: %s\n\n") % " ".join(d['aliases'])) |
|
151 | ui.write(_(" aliases: %s\n\n") % " ".join(d['aliases'])) | |
126 |
|
152 | |||
127 |
|
153 | |||
|
154 | def allextensionnames(): | |||
|
155 | extensionnames = [] | |||
|
156 | ||||
|
157 | extensionsdictionary = extensions.enabled()[0] | |||
|
158 | extensionnames.extend(extensionsdictionary.keys()) | |||
|
159 | ||||
|
160 | extensionsdictionary = extensions.disabled()[0] | |||
|
161 | extensionnames.extend(extensionsdictionary.keys()) | |||
|
162 | ||||
|
163 | return extensionnames | |||
|
164 | ||||
|
165 | ||||
128 | if __name__ == "__main__": |
|
166 | if __name__ == "__main__": | |
129 | show_doc(sys.stdout) |
|
167 | show_doc(sys.stdout) |
General Comments 0
You need to be logged in to leave comments.
Login now