annotate doc/gendoc.py @ 12781:0d09991f91ee

gendoc: automatically create help for default extensions. Adds a section in the hg.1 manpage and corresponding hg.1.html file. Each extension is listed with its module docstring, followed by the commands defined by that extendsion. Creates help for extensions by extracting doc strings from the extension modules and its commands.
author Erik Zielke <ez@aragost.com>
date Wed, 20 Oct 2010 17:45:09 +0200
parents bdc1cf692447
children e0e8b123b75e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
12780
bdc1cf692447 gendoc: dedent documentation from docstrings
Erik Zielke <ez@aragost.com>
parents: 12777
diff changeset
1 import os, sys, textwrap
1814
7956893e8458 generate hg manpage from commands.py docstring
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
2 # import from the live mercurial repo
7956893e8458 generate hg manpage from commands.py docstring
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
3 sys.path.insert(0, "..")
9130
335f749cc369 gendoc: fall back to pure modules if C extensions are not available (issue1711)
Cédric Duval <cedricduval@free.fr>
parents: 9021
diff changeset
4 # fall back to pure modules if required C extensions are not available
335f749cc369 gendoc: fall back to pure modules if C extensions are not available (issue1711)
Cédric Duval <cedricduval@free.fr>
parents: 9021
diff changeset
5 sys.path.append(os.path.join('..', 'mercurial', 'pure'))
5209
bbdcdc7f170e gendoc: use demandimport
Matt Mackall <mpm@selenic.com>
parents: 3797
diff changeset
6 from mercurial import demandimport; demandimport.enable()
9485
7d6ac5d7917c test-gendoc: add tests for all languages
Martin Geisler <mg@lazybytes.net>
parents: 9484
diff changeset
7 from mercurial import encoding
1814
7956893e8458 generate hg manpage from commands.py docstring
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
8 from mercurial.commands import table, globalopts
9240
b6cb3af61582 gendoc: don't translate topic strings twice (issue1760)
Cédric Duval <cedricduval@free.fr>
parents: 9130
diff changeset
9 from mercurial.i18n import _
3797
54fd4d3b4fce Generate docs for help topics
Matt Mackall <mpm@selenic.com>
parents: 1814
diff changeset
10 from mercurial.help import helptable
12781
0d09991f91ee gendoc: automatically create help for default extensions.
Erik Zielke <ez@aragost.com>
parents: 12780
diff changeset
11 from mercurial import extensions
1814
7956893e8458 generate hg manpage from commands.py docstring
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
12
7956893e8458 generate hg manpage from commands.py docstring
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
13 def get_desc(docstr):
7956893e8458 generate hg manpage from commands.py docstring
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
14 if not docstr:
7956893e8458 generate hg manpage from commands.py docstring
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
15 return "", ""
7956893e8458 generate hg manpage from commands.py docstring
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
16 # sanitize
7956893e8458 generate hg manpage from commands.py docstring
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
17 docstr = docstr.strip("\n")
7956893e8458 generate hg manpage from commands.py docstring
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
18 docstr = docstr.rstrip()
7956893e8458 generate hg manpage from commands.py docstring
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
19 shortdesc = docstr.splitlines()[0].strip()
7956893e8458 generate hg manpage from commands.py docstring
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
20
7956893e8458 generate hg manpage from commands.py docstring
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
21 i = docstr.find("\n")
7956893e8458 generate hg manpage from commands.py docstring
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
22 if i != -1:
10282
08a0f04b56bd many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents: 9792
diff changeset
23 desc = docstr[i + 2:]
1814
7956893e8458 generate hg manpage from commands.py docstring
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
24 else:
12780
bdc1cf692447 gendoc: dedent documentation from docstrings
Erik Zielke <ez@aragost.com>
parents: 12777
diff changeset
25 desc = shortdesc
bdc1cf692447 gendoc: dedent documentation from docstrings
Erik Zielke <ez@aragost.com>
parents: 12777
diff changeset
26
bdc1cf692447 gendoc: dedent documentation from docstrings
Erik Zielke <ez@aragost.com>
parents: 12777
diff changeset
27 desc = textwrap.dedent(desc)
bdc1cf692447 gendoc: dedent documentation from docstrings
Erik Zielke <ez@aragost.com>
parents: 12777
diff changeset
28
1814
7956893e8458 generate hg manpage from commands.py docstring
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
29 return (shortdesc, desc)
7956893e8458 generate hg manpage from commands.py docstring
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
30
7956893e8458 generate hg manpage from commands.py docstring
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
31 def get_opts(opts):
11321
40c06bbf58be help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 10282
diff changeset
32 for opt in opts:
40c06bbf58be help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 10282
diff changeset
33 if len(opt) == 5:
40c06bbf58be help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 10282
diff changeset
34 shortopt, longopt, default, desc, optlabel = opt
40c06bbf58be help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 10282
diff changeset
35 else:
40c06bbf58be help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 10282
diff changeset
36 shortopt, longopt, default, desc = opt
1814
7956893e8458 generate hg manpage from commands.py docstring
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
37 allopts = []
7956893e8458 generate hg manpage from commands.py docstring
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
38 if shortopt:
7956893e8458 generate hg manpage from commands.py docstring
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
39 allopts.append("-%s" % shortopt)
7956893e8458 generate hg manpage from commands.py docstring
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
40 if longopt:
7956893e8458 generate hg manpage from commands.py docstring
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
41 allopts.append("--%s" % longopt)
7956893e8458 generate hg manpage from commands.py docstring
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
42 desc += default and _(" (default: %s)") % default or ""
7956893e8458 generate hg manpage from commands.py docstring
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
43 yield(", ".join(allopts), desc)
7956893e8458 generate hg manpage from commands.py docstring
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
44
12756
13f0acfa974a gendoc: refactor get_cmd
Erik Zielke <ez@aragost.com>
parents: 11570
diff changeset
45 def get_cmd(cmd, cmdtable):
1814
7956893e8458 generate hg manpage from commands.py docstring
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
46 d = {}
12756
13f0acfa974a gendoc: refactor get_cmd
Erik Zielke <ez@aragost.com>
parents: 11570
diff changeset
47 attr = cmdtable[cmd]
1814
7956893e8458 generate hg manpage from commands.py docstring
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
48 cmds = cmd.lstrip("^").split("|")
7956893e8458 generate hg manpage from commands.py docstring
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
49
7956893e8458 generate hg manpage from commands.py docstring
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
50 d['cmd'] = cmds[0]
7956893e8458 generate hg manpage from commands.py docstring
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
51 d['aliases'] = cmd.split("|")[1:]
7956893e8458 generate hg manpage from commands.py docstring
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
52 d['desc'] = get_desc(attr[0].__doc__)
7956893e8458 generate hg manpage from commands.py docstring
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
53 d['opts'] = list(get_opts(attr[1]))
7376
fc06bd17c985 doc: handle shortened command synopses
Matt Mackall <mpm@selenic.com>
parents: 7014
diff changeset
54
fc06bd17c985 doc: handle shortened command synopses
Matt Mackall <mpm@selenic.com>
parents: 7014
diff changeset
55 s = 'hg ' + cmds[0]
fc06bd17c985 doc: handle shortened command synopses
Matt Mackall <mpm@selenic.com>
parents: 7014
diff changeset
56 if len(attr) > 2:
fc06bd17c985 doc: handle shortened command synopses
Matt Mackall <mpm@selenic.com>
parents: 7014
diff changeset
57 if not attr[2].startswith('hg'):
8546
a33d19dcf906 gendoc: add missing space in command synopsis
Ori Avtalion <ori@avtalion.name>
parents: 7376
diff changeset
58 s += ' ' + attr[2]
7376
fc06bd17c985 doc: handle shortened command synopses
Matt Mackall <mpm@selenic.com>
parents: 7014
diff changeset
59 else:
fc06bd17c985 doc: handle shortened command synopses
Matt Mackall <mpm@selenic.com>
parents: 7014
diff changeset
60 s = attr[2]
9622
9d1a480ca6ea gendoc: fix synopsis
Martin Geisler <mg@lazybytes.net>
parents: 9485
diff changeset
61 d['synopsis'] = s.strip()
7376
fc06bd17c985 doc: handle shortened command synopses
Matt Mackall <mpm@selenic.com>
parents: 7014
diff changeset
62
1814
7956893e8458 generate hg manpage from commands.py docstring
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
63 return d
7956893e8458 generate hg manpage from commands.py docstring
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
64
12776
4f4eddee254d gendoc: move section commands to module scope
Martin Geisler <mg@lazybytes.net>
parents: 12756
diff changeset
65 def section(ui, s):
4f4eddee254d gendoc: move section commands to module scope
Martin Geisler <mg@lazybytes.net>
parents: 12756
diff changeset
66 ui.write("%s\n%s\n\n" % (s, "-" * encoding.colwidth(s)))
4f4eddee254d gendoc: move section commands to module scope
Martin Geisler <mg@lazybytes.net>
parents: 12756
diff changeset
67
4f4eddee254d gendoc: move section commands to module scope
Martin Geisler <mg@lazybytes.net>
parents: 12756
diff changeset
68 def subsection(ui, s):
4f4eddee254d gendoc: move section commands to module scope
Martin Geisler <mg@lazybytes.net>
parents: 12756
diff changeset
69 ui.write("%s\n%s\n\n" % (s, '"' * encoding.colwidth(s)))
4f4eddee254d gendoc: move section commands to module scope
Martin Geisler <mg@lazybytes.net>
parents: 12756
diff changeset
70
12781
0d09991f91ee gendoc: automatically create help for default extensions.
Erik Zielke <ez@aragost.com>
parents: 12780
diff changeset
71 def subsubsection(ui, s):
0d09991f91ee gendoc: automatically create help for default extensions.
Erik Zielke <ez@aragost.com>
parents: 12780
diff changeset
72 ui.write("%s\n%s\n\n" % (s, "." * encoding.colwidth(s)))
0d09991f91ee gendoc: automatically create help for default extensions.
Erik Zielke <ez@aragost.com>
parents: 12780
diff changeset
73
0d09991f91ee gendoc: automatically create help for default extensions.
Erik Zielke <ez@aragost.com>
parents: 12780
diff changeset
74 def subsubsubsection(ui, s):
0d09991f91ee gendoc: automatically create help for default extensions.
Erik Zielke <ez@aragost.com>
parents: 12780
diff changeset
75 ui.write("%s\n%s\n\n" % (s, "#" * encoding.colwidth(s)))
0d09991f91ee gendoc: automatically create help for default extensions.
Erik Zielke <ez@aragost.com>
parents: 12780
diff changeset
76
12776
4f4eddee254d gendoc: move section commands to module scope
Martin Geisler <mg@lazybytes.net>
parents: 12756
diff changeset
77
1814
7956893e8458 generate hg manpage from commands.py docstring
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
78 def show_doc(ui):
7956893e8458 generate hg manpage from commands.py docstring
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
79 # print options
12776
4f4eddee254d gendoc: move section commands to module scope
Martin Geisler <mg@lazybytes.net>
parents: 12756
diff changeset
80 section(ui, _("Options"))
1814
7956893e8458 generate hg manpage from commands.py docstring
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
81 for optstr, desc in get_opts(globalopts):
12780
bdc1cf692447 gendoc: dedent documentation from docstrings
Erik Zielke <ez@aragost.com>
parents: 12777
diff changeset
82 ui.write("%s\n%s\n\n" % (optstr, desc))
1814
7956893e8458 generate hg manpage from commands.py docstring
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
83
7956893e8458 generate hg manpage from commands.py docstring
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
84 # print cmds
12776
4f4eddee254d gendoc: move section commands to module scope
Martin Geisler <mg@lazybytes.net>
parents: 12756
diff changeset
85 section(ui, _("Commands"))
12781
0d09991f91ee gendoc: automatically create help for default extensions.
Erik Zielke <ez@aragost.com>
parents: 12780
diff changeset
86 commandprinter(ui, table, subsection)
12756
13f0acfa974a gendoc: refactor get_cmd
Erik Zielke <ez@aragost.com>
parents: 11570
diff changeset
87
13f0acfa974a gendoc: refactor get_cmd
Erik Zielke <ez@aragost.com>
parents: 11570
diff changeset
88 # print topics
13f0acfa974a gendoc: refactor get_cmd
Erik Zielke <ez@aragost.com>
parents: 11570
diff changeset
89 for names, sec, doc in helptable:
13f0acfa974a gendoc: refactor get_cmd
Erik Zielke <ez@aragost.com>
parents: 11570
diff changeset
90 for name in names:
13f0acfa974a gendoc: refactor get_cmd
Erik Zielke <ez@aragost.com>
parents: 11570
diff changeset
91 ui.write(".. _%s:\n" % name)
13f0acfa974a gendoc: refactor get_cmd
Erik Zielke <ez@aragost.com>
parents: 11570
diff changeset
92 ui.write("\n")
12776
4f4eddee254d gendoc: move section commands to module scope
Martin Geisler <mg@lazybytes.net>
parents: 12756
diff changeset
93 section(ui, sec)
12756
13f0acfa974a gendoc: refactor get_cmd
Erik Zielke <ez@aragost.com>
parents: 11570
diff changeset
94 if hasattr(doc, '__call__'):
13f0acfa974a gendoc: refactor get_cmd
Erik Zielke <ez@aragost.com>
parents: 11570
diff changeset
95 doc = doc()
13f0acfa974a gendoc: refactor get_cmd
Erik Zielke <ez@aragost.com>
parents: 11570
diff changeset
96 ui.write(doc)
13f0acfa974a gendoc: refactor get_cmd
Erik Zielke <ez@aragost.com>
parents: 11570
diff changeset
97 ui.write("\n")
13f0acfa974a gendoc: refactor get_cmd
Erik Zielke <ez@aragost.com>
parents: 11570
diff changeset
98
12781
0d09991f91ee gendoc: automatically create help for default extensions.
Erik Zielke <ez@aragost.com>
parents: 12780
diff changeset
99 section(ui, _("Extensions"))
0d09991f91ee gendoc: automatically create help for default extensions.
Erik Zielke <ez@aragost.com>
parents: 12780
diff changeset
100 ui.write(_("This section contains help for extensions that is distributed "
0d09991f91ee gendoc: automatically create help for default extensions.
Erik Zielke <ez@aragost.com>
parents: 12780
diff changeset
101 "together with Mercurial. Help for other extensions is available "
0d09991f91ee gendoc: automatically create help for default extensions.
Erik Zielke <ez@aragost.com>
parents: 12780
diff changeset
102 "in the help system."))
0d09991f91ee gendoc: automatically create help for default extensions.
Erik Zielke <ez@aragost.com>
parents: 12780
diff changeset
103 ui.write("\n\n"
0d09991f91ee gendoc: automatically create help for default extensions.
Erik Zielke <ez@aragost.com>
parents: 12780
diff changeset
104 ".. contents::\n"
0d09991f91ee gendoc: automatically create help for default extensions.
Erik Zielke <ez@aragost.com>
parents: 12780
diff changeset
105 " :class: htmlonly\n"
0d09991f91ee gendoc: automatically create help for default extensions.
Erik Zielke <ez@aragost.com>
parents: 12780
diff changeset
106 " :local:\n"
0d09991f91ee gendoc: automatically create help for default extensions.
Erik Zielke <ez@aragost.com>
parents: 12780
diff changeset
107 " :depth: 1\n\n")
0d09991f91ee gendoc: automatically create help for default extensions.
Erik Zielke <ez@aragost.com>
parents: 12780
diff changeset
108
0d09991f91ee gendoc: automatically create help for default extensions.
Erik Zielke <ez@aragost.com>
parents: 12780
diff changeset
109 for extensionname in sorted(allextensionnames()):
0d09991f91ee gendoc: automatically create help for default extensions.
Erik Zielke <ez@aragost.com>
parents: 12780
diff changeset
110 mod = extensions.load(None, extensionname, None)
0d09991f91ee gendoc: automatically create help for default extensions.
Erik Zielke <ez@aragost.com>
parents: 12780
diff changeset
111 subsection(ui, extensionname)
0d09991f91ee gendoc: automatically create help for default extensions.
Erik Zielke <ez@aragost.com>
parents: 12780
diff changeset
112 ui.write("%s\n\n" % mod.__doc__)
0d09991f91ee gendoc: automatically create help for default extensions.
Erik Zielke <ez@aragost.com>
parents: 12780
diff changeset
113 cmdtable = getattr(mod, 'cmdtable', None)
0d09991f91ee gendoc: automatically create help for default extensions.
Erik Zielke <ez@aragost.com>
parents: 12780
diff changeset
114 if cmdtable:
0d09991f91ee gendoc: automatically create help for default extensions.
Erik Zielke <ez@aragost.com>
parents: 12780
diff changeset
115 subsubsection(ui, _('Commands'))
0d09991f91ee gendoc: automatically create help for default extensions.
Erik Zielke <ez@aragost.com>
parents: 12780
diff changeset
116 commandprinter(ui, cmdtable, subsubsubsection)
0d09991f91ee gendoc: automatically create help for default extensions.
Erik Zielke <ez@aragost.com>
parents: 12780
diff changeset
117
0d09991f91ee gendoc: automatically create help for default extensions.
Erik Zielke <ez@aragost.com>
parents: 12780
diff changeset
118 def commandprinter(ui, cmdtable, sectionfunc):
1814
7956893e8458 generate hg manpage from commands.py docstring
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
119 h = {}
12756
13f0acfa974a gendoc: refactor get_cmd
Erik Zielke <ez@aragost.com>
parents: 11570
diff changeset
120 for c, attr in cmdtable.items():
6488
119dff2cd592 gendoc: fix indentation
Christian Ebert <blacktrash@gmx.net>
parents: 5209
diff changeset
121 f = c.split("|")[0]
119dff2cd592 gendoc: fix indentation
Christian Ebert <blacktrash@gmx.net>
parents: 5209
diff changeset
122 f = f.lstrip("^")
119dff2cd592 gendoc: fix indentation
Christian Ebert <blacktrash@gmx.net>
parents: 5209
diff changeset
123 h[f] = c
1814
7956893e8458 generate hg manpage from commands.py docstring
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
124 cmds = h.keys()
7956893e8458 generate hg manpage from commands.py docstring
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
125 cmds.sort()
7956893e8458 generate hg manpage from commands.py docstring
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
126
7956893e8458 generate hg manpage from commands.py docstring
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
127 for f in cmds:
10282
08a0f04b56bd many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents: 9792
diff changeset
128 if f.startswith("debug"):
08a0f04b56bd many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents: 9792
diff changeset
129 continue
12756
13f0acfa974a gendoc: refactor get_cmd
Erik Zielke <ez@aragost.com>
parents: 11570
diff changeset
130 d = get_cmd(h[f], cmdtable)
12781
0d09991f91ee gendoc: automatically create help for default extensions.
Erik Zielke <ez@aragost.com>
parents: 12780
diff changeset
131 sectionfunc(ui, d['cmd'])
6488
119dff2cd592 gendoc: fix indentation
Christian Ebert <blacktrash@gmx.net>
parents: 5209
diff changeset
132 # synopsis
9158
d6eecafaf12f doc: use reStructuredText for man and HTML pages
Martin Geisler <mg@lazybytes.net>
parents: 9130
diff changeset
133 ui.write("``%s``\n" % d['synopsis'].replace("hg ","", 1))
12780
bdc1cf692447 gendoc: dedent documentation from docstrings
Erik Zielke <ez@aragost.com>
parents: 12777
diff changeset
134 ui.write("\n")
6488
119dff2cd592 gendoc: fix indentation
Christian Ebert <blacktrash@gmx.net>
parents: 5209
diff changeset
135 # description
119dff2cd592 gendoc: fix indentation
Christian Ebert <blacktrash@gmx.net>
parents: 5209
diff changeset
136 ui.write("%s\n\n" % d['desc'][1])
119dff2cd592 gendoc: fix indentation
Christian Ebert <blacktrash@gmx.net>
parents: 5209
diff changeset
137 # options
119dff2cd592 gendoc: fix indentation
Christian Ebert <blacktrash@gmx.net>
parents: 5209
diff changeset
138 opt_output = list(d['opts'])
119dff2cd592 gendoc: fix indentation
Christian Ebert <blacktrash@gmx.net>
parents: 5209
diff changeset
139 if opt_output:
119dff2cd592 gendoc: fix indentation
Christian Ebert <blacktrash@gmx.net>
parents: 5209
diff changeset
140 opts_len = max([len(line[0]) for line in opt_output])
12780
bdc1cf692447 gendoc: dedent documentation from docstrings
Erik Zielke <ez@aragost.com>
parents: 12777
diff changeset
141 ui.write(_("options:\n\n"))
6488
119dff2cd592 gendoc: fix indentation
Christian Ebert <blacktrash@gmx.net>
parents: 5209
diff changeset
142 for optstr, desc in opt_output:
119dff2cd592 gendoc: fix indentation
Christian Ebert <blacktrash@gmx.net>
parents: 5209
diff changeset
143 if desc:
119dff2cd592 gendoc: fix indentation
Christian Ebert <blacktrash@gmx.net>
parents: 5209
diff changeset
144 s = "%-*s %s" % (opts_len, optstr, desc)
119dff2cd592 gendoc: fix indentation
Christian Ebert <blacktrash@gmx.net>
parents: 5209
diff changeset
145 else:
119dff2cd592 gendoc: fix indentation
Christian Ebert <blacktrash@gmx.net>
parents: 5209
diff changeset
146 s = optstr
12780
bdc1cf692447 gendoc: dedent documentation from docstrings
Erik Zielke <ez@aragost.com>
parents: 12777
diff changeset
147 ui.write("%s\n" % s)
6488
119dff2cd592 gendoc: fix indentation
Christian Ebert <blacktrash@gmx.net>
parents: 5209
diff changeset
148 ui.write("\n")
119dff2cd592 gendoc: fix indentation
Christian Ebert <blacktrash@gmx.net>
parents: 5209
diff changeset
149 # aliases
119dff2cd592 gendoc: fix indentation
Christian Ebert <blacktrash@gmx.net>
parents: 5209
diff changeset
150 if d['aliases']:
119dff2cd592 gendoc: fix indentation
Christian Ebert <blacktrash@gmx.net>
parents: 5209
diff changeset
151 ui.write(_(" aliases: %s\n\n") % " ".join(d['aliases']))
1814
7956893e8458 generate hg manpage from commands.py docstring
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
152
3797
54fd4d3b4fce Generate docs for help topics
Matt Mackall <mpm@selenic.com>
parents: 1814
diff changeset
153
12781
0d09991f91ee gendoc: automatically create help for default extensions.
Erik Zielke <ez@aragost.com>
parents: 12780
diff changeset
154 def allextensionnames():
0d09991f91ee gendoc: automatically create help for default extensions.
Erik Zielke <ez@aragost.com>
parents: 12780
diff changeset
155 extensionnames = []
0d09991f91ee gendoc: automatically create help for default extensions.
Erik Zielke <ez@aragost.com>
parents: 12780
diff changeset
156
0d09991f91ee gendoc: automatically create help for default extensions.
Erik Zielke <ez@aragost.com>
parents: 12780
diff changeset
157 extensionsdictionary = extensions.enabled()[0]
0d09991f91ee gendoc: automatically create help for default extensions.
Erik Zielke <ez@aragost.com>
parents: 12780
diff changeset
158 extensionnames.extend(extensionsdictionary.keys())
0d09991f91ee gendoc: automatically create help for default extensions.
Erik Zielke <ez@aragost.com>
parents: 12780
diff changeset
159
0d09991f91ee gendoc: automatically create help for default extensions.
Erik Zielke <ez@aragost.com>
parents: 12780
diff changeset
160 extensionsdictionary = extensions.disabled()[0]
0d09991f91ee gendoc: automatically create help for default extensions.
Erik Zielke <ez@aragost.com>
parents: 12780
diff changeset
161 extensionnames.extend(extensionsdictionary.keys())
0d09991f91ee gendoc: automatically create help for default extensions.
Erik Zielke <ez@aragost.com>
parents: 12780
diff changeset
162
0d09991f91ee gendoc: automatically create help for default extensions.
Erik Zielke <ez@aragost.com>
parents: 12780
diff changeset
163 return extensionnames
0d09991f91ee gendoc: automatically create help for default extensions.
Erik Zielke <ez@aragost.com>
parents: 12780
diff changeset
164
0d09991f91ee gendoc: automatically create help for default extensions.
Erik Zielke <ez@aragost.com>
parents: 12780
diff changeset
165
1814
7956893e8458 generate hg manpage from commands.py docstring
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
166 if __name__ == "__main__":
7956893e8458 generate hg manpage from commands.py docstring
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
167 show_doc(sys.stdout)