Show More
@@ -8,6 +8,7 b' from mercurial import encoding' | |||
|
8 | 8 | from mercurial.commands import table, globalopts |
|
9 | 9 | from mercurial.i18n import _ |
|
10 | 10 | from mercurial.help import helptable |
|
11 | from mercurial import extensions | |
|
11 | 12 | |
|
12 | 13 | def get_desc(docstr): |
|
13 | 14 | if not docstr: |
@@ -67,6 +68,12 b' def section(ui, s):' | |||
|
67 | 68 | def subsection(ui, s): |
|
68 | 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 | 78 | def show_doc(ui): |
|
72 | 79 | # print options |
@@ -76,7 +83,7 b' def show_doc(ui):' | |||
|
76 | 83 | |
|
77 | 84 | # print cmds |
|
78 | 85 | section(ui, _("Commands")) |
|
79 | commandprinter(ui, table) | |
|
86 | commandprinter(ui, table, subsection) | |
|
80 | 87 | |
|
81 | 88 | # print topics |
|
82 | 89 | for names, sec, doc in helptable: |
@@ -89,7 +96,26 b' def show_doc(ui):' | |||
|
89 | 96 | ui.write(doc) |
|
90 | 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 | 119 | h = {} |
|
94 | 120 | for c, attr in cmdtable.items(): |
|
95 | 121 | f = c.split("|")[0] |
@@ -102,7 +128,7 b' def commandprinter(ui, cmdtable):' | |||
|
102 | 128 | if f.startswith("debug"): |
|
103 | 129 | continue |
|
104 | 130 | d = get_cmd(h[f], cmdtable) |
|
105 |
|
|
|
131 | sectionfunc(ui, d['cmd']) | |
|
106 | 132 | # synopsis |
|
107 | 133 | ui.write("``%s``\n" % d['synopsis'].replace("hg ","", 1)) |
|
108 | 134 | ui.write("\n") |
@@ -125,5 +151,17 b' def commandprinter(ui, cmdtable):' | |||
|
125 | 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 | 166 | if __name__ == "__main__": |
|
129 | 167 | show_doc(sys.stdout) |
General Comments 0
You need to be logged in to leave comments.
Login now