Mercurial > hg
annotate doc/gendoc.py @ 52271:81e59988e11c stable tip
wheels: make sure we create the `dist/` directory in the make target
The embarrassing details of how this was discovered will be kept under silence.
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Fri, 15 Nov 2024 23:50:35 +0100 |
parents | 2a875530a023 |
children |
rev | line source |
---|---|
45830
c102b704edb5
global: use python3 in shebangs
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44975
diff
changeset
|
1 #!/usr/bin/env python3 |
19425
81fbd4e66ff5
gendoc: dispatch print document content by commandline arguments
Takumi IINO <trot.thunder@gmail.com>
parents:
19424
diff
changeset
|
2 """usage: %s DOC ... |
81fbd4e66ff5
gendoc: dispatch print document content by commandline arguments
Takumi IINO <trot.thunder@gmail.com>
parents:
19424
diff
changeset
|
3 |
81fbd4e66ff5
gendoc: dispatch print document content by commandline arguments
Takumi IINO <trot.thunder@gmail.com>
parents:
19424
diff
changeset
|
4 where DOC is the name of a document |
81fbd4e66ff5
gendoc: dispatch print document content by commandline arguments
Takumi IINO <trot.thunder@gmail.com>
parents:
19424
diff
changeset
|
5 """ |
81fbd4e66ff5
gendoc: dispatch print document content by commandline arguments
Takumi IINO <trot.thunder@gmail.com>
parents:
19424
diff
changeset
|
6 |
28966
ea1fab5293ca
py3: make gendoc use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
27660
diff
changeset
|
7 |
ea1fab5293ca
py3: make gendoc use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
27660
diff
changeset
|
8 import os |
ea1fab5293ca
py3: make gendoc use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
27660
diff
changeset
|
9 import sys |
ea1fab5293ca
py3: make gendoc use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
27660
diff
changeset
|
10 import textwrap |
52020
1f5974f8f730
doc: refactor gendoc for better reusability
Ludovic Chabant <ludovic@chabant.com>
parents:
51844
diff
changeset
|
11 import argparse |
27330
6fbf1159a85a
doc: make gendoc.py module import policy aware
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26413
diff
changeset
|
12 |
41004
e10641c48fa7
py3: byteify gendoc.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
40294
diff
changeset
|
13 try: |
e10641c48fa7
py3: byteify gendoc.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
40294
diff
changeset
|
14 import msvcrt |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42252
diff
changeset
|
15 |
41004
e10641c48fa7
py3: byteify gendoc.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
40294
diff
changeset
|
16 msvcrt.setmode(sys.stdout.fileno(), os.O_BINARY) |
e10641c48fa7
py3: byteify gendoc.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
40294
diff
changeset
|
17 msvcrt.setmode(sys.stderr.fileno(), os.O_BINARY) |
e10641c48fa7
py3: byteify gendoc.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
40294
diff
changeset
|
18 except ImportError: |
e10641c48fa7
py3: byteify gendoc.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
40294
diff
changeset
|
19 pass |
e10641c48fa7
py3: byteify gendoc.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
40294
diff
changeset
|
20 |
27330
6fbf1159a85a
doc: make gendoc.py module import policy aware
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26413
diff
changeset
|
21 # This script is executed during installs and may not have C extensions |
6fbf1159a85a
doc: make gendoc.py module import policy aware
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26413
diff
changeset
|
22 # available. Relax C module requirements. |
43506
9f70512ae2cf
cleanup: remove pointless r-prefixes on single-quoted strings
Augie Fackler <augie@google.com>
parents:
43503
diff
changeset
|
23 os.environ['HGMODULEPOLICY'] = 'allow' |
1814
7956893e8458
generate hg manpage from commands.py docstring
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
24 # import from the live mercurial repo |
49151
1b6e381521c5
doc: use an absolute path in sys.path to work around a python DLL loading bug
Matt Harbison <matt_harbison@yahoo.com>
parents:
46518
diff
changeset
|
25 sys.path.insert(0, os.path.abspath("..")) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42252
diff
changeset
|
26 from mercurial import demandimport |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42252
diff
changeset
|
27 |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42252
diff
changeset
|
28 demandimport.enable() |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42252
diff
changeset
|
29 |
28966
ea1fab5293ca
py3: make gendoc use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
27660
diff
changeset
|
30 from mercurial import ( |
ea1fab5293ca
py3: make gendoc use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
27660
diff
changeset
|
31 commands, |
41030
c0865f3da285
py3: byteify sys.argv in gendoc.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
41004
diff
changeset
|
32 encoding, |
28966
ea1fab5293ca
py3: make gendoc use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
27660
diff
changeset
|
33 extensions, |
46516
921e1253c8ba
gendoc: support defaults on customopts a bit better
Kyle Lippincott <spectral@google.com>
parents:
45830
diff
changeset
|
34 fancyopts, |
28966
ea1fab5293ca
py3: make gendoc use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
27660
diff
changeset
|
35 help, |
ea1fab5293ca
py3: make gendoc use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
27660
diff
changeset
|
36 minirst, |
41004
e10641c48fa7
py3: byteify gendoc.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
40294
diff
changeset
|
37 pycompat, |
28966
ea1fab5293ca
py3: make gendoc use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
27660
diff
changeset
|
38 ui as uimod, |
ea1fab5293ca
py3: make gendoc use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
27660
diff
changeset
|
39 ) |
ea1fab5293ca
py3: make gendoc use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
27660
diff
changeset
|
40 from mercurial.i18n import ( |
ea1fab5293ca
py3: make gendoc use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
27660
diff
changeset
|
41 gettext, |
ea1fab5293ca
py3: make gendoc use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
27660
diff
changeset
|
42 _, |
ea1fab5293ca
py3: make gendoc use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
27660
diff
changeset
|
43 ) |
44975
1a4b9b602e54
py3: fix broken man page generation, it was generating `(default: NUL*)`
Kyle Lippincott <spectral@google.com>
parents:
43673
diff
changeset
|
44 from mercurial.utils import stringutil |
28966
ea1fab5293ca
py3: make gendoc use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
27660
diff
changeset
|
45 |
ea1fab5293ca
py3: make gendoc use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
27660
diff
changeset
|
46 table = commands.table |
ea1fab5293ca
py3: make gendoc use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
27660
diff
changeset
|
47 globalopts = commands.globalopts |
ea1fab5293ca
py3: make gendoc use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
27660
diff
changeset
|
48 helptable = help.helptable |
ea1fab5293ca
py3: make gendoc use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
27660
diff
changeset
|
49 loaddoc = help.loaddoc |
1814
7956893e8458
generate hg manpage from commands.py docstring
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
50 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42252
diff
changeset
|
51 |
1814
7956893e8458
generate hg manpage from commands.py docstring
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
52 def get_desc(docstr): |
7956893e8458
generate hg manpage from commands.py docstring
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
53 if not docstr: |
41004
e10641c48fa7
py3: byteify gendoc.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
40294
diff
changeset
|
54 return b"", b"" |
1814
7956893e8458
generate hg manpage from commands.py docstring
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
55 # sanitize |
41004
e10641c48fa7
py3: byteify gendoc.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
40294
diff
changeset
|
56 docstr = docstr.strip(b"\n") |
1814
7956893e8458
generate hg manpage from commands.py docstring
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
57 docstr = docstr.rstrip() |
7956893e8458
generate hg manpage from commands.py docstring
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
58 shortdesc = docstr.splitlines()[0].strip() |
7956893e8458
generate hg manpage from commands.py docstring
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
59 |
41004
e10641c48fa7
py3: byteify gendoc.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
40294
diff
changeset
|
60 i = docstr.find(b"\n") |
1814
7956893e8458
generate hg manpage from commands.py docstring
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
61 if i != -1: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42252
diff
changeset
|
62 desc = docstr[i + 2 :] |
1814
7956893e8458
generate hg manpage from commands.py docstring
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
63 else: |
12780
bdc1cf692447
gendoc: dedent documentation from docstrings
Erik Zielke <ez@aragost.com>
parents:
12777
diff
changeset
|
64 desc = shortdesc |
bdc1cf692447
gendoc: dedent documentation from docstrings
Erik Zielke <ez@aragost.com>
parents:
12777
diff
changeset
|
65 |
41004
e10641c48fa7
py3: byteify gendoc.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
40294
diff
changeset
|
66 desc = textwrap.dedent(desc.decode('latin1')).encode('latin1') |
12780
bdc1cf692447
gendoc: dedent documentation from docstrings
Erik Zielke <ez@aragost.com>
parents:
12777
diff
changeset
|
67 |
1814
7956893e8458
generate hg manpage from commands.py docstring
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
68 return (shortdesc, desc) |
7956893e8458
generate hg manpage from commands.py docstring
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
69 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42252
diff
changeset
|
70 |
1814
7956893e8458
generate hg manpage from commands.py docstring
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
71 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
|
72 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
|
73 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
|
74 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
|
75 else: |
40c06bbf58be
help: show value requirement and multiple occurrence of options
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
10282
diff
changeset
|
76 shortopt, longopt, default, desc = opt |
41004
e10641c48fa7
py3: byteify gendoc.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
40294
diff
changeset
|
77 optlabel = _(b"VALUE") |
1814
7956893e8458
generate hg manpage from commands.py docstring
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
78 allopts = [] |
7956893e8458
generate hg manpage from commands.py docstring
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
79 if shortopt: |
41004
e10641c48fa7
py3: byteify gendoc.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
40294
diff
changeset
|
80 allopts.append(b"-%s" % shortopt) |
1814
7956893e8458
generate hg manpage from commands.py docstring
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
81 if longopt: |
41004
e10641c48fa7
py3: byteify gendoc.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
40294
diff
changeset
|
82 allopts.append(b"--%s" % longopt) |
20081
93f9d11603d8
doc: show details of command options in pages generated by docutils
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
19425
diff
changeset
|
83 if isinstance(default, list): |
41004
e10641c48fa7
py3: byteify gendoc.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
40294
diff
changeset
|
84 allopts[-1] += b" <%s[+]>" % optlabel |
20081
93f9d11603d8
doc: show details of command options in pages generated by docutils
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
19425
diff
changeset
|
85 elif (default is not None) and not isinstance(default, bool): |
41004
e10641c48fa7
py3: byteify gendoc.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
40294
diff
changeset
|
86 allopts[-1] += b" <%s>" % optlabel |
e10641c48fa7
py3: byteify gendoc.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
40294
diff
changeset
|
87 if b'\n' in desc: |
20655
37f3be9d1541
doc: gendoc.py creates valid output for option descriptions with newlines
Simon Heimberg <simohe@besonet.ch>
parents:
20081
diff
changeset
|
88 # only remove line breaks and indentation |
41004
e10641c48fa7
py3: byteify gendoc.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
40294
diff
changeset
|
89 desc = b' '.join(l.lstrip() for l in desc.split(b'\n')) |
46516
921e1253c8ba
gendoc: support defaults on customopts a bit better
Kyle Lippincott <spectral@google.com>
parents:
45830
diff
changeset
|
90 if isinstance(default, fancyopts.customopt): |
921e1253c8ba
gendoc: support defaults on customopts a bit better
Kyle Lippincott <spectral@google.com>
parents:
45830
diff
changeset
|
91 default = default.getdefaultvalue() |
44975
1a4b9b602e54
py3: fix broken man page generation, it was generating `(default: NUL*)`
Kyle Lippincott <spectral@google.com>
parents:
43673
diff
changeset
|
92 if default: |
1a4b9b602e54
py3: fix broken man page generation, it was generating `(default: NUL*)`
Kyle Lippincott <spectral@google.com>
parents:
43673
diff
changeset
|
93 default = stringutil.forcebytestr(default) |
1a4b9b602e54
py3: fix broken man page generation, it was generating `(default: NUL*)`
Kyle Lippincott <spectral@google.com>
parents:
43673
diff
changeset
|
94 desc += _(b" (default: %s)") % default |
41004
e10641c48fa7
py3: byteify gendoc.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
40294
diff
changeset
|
95 yield (b", ".join(allopts), desc) |
1814
7956893e8458
generate hg manpage from commands.py docstring
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
96 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42252
diff
changeset
|
97 |
12756 | 98 def get_cmd(cmd, cmdtable): |
1814
7956893e8458
generate hg manpage from commands.py docstring
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
99 d = {} |
12756 | 100 attr = cmdtable[cmd] |
41004
e10641c48fa7
py3: byteify gendoc.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
40294
diff
changeset
|
101 cmds = cmd.lstrip(b"^").split(b"|") |
1814
7956893e8458
generate hg manpage from commands.py docstring
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
102 |
41004
e10641c48fa7
py3: byteify gendoc.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
40294
diff
changeset
|
103 d[b'cmd'] = cmds[0] |
e10641c48fa7
py3: byteify gendoc.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
40294
diff
changeset
|
104 d[b'aliases'] = cmd.split(b"|")[1:] |
e10641c48fa7
py3: byteify gendoc.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
40294
diff
changeset
|
105 d[b'desc'] = get_desc(gettext(pycompat.getdoc(attr[0]))) |
e10641c48fa7
py3: byteify gendoc.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
40294
diff
changeset
|
106 d[b'opts'] = list(get_opts(attr[1])) |
7376
fc06bd17c985
doc: handle shortened command synopses
Matt Mackall <mpm@selenic.com>
parents:
7014
diff
changeset
|
107 |
41004
e10641c48fa7
py3: byteify gendoc.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
40294
diff
changeset
|
108 s = b'hg ' + cmds[0] |
7376
fc06bd17c985
doc: handle shortened command synopses
Matt Mackall <mpm@selenic.com>
parents:
7014
diff
changeset
|
109 if len(attr) > 2: |
41004
e10641c48fa7
py3: byteify gendoc.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
40294
diff
changeset
|
110 if not attr[2].startswith(b'hg'): |
e10641c48fa7
py3: byteify gendoc.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
40294
diff
changeset
|
111 s += b' ' + attr[2] |
7376
fc06bd17c985
doc: handle shortened command synopses
Matt Mackall <mpm@selenic.com>
parents:
7014
diff
changeset
|
112 else: |
fc06bd17c985
doc: handle shortened command synopses
Matt Mackall <mpm@selenic.com>
parents:
7014
diff
changeset
|
113 s = attr[2] |
41004
e10641c48fa7
py3: byteify gendoc.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
40294
diff
changeset
|
114 d[b'synopsis'] = s.strip() |
7376
fc06bd17c985
doc: handle shortened command synopses
Matt Mackall <mpm@selenic.com>
parents:
7014
diff
changeset
|
115 |
1814
7956893e8458
generate hg manpage from commands.py docstring
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
116 return d |
7956893e8458
generate hg manpage from commands.py docstring
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
117 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42252
diff
changeset
|
118 |
52020
1f5974f8f730
doc: refactor gendoc for better reusability
Ludovic Chabant <ludovic@chabant.com>
parents:
51844
diff
changeset
|
119 def showdoc(ui, debugcmds=False): |
1814
7956893e8458
generate hg manpage from commands.py docstring
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
120 # print options |
41004
e10641c48fa7
py3: byteify gendoc.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
40294
diff
changeset
|
121 ui.write(minirst.section(_(b"Options"))) |
20081
93f9d11603d8
doc: show details of command options in pages generated by docutils
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
19425
diff
changeset
|
122 multioccur = False |
1814
7956893e8458
generate hg manpage from commands.py docstring
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
123 for optstr, desc in get_opts(globalopts): |
41004
e10641c48fa7
py3: byteify gendoc.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
40294
diff
changeset
|
124 ui.write(b"%s\n %s\n\n" % (optstr, desc)) |
e10641c48fa7
py3: byteify gendoc.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
40294
diff
changeset
|
125 if optstr.endswith(b"[+]>"): |
20081
93f9d11603d8
doc: show details of command options in pages generated by docutils
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
19425
diff
changeset
|
126 multioccur = True |
93f9d11603d8
doc: show details of command options in pages generated by docutils
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
19425
diff
changeset
|
127 if multioccur: |
41004
e10641c48fa7
py3: byteify gendoc.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
40294
diff
changeset
|
128 ui.write(_(b"\n[+] marked option can be specified multiple times\n")) |
e10641c48fa7
py3: byteify gendoc.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
40294
diff
changeset
|
129 ui.write(b"\n") |
1814
7956893e8458
generate hg manpage from commands.py docstring
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
130 |
7956893e8458
generate hg manpage from commands.py docstring
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
131 # print cmds |
41004
e10641c48fa7
py3: byteify gendoc.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
40294
diff
changeset
|
132 ui.write(minirst.section(_(b"Commands"))) |
52020
1f5974f8f730
doc: refactor gendoc for better reusability
Ludovic Chabant <ludovic@chabant.com>
parents:
51844
diff
changeset
|
133 commandprinter( |
1f5974f8f730
doc: refactor gendoc for better reusability
Ludovic Chabant <ludovic@chabant.com>
parents:
51844
diff
changeset
|
134 ui, |
1f5974f8f730
doc: refactor gendoc for better reusability
Ludovic Chabant <ludovic@chabant.com>
parents:
51844
diff
changeset
|
135 table, |
1f5974f8f730
doc: refactor gendoc for better reusability
Ludovic Chabant <ludovic@chabant.com>
parents:
51844
diff
changeset
|
136 minirst.subsection, |
1f5974f8f730
doc: refactor gendoc for better reusability
Ludovic Chabant <ludovic@chabant.com>
parents:
51844
diff
changeset
|
137 minirst.subsubsection, |
1f5974f8f730
doc: refactor gendoc for better reusability
Ludovic Chabant <ludovic@chabant.com>
parents:
51844
diff
changeset
|
138 debugcmds=debugcmds, |
1f5974f8f730
doc: refactor gendoc for better reusability
Ludovic Chabant <ludovic@chabant.com>
parents:
51844
diff
changeset
|
139 ) |
12756 | 140 |
19233
81d9a7f6f2e7
gendoc: extract print help topics into a dedicated function
Takumi IINO <trot.thunder@gmail.com>
parents:
19231
diff
changeset
|
141 # print help topics |
81d9a7f6f2e7
gendoc: extract print help topics into a dedicated function
Takumi IINO <trot.thunder@gmail.com>
parents:
19231
diff
changeset
|
142 # The config help topic is included in the hgrc.5 man page. |
52020
1f5974f8f730
doc: refactor gendoc for better reusability
Ludovic Chabant <ludovic@chabant.com>
parents:
51844
diff
changeset
|
143 topics = findtopics(helptable, exclude=[b'config']) |
1f5974f8f730
doc: refactor gendoc for better reusability
Ludovic Chabant <ludovic@chabant.com>
parents:
51844
diff
changeset
|
144 helpprinter(ui, topics, minirst.section) |
12756 | 145 |
41004
e10641c48fa7
py3: byteify gendoc.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
40294
diff
changeset
|
146 ui.write(minirst.section(_(b"Extensions"))) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42252
diff
changeset
|
147 ui.write( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42252
diff
changeset
|
148 _( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42252
diff
changeset
|
149 b"This section contains help for extensions that are " |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42252
diff
changeset
|
150 b"distributed together with Mercurial. Help for other " |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42252
diff
changeset
|
151 b"extensions is available in the help system." |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42252
diff
changeset
|
152 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42252
diff
changeset
|
153 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42252
diff
changeset
|
154 ui.write( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42252
diff
changeset
|
155 ( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42252
diff
changeset
|
156 b"\n\n" |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42252
diff
changeset
|
157 b".. contents::\n" |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42252
diff
changeset
|
158 b" :class: htmlonly\n" |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42252
diff
changeset
|
159 b" :local:\n" |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42252
diff
changeset
|
160 b" :depth: 1\n\n" |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42252
diff
changeset
|
161 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42252
diff
changeset
|
162 ) |
12781
0d09991f91ee
gendoc: automatically create help for default extensions.
Erik Zielke <ez@aragost.com>
parents:
12780
diff
changeset
|
163 |
0d09991f91ee
gendoc: automatically create help for default extensions.
Erik Zielke <ez@aragost.com>
parents:
12780
diff
changeset
|
164 for extensionname in sorted(allextensionnames()): |
27660
512f883c234c
mercurial: pass ui to extensions.load (issue5007)
Jun Wu <quark@fb.com>
parents:
27496
diff
changeset
|
165 mod = extensions.load(ui, extensionname, None) |
18748
6e676fb6ea44
help: use a full header for topic titles
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17267
diff
changeset
|
166 ui.write(minirst.subsection(extensionname)) |
51844
76387080f238
help: add :config-doc:`section.key` shorthand to insert documentation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49164
diff
changeset
|
167 ext_doc = help.ext_help(ui, mod) |
76387080f238
help: add :config-doc:`section.key` shorthand to insert documentation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49164
diff
changeset
|
168 ui.write(b"%s\n\n" % ext_doc) |
12781
0d09991f91ee
gendoc: automatically create help for default extensions.
Erik Zielke <ez@aragost.com>
parents:
12780
diff
changeset
|
169 cmdtable = getattr(mod, 'cmdtable', None) |
0d09991f91ee
gendoc: automatically create help for default extensions.
Erik Zielke <ez@aragost.com>
parents:
12780
diff
changeset
|
170 if cmdtable: |
41004
e10641c48fa7
py3: byteify gendoc.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
40294
diff
changeset
|
171 ui.write(minirst.subsubsection(_(b'Commands'))) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42252
diff
changeset
|
172 commandprinter( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42252
diff
changeset
|
173 ui, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42252
diff
changeset
|
174 cmdtable, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42252
diff
changeset
|
175 minirst.subsubsubsection, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42252
diff
changeset
|
176 minirst.subsubsubsubsection, |
52020
1f5974f8f730
doc: refactor gendoc for better reusability
Ludovic Chabant <ludovic@chabant.com>
parents:
51844
diff
changeset
|
177 debugcmds=debugcmds, |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42252
diff
changeset
|
178 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42252
diff
changeset
|
179 |
12781
0d09991f91ee
gendoc: automatically create help for default extensions.
Erik Zielke <ez@aragost.com>
parents:
12780
diff
changeset
|
180 |
52021
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
181 def showcommandlist(ui, debugcmds=False): |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
182 """Render a plain text list of all command names |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
183 |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
184 Args: |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
185 ui: the UI object to output to |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
186 debugcmds: whether to include debug commands |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
187 """ |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
188 cmdnames = allcommandnames(table, debugcmds=debugcmds) |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
189 for mainname in cmdnames.keys(): |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
190 # Make does not like semicolons in filenames (or what it |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
191 # considers as filenames). We use command names as targets so |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
192 # it applies here. For now let's skip commands with semicolons |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
193 # in them (at this time it only includes the `admin::verify` |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
194 # advanced command). |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
195 if b'::' in mainname: |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
196 continue |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
197 ui.write(mainname) |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
198 ui.write(b" ") |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
199 |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
200 |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
201 def showtopiclist(ui): |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
202 """Render a plain text list of all help topic names |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
203 |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
204 Args: |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
205 ui: the UI object to output to |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
206 """ |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
207 for topic in helptable: |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
208 topicname = topic[0][0] |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
209 if help.filtertopic(ui, topicname): |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
210 continue |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
211 ui.write(topicname) |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
212 ui.write(b" ") |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
213 |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
214 |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
215 def showextensionlist(ui): |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
216 """Render a plain text list of all extension names |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
217 |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
218 Args: |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
219 ui: the UI object to output to |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
220 """ |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
221 for extensionname in allextensionnames(): |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
222 ui.write(extensionname) |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
223 ui.write(b" ") |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
224 |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
225 |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
226 def showhelpindex(ui, debugcmds=False): |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
227 """Render restructured text for a complete mercurial help index |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
228 |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
229 This index will show a list of commands, followed by a list of help topics, |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
230 and finally a list of extensions. These lists are split in categories and |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
231 ordered 'nicely' as defined by alphabetical and categeory order. |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
232 |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
233 Each entry in this index is a reference to the specific help page of the |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
234 command, topic, or extension at hand. |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
235 """ |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
236 ui.write(minirst.section(_(b"Mercurial Distributed SCM"))) |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
237 |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
238 missingdoc = _(b"(no help text available)") |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
239 |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
240 cats, h, syns = help._getcategorizedhelpcmds(ui, table, None) |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
241 ui.write(minirst.subsection(_(b"Commands"))) |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
242 |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
243 for cat in help.CATEGORY_ORDER: |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
244 catfns = sorted(cats.get(cat, [])) |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
245 if not catfns: |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
246 continue |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
247 |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
248 catname = gettext(help.CATEGORY_NAMES[cat]) |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
249 ui.write(minirst.subsubsection(catname)) |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
250 for c in catfns: |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
251 url = b'hg-%s.html' % c |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
252 ui.write(b" :`%s <%s>`__: %s" % (c, url, h[c])) |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
253 syns[c].remove(c) |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
254 if syns[c]: |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
255 ui.write(_(b" (aliases: *%s*)") % (b', '.join(syns[c]))) |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
256 ui.write(b"\n") |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
257 ui.write(b"\n\n") |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
258 |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
259 ui.write(b"\n\n") |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
260 |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
261 ui.write(minirst.subsection(_(b"Additional Help Topics"))) |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
262 topiccats, topicsyns = help._getcategorizedhelptopics(ui, helptable) |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
263 for cat in help.TOPIC_CATEGORY_ORDER: |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
264 topics = topiccats.get(cat, []) |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
265 if not topics: |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
266 continue |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
267 |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
268 catname = gettext(help.TOPIC_CATEGORY_NAMES[cat]) |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
269 ui.write(minirst.subsubsection(catname)) |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
270 for t, desc in topics: |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
271 url = b'topic-%s.html' % t |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
272 ui.write(b" :`%s <%s>`__: %s" % (t, url, desc)) |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
273 topicsyns[t].remove(t) |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
274 if topicsyns[t]: |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
275 ui.write(_(b" (aliases: *%s*)") % (b', '.join(topicsyns[t]))) |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
276 ui.write(b"\n") |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
277 ui.write(b"\n\n") |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
278 |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
279 ui.write(b"\n\n") |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
280 |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
281 # Add an alphabetical list of extensions, categorized by group. |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
282 sectionkeywords = [ |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
283 (b"(ADVANCED)", _(b"(ADVANCED)")), |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
284 (b"(EXPERIMENTAL)", _(b"(EXPERIMENTAL)")), |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
285 (b"(DEPRECATED)", _(b"(DEPRECATED)")), |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
286 ] |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
287 extensionsections = [ |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
288 (b"Extensions", []), |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
289 (b"Advanced Extensions", []), |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
290 (b"Experimental Extensions", []), |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
291 (b"Deprecated Extensions", []), |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
292 ] |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
293 for extensionname in allextensionnames(): |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
294 mod = extensions.load(ui, extensionname, None) |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
295 shortdoc, longdoc = _splitdoc(mod) |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
296 for i, kwds in enumerate(sectionkeywords): |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
297 if any([kwd in shortdoc for kwd in kwds]): |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
298 extensionsections[i + 1][1].append( |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
299 (extensionname, mod, shortdoc) |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
300 ) |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
301 break |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
302 else: |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
303 extensionsections[0][1].append((extensionname, mod, shortdoc)) |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
304 for sectiontitle, extinfos in extensionsections: |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
305 ui.write(minirst.subsection(_(sectiontitle))) |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
306 for extinfo in sorted(extinfos, key=lambda ei: ei[0]): |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
307 extensionname, mod, shortdoc = extinfo |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
308 url = b'ext-%s.html' % extensionname |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
309 ui.write( |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
310 minirst.subsubsection(b'`%s <%s>`__' % (extensionname, url)) |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
311 ) |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
312 ui.write(shortdoc) |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
313 ui.write(b'\n\n') |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
314 cmdtable = getattr(mod, 'cmdtable', None) |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
315 if cmdtable: |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
316 cmdnames = allcommandnames(cmdtable, debugcmds=debugcmds) |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
317 for f in sorted(cmdnames.keys()): |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
318 d = get_cmd(cmdnames[f], cmdtable) |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
319 ui.write(b':%s: ' % d[b'cmd']) |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
320 ui.write(d[b'desc'][0] or (missingdoc + b"\n")) |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
321 ui.write(b'\n') |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
322 ui.write(b'\n') |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
323 |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
324 |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
325 def showcommand(ui, mainname): |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
326 # Always pass debugcmds=True so that we find whatever command we are told |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
327 # to display. |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
328 cmdnames = allcommandnames(table, debugcmds=True) |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
329 allnames = cmdnames[mainname] |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
330 d = get_cmd(allnames, table) |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
331 |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
332 header = _rendertpl( |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
333 'cmdheader.txt', |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
334 { |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
335 'cmdname': mainname, |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
336 'cmdtitle': minirst.section(b'hg ' + mainname), |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
337 'cmdshortdesc': minirst.subsection(d[b'desc'][0]), |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
338 'cmdlongdesc': d[b'desc'][1], |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
339 'cmdsynopsis': d[b'synopsis'], |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
340 }, |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
341 ) |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
342 ui.write(header.encode()) |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
343 |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
344 _optionsprinter(ui, d, minirst.subsubsection) |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
345 if d[b'aliases']: |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
346 ui.write(minirst.subsubsection(_(b"Aliases"))) |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
347 ui.write(b"::\n\n ") |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
348 ui.write(b", ".join(d[b'aliases'])) |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
349 ui.write(b"\n") |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
350 |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
351 |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
352 def _splitdoc(obj): |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
353 objdoc = pycompat.getdoc(obj) |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
354 firstnl = objdoc.find(b'\n') |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
355 if firstnl > 0: |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
356 shortdoc = objdoc[:firstnl] |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
357 longdoc = objdoc[firstnl + 1 :] |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
358 else: |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
359 shortdoc = objdoc |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
360 longdoc = '' |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
361 return shortdoc.lstrip(), longdoc.lstrip() |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
362 |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
363 |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
364 def _rendertpl(tplname, data): |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
365 tplpath = os.path.join(os.path.dirname(__file__), 'templates', tplname) |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
366 with open(tplpath, 'r') as f: |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
367 tpl = f.read() |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
368 |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
369 if isinstance(tpl, bytes): |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
370 tpl = tpl.decode() |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
371 for k in data: |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
372 data[k] = data[k].decode() |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
373 |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
374 return tpl % data |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
375 |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
376 |
52020
1f5974f8f730
doc: refactor gendoc for better reusability
Ludovic Chabant <ludovic@chabant.com>
parents:
51844
diff
changeset
|
377 def gettopicstable(): |
19424
762e51ce3411
gendoc: add showtopic
Takumi IINO <trot.thunder@gmail.com>
parents:
19423
diff
changeset
|
378 extrahelptable = [ |
41004
e10641c48fa7
py3: byteify gendoc.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
40294
diff
changeset
|
379 ([b"common"], b'', loaddoc(b'common'), help.TOPIC_CATEGORY_MISC), |
e10641c48fa7
py3: byteify gendoc.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
40294
diff
changeset
|
380 ([b"hg.1"], b'', loaddoc(b'hg.1'), help.TOPIC_CATEGORY_CONFIG), |
e10641c48fa7
py3: byteify gendoc.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
40294
diff
changeset
|
381 ([b"hg-ssh.8"], b'', loaddoc(b'hg-ssh.8'), help.TOPIC_CATEGORY_CONFIG), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42252
diff
changeset
|
382 ( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42252
diff
changeset
|
383 [b"hgignore.5"], |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42252
diff
changeset
|
384 b'', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42252
diff
changeset
|
385 loaddoc(b'hgignore.5'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42252
diff
changeset
|
386 help.TOPIC_CATEGORY_CONFIG, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42252
diff
changeset
|
387 ), |
41004
e10641c48fa7
py3: byteify gendoc.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
40294
diff
changeset
|
388 ([b"hgrc.5"], b'', loaddoc(b'hgrc.5'), help.TOPIC_CATEGORY_CONFIG), |
52020
1f5974f8f730
doc: refactor gendoc for better reusability
Ludovic Chabant <ludovic@chabant.com>
parents:
51844
diff
changeset
|
389 ([b"hg-ssh.8.gendoc"], b'', b'', help.TOPIC_CATEGORY_CONFIG), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42252
diff
changeset
|
390 ( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42252
diff
changeset
|
391 [b"hgignore.5.gendoc"], |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42252
diff
changeset
|
392 b'', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42252
diff
changeset
|
393 loaddoc(b'hgignore'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42252
diff
changeset
|
394 help.TOPIC_CATEGORY_CONFIG, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42252
diff
changeset
|
395 ), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42252
diff
changeset
|
396 ( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42252
diff
changeset
|
397 [b"hgrc.5.gendoc"], |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42252
diff
changeset
|
398 b'', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42252
diff
changeset
|
399 loaddoc(b'config'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42252
diff
changeset
|
400 help.TOPIC_CATEGORY_CONFIG, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42252
diff
changeset
|
401 ), |
19424
762e51ce3411
gendoc: add showtopic
Takumi IINO <trot.thunder@gmail.com>
parents:
19423
diff
changeset
|
402 ] |
52020
1f5974f8f730
doc: refactor gendoc for better reusability
Ludovic Chabant <ludovic@chabant.com>
parents:
51844
diff
changeset
|
403 return helptable + extrahelptable |
19424
762e51ce3411
gendoc: add showtopic
Takumi IINO <trot.thunder@gmail.com>
parents:
19423
diff
changeset
|
404 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42252
diff
changeset
|
405 |
52020
1f5974f8f730
doc: refactor gendoc for better reusability
Ludovic Chabant <ludovic@chabant.com>
parents:
51844
diff
changeset
|
406 def findtopics(helptable, include=[], exclude=[]): |
1f5974f8f730
doc: refactor gendoc for better reusability
Ludovic Chabant <ludovic@chabant.com>
parents:
51844
diff
changeset
|
407 """Find topics whose names match the given include/exclude rules |
1f5974f8f730
doc: refactor gendoc for better reusability
Ludovic Chabant <ludovic@chabant.com>
parents:
51844
diff
changeset
|
408 |
1f5974f8f730
doc: refactor gendoc for better reusability
Ludovic Chabant <ludovic@chabant.com>
parents:
51844
diff
changeset
|
409 Note that exclude rules take precedence over include rules. |
1f5974f8f730
doc: refactor gendoc for better reusability
Ludovic Chabant <ludovic@chabant.com>
parents:
51844
diff
changeset
|
410 """ |
1f5974f8f730
doc: refactor gendoc for better reusability
Ludovic Chabant <ludovic@chabant.com>
parents:
51844
diff
changeset
|
411 found = [] |
40291
170926caf44c
help: adding support for command categories
rdamazio@google.com
parents:
32336
diff
changeset
|
412 for h in helptable: |
170926caf44c
help: adding support for command categories
rdamazio@google.com
parents:
32336
diff
changeset
|
413 names, sec, doc = h[0:3] |
19233
81d9a7f6f2e7
gendoc: extract print help topics into a dedicated function
Takumi IINO <trot.thunder@gmail.com>
parents:
19231
diff
changeset
|
414 if exclude and names[0] in exclude: |
81d9a7f6f2e7
gendoc: extract print help topics into a dedicated function
Takumi IINO <trot.thunder@gmail.com>
parents:
19231
diff
changeset
|
415 continue |
81d9a7f6f2e7
gendoc: extract print help topics into a dedicated function
Takumi IINO <trot.thunder@gmail.com>
parents:
19231
diff
changeset
|
416 if include and names[0] not in include: |
81d9a7f6f2e7
gendoc: extract print help topics into a dedicated function
Takumi IINO <trot.thunder@gmail.com>
parents:
19231
diff
changeset
|
417 continue |
52020
1f5974f8f730
doc: refactor gendoc for better reusability
Ludovic Chabant <ludovic@chabant.com>
parents:
51844
diff
changeset
|
418 found.append((names, sec, doc)) |
1f5974f8f730
doc: refactor gendoc for better reusability
Ludovic Chabant <ludovic@chabant.com>
parents:
51844
diff
changeset
|
419 return found |
1f5974f8f730
doc: refactor gendoc for better reusability
Ludovic Chabant <ludovic@chabant.com>
parents:
51844
diff
changeset
|
420 |
1f5974f8f730
doc: refactor gendoc for better reusability
Ludovic Chabant <ludovic@chabant.com>
parents:
51844
diff
changeset
|
421 |
1f5974f8f730
doc: refactor gendoc for better reusability
Ludovic Chabant <ludovic@chabant.com>
parents:
51844
diff
changeset
|
422 def showtopic(ui, topic, wraptpl=False): |
1f5974f8f730
doc: refactor gendoc for better reusability
Ludovic Chabant <ludovic@chabant.com>
parents:
51844
diff
changeset
|
423 """Render a help topic |
1f5974f8f730
doc: refactor gendoc for better reusability
Ludovic Chabant <ludovic@chabant.com>
parents:
51844
diff
changeset
|
424 |
1f5974f8f730
doc: refactor gendoc for better reusability
Ludovic Chabant <ludovic@chabant.com>
parents:
51844
diff
changeset
|
425 Args: |
1f5974f8f730
doc: refactor gendoc for better reusability
Ludovic Chabant <ludovic@chabant.com>
parents:
51844
diff
changeset
|
426 ui: the UI object to output to |
1f5974f8f730
doc: refactor gendoc for better reusability
Ludovic Chabant <ludovic@chabant.com>
parents:
51844
diff
changeset
|
427 topic: the topic name to output |
1f5974f8f730
doc: refactor gendoc for better reusability
Ludovic Chabant <ludovic@chabant.com>
parents:
51844
diff
changeset
|
428 wraptpl: whether to wrap the output in the individual help topic |
1f5974f8f730
doc: refactor gendoc for better reusability
Ludovic Chabant <ludovic@chabant.com>
parents:
51844
diff
changeset
|
429 pages' header/footer |
1f5974f8f730
doc: refactor gendoc for better reusability
Ludovic Chabant <ludovic@chabant.com>
parents:
51844
diff
changeset
|
430 """ |
1f5974f8f730
doc: refactor gendoc for better reusability
Ludovic Chabant <ludovic@chabant.com>
parents:
51844
diff
changeset
|
431 found = findtopics(gettopicstable(), include=[topic]) |
1f5974f8f730
doc: refactor gendoc for better reusability
Ludovic Chabant <ludovic@chabant.com>
parents:
51844
diff
changeset
|
432 if not found: |
1f5974f8f730
doc: refactor gendoc for better reusability
Ludovic Chabant <ludovic@chabant.com>
parents:
51844
diff
changeset
|
433 ui.write_err(_(b"ERROR: no such topic: %s\n") % topic) |
1f5974f8f730
doc: refactor gendoc for better reusability
Ludovic Chabant <ludovic@chabant.com>
parents:
51844
diff
changeset
|
434 sys.exit(1) |
1f5974f8f730
doc: refactor gendoc for better reusability
Ludovic Chabant <ludovic@chabant.com>
parents:
51844
diff
changeset
|
435 |
1f5974f8f730
doc: refactor gendoc for better reusability
Ludovic Chabant <ludovic@chabant.com>
parents:
51844
diff
changeset
|
436 if wraptpl: |
1f5974f8f730
doc: refactor gendoc for better reusability
Ludovic Chabant <ludovic@chabant.com>
parents:
51844
diff
changeset
|
437 header = _rendertpl( |
1f5974f8f730
doc: refactor gendoc for better reusability
Ludovic Chabant <ludovic@chabant.com>
parents:
51844
diff
changeset
|
438 'topicheader.txt', |
1f5974f8f730
doc: refactor gendoc for better reusability
Ludovic Chabant <ludovic@chabant.com>
parents:
51844
diff
changeset
|
439 {'topicname': topic, 'topictitle': minirst.section(found[0][1])}, |
1f5974f8f730
doc: refactor gendoc for better reusability
Ludovic Chabant <ludovic@chabant.com>
parents:
51844
diff
changeset
|
440 ) |
1f5974f8f730
doc: refactor gendoc for better reusability
Ludovic Chabant <ludovic@chabant.com>
parents:
51844
diff
changeset
|
441 ui.write(header.encode()) |
1f5974f8f730
doc: refactor gendoc for better reusability
Ludovic Chabant <ludovic@chabant.com>
parents:
51844
diff
changeset
|
442 helpprinter(ui, found, None) |
1f5974f8f730
doc: refactor gendoc for better reusability
Ludovic Chabant <ludovic@chabant.com>
parents:
51844
diff
changeset
|
443 return True |
1f5974f8f730
doc: refactor gendoc for better reusability
Ludovic Chabant <ludovic@chabant.com>
parents:
51844
diff
changeset
|
444 |
1f5974f8f730
doc: refactor gendoc for better reusability
Ludovic Chabant <ludovic@chabant.com>
parents:
51844
diff
changeset
|
445 |
1f5974f8f730
doc: refactor gendoc for better reusability
Ludovic Chabant <ludovic@chabant.com>
parents:
51844
diff
changeset
|
446 def helpprinter(ui, topics, sectionfunc): |
1f5974f8f730
doc: refactor gendoc for better reusability
Ludovic Chabant <ludovic@chabant.com>
parents:
51844
diff
changeset
|
447 """Print a help topic |
1f5974f8f730
doc: refactor gendoc for better reusability
Ludovic Chabant <ludovic@chabant.com>
parents:
51844
diff
changeset
|
448 |
1f5974f8f730
doc: refactor gendoc for better reusability
Ludovic Chabant <ludovic@chabant.com>
parents:
51844
diff
changeset
|
449 Args: |
1f5974f8f730
doc: refactor gendoc for better reusability
Ludovic Chabant <ludovic@chabant.com>
parents:
51844
diff
changeset
|
450 ui: the UI object to output to |
1f5974f8f730
doc: refactor gendoc for better reusability
Ludovic Chabant <ludovic@chabant.com>
parents:
51844
diff
changeset
|
451 topics: a list of help topics to output |
1f5974f8f730
doc: refactor gendoc for better reusability
Ludovic Chabant <ludovic@chabant.com>
parents:
51844
diff
changeset
|
452 sectionfunc: a callback to write the section title |
1f5974f8f730
doc: refactor gendoc for better reusability
Ludovic Chabant <ludovic@chabant.com>
parents:
51844
diff
changeset
|
453 """ |
1f5974f8f730
doc: refactor gendoc for better reusability
Ludovic Chabant <ludovic@chabant.com>
parents:
51844
diff
changeset
|
454 for h in topics: |
1f5974f8f730
doc: refactor gendoc for better reusability
Ludovic Chabant <ludovic@chabant.com>
parents:
51844
diff
changeset
|
455 names, sec, doc = h[0:3] |
19233
81d9a7f6f2e7
gendoc: extract print help topics into a dedicated function
Takumi IINO <trot.thunder@gmail.com>
parents:
19231
diff
changeset
|
456 for name in names: |
41004
e10641c48fa7
py3: byteify gendoc.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
40294
diff
changeset
|
457 ui.write(b".. _%s:\n" % name) |
e10641c48fa7
py3: byteify gendoc.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
40294
diff
changeset
|
458 ui.write(b"\n") |
19233
81d9a7f6f2e7
gendoc: extract print help topics into a dedicated function
Takumi IINO <trot.thunder@gmail.com>
parents:
19231
diff
changeset
|
459 if sectionfunc: |
81d9a7f6f2e7
gendoc: extract print help topics into a dedicated function
Takumi IINO <trot.thunder@gmail.com>
parents:
19231
diff
changeset
|
460 ui.write(sectionfunc(sec)) |
21793
e0b29a0c36c4
gendoc: restore use of callable() since it was readded in Python 3.2
Augie Fackler <raf@durin42.com>
parents:
20689
diff
changeset
|
461 if callable(doc): |
26413
e0c572d4d112
help: pass around ui to doc loader (API)
Yuya Nishihara <yuya@tcha.org>
parents:
26412
diff
changeset
|
462 doc = doc(ui) |
19233
81d9a7f6f2e7
gendoc: extract print help topics into a dedicated function
Takumi IINO <trot.thunder@gmail.com>
parents:
19231
diff
changeset
|
463 ui.write(doc) |
41004
e10641c48fa7
py3: byteify gendoc.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
40294
diff
changeset
|
464 ui.write(b"\n") |
19233
81d9a7f6f2e7
gendoc: extract print help topics into a dedicated function
Takumi IINO <trot.thunder@gmail.com>
parents:
19231
diff
changeset
|
465 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42252
diff
changeset
|
466 |
52021
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
467 def showextension(ui, extensionname, debugcmds=False): |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
468 """Render the help text for an extension |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
469 |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
470 Args: |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
471 ui: the UI object to output to |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
472 extensionname: the name of the extension to output |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
473 debugcmds: whether to include the extension's debug commands, if any |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
474 """ |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
475 mod = extensions.load(ui, extensionname, None) |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
476 |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
477 header = _rendertpl( |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
478 'extheader.txt', |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
479 {'extname': extensionname, 'exttitle': minirst.section(extensionname)}, |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
480 ) |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
481 ui.write(header.encode()) |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
482 |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
483 shortdoc, longdoc = _splitdoc(mod) |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
484 if shortdoc: |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
485 ui.write(b"%s\n\n" % gettext(shortdoc)) |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
486 if longdoc: |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
487 ui.write(minirst.subsection(_(b"Description"))) |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
488 ui.write(b"%s\n\n" % gettext(longdoc)) |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
489 |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
490 cmdtable = getattr(mod, 'cmdtable', None) |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
491 if cmdtable: |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
492 ui.write(minirst.subsection(_(b'Commands'))) |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
493 commandprinter( |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
494 ui, |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
495 cmdtable, |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
496 minirst.subsubsection, |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
497 minirst.subsubsubsection, |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
498 debugcmds=debugcmds, |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
499 ) |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
500 |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
501 |
52020
1f5974f8f730
doc: refactor gendoc for better reusability
Ludovic Chabant <ludovic@chabant.com>
parents:
51844
diff
changeset
|
502 def commandprinter(ui, cmdtable, sectionfunc, subsectionfunc, debugcmds=False): |
42252
a42cc325b682
gendoc: nest command headers under category headers
Sietse Brouwer <sbbrouwer@gmail.com>
parents:
42250
diff
changeset
|
503 """Render restructuredtext describing a list of commands and their |
a42cc325b682
gendoc: nest command headers under category headers
Sietse Brouwer <sbbrouwer@gmail.com>
parents:
42250
diff
changeset
|
504 documentations, grouped by command category. |
a42cc325b682
gendoc: nest command headers under category headers
Sietse Brouwer <sbbrouwer@gmail.com>
parents:
42250
diff
changeset
|
505 |
a42cc325b682
gendoc: nest command headers under category headers
Sietse Brouwer <sbbrouwer@gmail.com>
parents:
42250
diff
changeset
|
506 Args: |
a42cc325b682
gendoc: nest command headers under category headers
Sietse Brouwer <sbbrouwer@gmail.com>
parents:
42250
diff
changeset
|
507 ui: UI object to write the output to |
a42cc325b682
gendoc: nest command headers under category headers
Sietse Brouwer <sbbrouwer@gmail.com>
parents:
42250
diff
changeset
|
508 cmdtable: a dict that maps a string of the command name plus its aliases |
a42cc325b682
gendoc: nest command headers under category headers
Sietse Brouwer <sbbrouwer@gmail.com>
parents:
42250
diff
changeset
|
509 (separated with pipes) to a 3-tuple of (the command's function, a list |
a42cc325b682
gendoc: nest command headers under category headers
Sietse Brouwer <sbbrouwer@gmail.com>
parents:
42250
diff
changeset
|
510 of its option descriptions, and a string summarizing available |
a42cc325b682
gendoc: nest command headers under category headers
Sietse Brouwer <sbbrouwer@gmail.com>
parents:
42250
diff
changeset
|
511 options). Example, with aliases added for demonstration purposes: |
a42cc325b682
gendoc: nest command headers under category headers
Sietse Brouwer <sbbrouwer@gmail.com>
parents:
42250
diff
changeset
|
512 |
a42cc325b682
gendoc: nest command headers under category headers
Sietse Brouwer <sbbrouwer@gmail.com>
parents:
42250
diff
changeset
|
513 'phase|alias1|alias2': ( |
a42cc325b682
gendoc: nest command headers under category headers
Sietse Brouwer <sbbrouwer@gmail.com>
parents:
42250
diff
changeset
|
514 <function phase at 0x7f0816b05e60>, |
a42cc325b682
gendoc: nest command headers under category headers
Sietse Brouwer <sbbrouwer@gmail.com>
parents:
42250
diff
changeset
|
515 [ ('p', 'public', False, 'set changeset phase to public'), |
a42cc325b682
gendoc: nest command headers under category headers
Sietse Brouwer <sbbrouwer@gmail.com>
parents:
42250
diff
changeset
|
516 ..., |
a42cc325b682
gendoc: nest command headers under category headers
Sietse Brouwer <sbbrouwer@gmail.com>
parents:
42250
diff
changeset
|
517 ('r', 'rev', [], 'target revision', 'REV')], |
a42cc325b682
gendoc: nest command headers under category headers
Sietse Brouwer <sbbrouwer@gmail.com>
parents:
42250
diff
changeset
|
518 '[-p|-d|-s] [-f] [-r] [REV...]' |
a42cc325b682
gendoc: nest command headers under category headers
Sietse Brouwer <sbbrouwer@gmail.com>
parents:
42250
diff
changeset
|
519 ) |
a42cc325b682
gendoc: nest command headers under category headers
Sietse Brouwer <sbbrouwer@gmail.com>
parents:
42250
diff
changeset
|
520 sectionfunc: minirst function to format command category headers |
a42cc325b682
gendoc: nest command headers under category headers
Sietse Brouwer <sbbrouwer@gmail.com>
parents:
42250
diff
changeset
|
521 subsectionfunc: minirst function to format command headers |
a42cc325b682
gendoc: nest command headers under category headers
Sietse Brouwer <sbbrouwer@gmail.com>
parents:
42250
diff
changeset
|
522 """ |
52020
1f5974f8f730
doc: refactor gendoc for better reusability
Ludovic Chabant <ludovic@chabant.com>
parents:
51844
diff
changeset
|
523 h = allcommandnames(cmdtable, debugcmds=debugcmds) |
1814
7956893e8458
generate hg manpage from commands.py docstring
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
524 cmds = h.keys() |
7956893e8458
generate hg manpage from commands.py docstring
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
525 |
42249
3816e361e3d8
gendoc: group commands by category in man page and HTML help
Sietse Brouwer <sbbrouwer@gmail.com>
parents:
42248
diff
changeset
|
526 def helpcategory(cmd): |
3816e361e3d8
gendoc: group commands by category in man page and HTML help
Sietse Brouwer <sbbrouwer@gmail.com>
parents:
42248
diff
changeset
|
527 """Given a canonical command name from `cmds` (above), retrieve its |
3816e361e3d8
gendoc: group commands by category in man page and HTML help
Sietse Brouwer <sbbrouwer@gmail.com>
parents:
42248
diff
changeset
|
528 help category. If helpcategory is None, default to CATEGORY_NONE. |
3816e361e3d8
gendoc: group commands by category in man page and HTML help
Sietse Brouwer <sbbrouwer@gmail.com>
parents:
42248
diff
changeset
|
529 """ |
3816e361e3d8
gendoc: group commands by category in man page and HTML help
Sietse Brouwer <sbbrouwer@gmail.com>
parents:
42248
diff
changeset
|
530 fullname = h[cmd] |
3816e361e3d8
gendoc: group commands by category in man page and HTML help
Sietse Brouwer <sbbrouwer@gmail.com>
parents:
42248
diff
changeset
|
531 details = cmdtable[fullname] |
3816e361e3d8
gendoc: group commands by category in man page and HTML help
Sietse Brouwer <sbbrouwer@gmail.com>
parents:
42248
diff
changeset
|
532 helpcategory = details[0].helpcategory |
3816e361e3d8
gendoc: group commands by category in man page and HTML help
Sietse Brouwer <sbbrouwer@gmail.com>
parents:
42248
diff
changeset
|
533 return helpcategory or help.registrar.command.CATEGORY_NONE |
3816e361e3d8
gendoc: group commands by category in man page and HTML help
Sietse Brouwer <sbbrouwer@gmail.com>
parents:
42248
diff
changeset
|
534 |
42250
037a97d62625
gendoc: guarantee that all commands were processed
Sietse Brouwer <sbbrouwer@gmail.com>
parents:
42249
diff
changeset
|
535 cmdsbycategory = {category: [] for category in help.CATEGORY_ORDER} |
037a97d62625
gendoc: guarantee that all commands were processed
Sietse Brouwer <sbbrouwer@gmail.com>
parents:
42249
diff
changeset
|
536 for cmd in cmds: |
037a97d62625
gendoc: guarantee that all commands were processed
Sietse Brouwer <sbbrouwer@gmail.com>
parents:
42249
diff
changeset
|
537 # If a command category wasn't registered, the command won't get |
037a97d62625
gendoc: guarantee that all commands were processed
Sietse Brouwer <sbbrouwer@gmail.com>
parents:
42249
diff
changeset
|
538 # rendered below, so we raise an AssertionError. |
037a97d62625
gendoc: guarantee that all commands were processed
Sietse Brouwer <sbbrouwer@gmail.com>
parents:
42249
diff
changeset
|
539 if helpcategory(cmd) not in cmdsbycategory: |
037a97d62625
gendoc: guarantee that all commands were processed
Sietse Brouwer <sbbrouwer@gmail.com>
parents:
42249
diff
changeset
|
540 raise AssertionError( |
037a97d62625
gendoc: guarantee that all commands were processed
Sietse Brouwer <sbbrouwer@gmail.com>
parents:
42249
diff
changeset
|
541 "The following command did not register its (category) in " |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42252
diff
changeset
|
542 "help.CATEGORY_ORDER: %s (%s)" % (cmd, helpcategory(cmd)) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42252
diff
changeset
|
543 ) |
42250
037a97d62625
gendoc: guarantee that all commands were processed
Sietse Brouwer <sbbrouwer@gmail.com>
parents:
42249
diff
changeset
|
544 cmdsbycategory[helpcategory(cmd)].append(cmd) |
037a97d62625
gendoc: guarantee that all commands were processed
Sietse Brouwer <sbbrouwer@gmail.com>
parents:
42249
diff
changeset
|
545 |
42249
3816e361e3d8
gendoc: group commands by category in man page and HTML help
Sietse Brouwer <sbbrouwer@gmail.com>
parents:
42248
diff
changeset
|
546 # Print the help for each command. We present the commands grouped by |
3816e361e3d8
gendoc: group commands by category in man page and HTML help
Sietse Brouwer <sbbrouwer@gmail.com>
parents:
42248
diff
changeset
|
547 # category, and we use help.CATEGORY_ORDER as a guide for a helpful order |
3816e361e3d8
gendoc: group commands by category in man page and HTML help
Sietse Brouwer <sbbrouwer@gmail.com>
parents:
42248
diff
changeset
|
548 # in which to present the categories. |
3816e361e3d8
gendoc: group commands by category in man page and HTML help
Sietse Brouwer <sbbrouwer@gmail.com>
parents:
42248
diff
changeset
|
549 for category in help.CATEGORY_ORDER: |
3816e361e3d8
gendoc: group commands by category in man page and HTML help
Sietse Brouwer <sbbrouwer@gmail.com>
parents:
42248
diff
changeset
|
550 categorycmds = cmdsbycategory[category] |
3816e361e3d8
gendoc: group commands by category in man page and HTML help
Sietse Brouwer <sbbrouwer@gmail.com>
parents:
42248
diff
changeset
|
551 if not categorycmds: |
3816e361e3d8
gendoc: group commands by category in man page and HTML help
Sietse Brouwer <sbbrouwer@gmail.com>
parents:
42248
diff
changeset
|
552 # Skip empty categories |
3816e361e3d8
gendoc: group commands by category in man page and HTML help
Sietse Brouwer <sbbrouwer@gmail.com>
parents:
42248
diff
changeset
|
553 continue |
3816e361e3d8
gendoc: group commands by category in man page and HTML help
Sietse Brouwer <sbbrouwer@gmail.com>
parents:
42248
diff
changeset
|
554 # Print a section header for the category. |
3816e361e3d8
gendoc: group commands by category in man page and HTML help
Sietse Brouwer <sbbrouwer@gmail.com>
parents:
42248
diff
changeset
|
555 # For now, the category header is at the same level as the headers for |
3816e361e3d8
gendoc: group commands by category in man page and HTML help
Sietse Brouwer <sbbrouwer@gmail.com>
parents:
42248
diff
changeset
|
556 # the commands in the category; this is fixed in the next commit. |
3816e361e3d8
gendoc: group commands by category in man page and HTML help
Sietse Brouwer <sbbrouwer@gmail.com>
parents:
42248
diff
changeset
|
557 ui.write(sectionfunc(help.CATEGORY_NAMES[category])) |
3816e361e3d8
gendoc: group commands by category in man page and HTML help
Sietse Brouwer <sbbrouwer@gmail.com>
parents:
42248
diff
changeset
|
558 # Print each command in the category |
3816e361e3d8
gendoc: group commands by category in man page and HTML help
Sietse Brouwer <sbbrouwer@gmail.com>
parents:
42248
diff
changeset
|
559 for f in sorted(categorycmds): |
42248
0786b791b3b5
gendoc: indent loop to make next patch more legible
Sietse Brouwer <sbbrouwer@gmail.com>
parents:
41037
diff
changeset
|
560 d = get_cmd(h[f], cmdtable) |
42252
a42cc325b682
gendoc: nest command headers under category headers
Sietse Brouwer <sbbrouwer@gmail.com>
parents:
42250
diff
changeset
|
561 ui.write(subsectionfunc(d[b'cmd'])) |
42248
0786b791b3b5
gendoc: indent loop to make next patch more legible
Sietse Brouwer <sbbrouwer@gmail.com>
parents:
41037
diff
changeset
|
562 # short description |
0786b791b3b5
gendoc: indent loop to make next patch more legible
Sietse Brouwer <sbbrouwer@gmail.com>
parents:
41037
diff
changeset
|
563 ui.write(d[b'desc'][0]) |
12813
13fdef670c43
gendoc: support multi-line synopses
Martin Geisler <mg@lazybytes.net>
parents:
12812
diff
changeset
|
564 # synopsis |
42248
0786b791b3b5
gendoc: indent loop to make next patch more legible
Sietse Brouwer <sbbrouwer@gmail.com>
parents:
41037
diff
changeset
|
565 ui.write(b"::\n\n") |
0786b791b3b5
gendoc: indent loop to make next patch more legible
Sietse Brouwer <sbbrouwer@gmail.com>
parents:
41037
diff
changeset
|
566 synopsislines = d[b'synopsis'].splitlines() |
0786b791b3b5
gendoc: indent loop to make next patch more legible
Sietse Brouwer <sbbrouwer@gmail.com>
parents:
41037
diff
changeset
|
567 for line in synopsislines: |
0786b791b3b5
gendoc: indent loop to make next patch more legible
Sietse Brouwer <sbbrouwer@gmail.com>
parents:
41037
diff
changeset
|
568 # some commands (such as rebase) have a multi-line |
0786b791b3b5
gendoc: indent loop to make next patch more legible
Sietse Brouwer <sbbrouwer@gmail.com>
parents:
41037
diff
changeset
|
569 # synopsis |
0786b791b3b5
gendoc: indent loop to make next patch more legible
Sietse Brouwer <sbbrouwer@gmail.com>
parents:
41037
diff
changeset
|
570 ui.write(b" %s\n" % line) |
0786b791b3b5
gendoc: indent loop to make next patch more legible
Sietse Brouwer <sbbrouwer@gmail.com>
parents:
41037
diff
changeset
|
571 ui.write(b'\n') |
0786b791b3b5
gendoc: indent loop to make next patch more legible
Sietse Brouwer <sbbrouwer@gmail.com>
parents:
41037
diff
changeset
|
572 # description |
0786b791b3b5
gendoc: indent loop to make next patch more legible
Sietse Brouwer <sbbrouwer@gmail.com>
parents:
41037
diff
changeset
|
573 ui.write(b"%s\n\n" % d[b'desc'][1]) |
52020
1f5974f8f730
doc: refactor gendoc for better reusability
Ludovic Chabant <ludovic@chabant.com>
parents:
51844
diff
changeset
|
574 |
42248
0786b791b3b5
gendoc: indent loop to make next patch more legible
Sietse Brouwer <sbbrouwer@gmail.com>
parents:
41037
diff
changeset
|
575 # options |
52020
1f5974f8f730
doc: refactor gendoc for better reusability
Ludovic Chabant <ludovic@chabant.com>
parents:
51844
diff
changeset
|
576 def _optsection(s): |
1f5974f8f730
doc: refactor gendoc for better reusability
Ludovic Chabant <ludovic@chabant.com>
parents:
51844
diff
changeset
|
577 return b"%s:\n\n" % s |
1f5974f8f730
doc: refactor gendoc for better reusability
Ludovic Chabant <ludovic@chabant.com>
parents:
51844
diff
changeset
|
578 |
1f5974f8f730
doc: refactor gendoc for better reusability
Ludovic Chabant <ludovic@chabant.com>
parents:
51844
diff
changeset
|
579 _optionsprinter(ui, d, _optsection) |
42248
0786b791b3b5
gendoc: indent loop to make next patch more legible
Sietse Brouwer <sbbrouwer@gmail.com>
parents:
41037
diff
changeset
|
580 # aliases |
0786b791b3b5
gendoc: indent loop to make next patch more legible
Sietse Brouwer <sbbrouwer@gmail.com>
parents:
41037
diff
changeset
|
581 if d[b'aliases']: |
46518
85ec89c47a04
gendoc: use an empty comment so aliases are separated from previous elements
Kyle Lippincott <spectral@google.com>
parents:
46517
diff
changeset
|
582 # Note the empty comment, this is required to separate this |
85ec89c47a04
gendoc: use an empty comment so aliases are separated from previous elements
Kyle Lippincott <spectral@google.com>
parents:
46517
diff
changeset
|
583 # (which should be a blockquote) from any preceding things (such |
85ec89c47a04
gendoc: use an empty comment so aliases are separated from previous elements
Kyle Lippincott <spectral@google.com>
parents:
46517
diff
changeset
|
584 # as a definition list). |
85ec89c47a04
gendoc: use an empty comment so aliases are separated from previous elements
Kyle Lippincott <spectral@google.com>
parents:
46517
diff
changeset
|
585 ui.write( |
85ec89c47a04
gendoc: use an empty comment so aliases are separated from previous elements
Kyle Lippincott <spectral@google.com>
parents:
46517
diff
changeset
|
586 _(b"..\n\n aliases: %s\n\n") % b" ".join(d[b'aliases']) |
85ec89c47a04
gendoc: use an empty comment so aliases are separated from previous elements
Kyle Lippincott <spectral@google.com>
parents:
46517
diff
changeset
|
587 ) |
1814
7956893e8458
generate hg manpage from commands.py docstring
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
588 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42252
diff
changeset
|
589 |
52020
1f5974f8f730
doc: refactor gendoc for better reusability
Ludovic Chabant <ludovic@chabant.com>
parents:
51844
diff
changeset
|
590 def _optionsprinter(ui, cmd, sectionfunc): |
1f5974f8f730
doc: refactor gendoc for better reusability
Ludovic Chabant <ludovic@chabant.com>
parents:
51844
diff
changeset
|
591 """Outputs the list of options for a given command object""" |
1f5974f8f730
doc: refactor gendoc for better reusability
Ludovic Chabant <ludovic@chabant.com>
parents:
51844
diff
changeset
|
592 opt_output = list(cmd[b'opts']) |
1f5974f8f730
doc: refactor gendoc for better reusability
Ludovic Chabant <ludovic@chabant.com>
parents:
51844
diff
changeset
|
593 if opt_output: |
1f5974f8f730
doc: refactor gendoc for better reusability
Ludovic Chabant <ludovic@chabant.com>
parents:
51844
diff
changeset
|
594 opts_len = max([len(line[0]) for line in opt_output]) |
1f5974f8f730
doc: refactor gendoc for better reusability
Ludovic Chabant <ludovic@chabant.com>
parents:
51844
diff
changeset
|
595 ui.write(sectionfunc(_(b"Options"))) |
1f5974f8f730
doc: refactor gendoc for better reusability
Ludovic Chabant <ludovic@chabant.com>
parents:
51844
diff
changeset
|
596 multioccur = False |
1f5974f8f730
doc: refactor gendoc for better reusability
Ludovic Chabant <ludovic@chabant.com>
parents:
51844
diff
changeset
|
597 for optstr, desc in opt_output: |
1f5974f8f730
doc: refactor gendoc for better reusability
Ludovic Chabant <ludovic@chabant.com>
parents:
51844
diff
changeset
|
598 if desc: |
1f5974f8f730
doc: refactor gendoc for better reusability
Ludovic Chabant <ludovic@chabant.com>
parents:
51844
diff
changeset
|
599 s = b"%-*s %s" % (opts_len, optstr, desc) |
1f5974f8f730
doc: refactor gendoc for better reusability
Ludovic Chabant <ludovic@chabant.com>
parents:
51844
diff
changeset
|
600 else: |
1f5974f8f730
doc: refactor gendoc for better reusability
Ludovic Chabant <ludovic@chabant.com>
parents:
51844
diff
changeset
|
601 s = optstr |
1f5974f8f730
doc: refactor gendoc for better reusability
Ludovic Chabant <ludovic@chabant.com>
parents:
51844
diff
changeset
|
602 ui.write(b"%s\n" % s) |
1f5974f8f730
doc: refactor gendoc for better reusability
Ludovic Chabant <ludovic@chabant.com>
parents:
51844
diff
changeset
|
603 if optstr.endswith(b"[+]>"): |
1f5974f8f730
doc: refactor gendoc for better reusability
Ludovic Chabant <ludovic@chabant.com>
parents:
51844
diff
changeset
|
604 multioccur = True |
1f5974f8f730
doc: refactor gendoc for better reusability
Ludovic Chabant <ludovic@chabant.com>
parents:
51844
diff
changeset
|
605 if multioccur: |
1f5974f8f730
doc: refactor gendoc for better reusability
Ludovic Chabant <ludovic@chabant.com>
parents:
51844
diff
changeset
|
606 ui.write( |
1f5974f8f730
doc: refactor gendoc for better reusability
Ludovic Chabant <ludovic@chabant.com>
parents:
51844
diff
changeset
|
607 _(b"\n[+] marked option can be specified multiple times\n") |
1f5974f8f730
doc: refactor gendoc for better reusability
Ludovic Chabant <ludovic@chabant.com>
parents:
51844
diff
changeset
|
608 ) |
1f5974f8f730
doc: refactor gendoc for better reusability
Ludovic Chabant <ludovic@chabant.com>
parents:
51844
diff
changeset
|
609 ui.write(b"\n") |
1f5974f8f730
doc: refactor gendoc for better reusability
Ludovic Chabant <ludovic@chabant.com>
parents:
51844
diff
changeset
|
610 |
1f5974f8f730
doc: refactor gendoc for better reusability
Ludovic Chabant <ludovic@chabant.com>
parents:
51844
diff
changeset
|
611 |
1f5974f8f730
doc: refactor gendoc for better reusability
Ludovic Chabant <ludovic@chabant.com>
parents:
51844
diff
changeset
|
612 def allcommandnames(cmdtable, debugcmds=False): |
1f5974f8f730
doc: refactor gendoc for better reusability
Ludovic Chabant <ludovic@chabant.com>
parents:
51844
diff
changeset
|
613 """Get a collection of all command names in the given command table |
1f5974f8f730
doc: refactor gendoc for better reusability
Ludovic Chabant <ludovic@chabant.com>
parents:
51844
diff
changeset
|
614 |
1f5974f8f730
doc: refactor gendoc for better reusability
Ludovic Chabant <ludovic@chabant.com>
parents:
51844
diff
changeset
|
615 Args: |
1f5974f8f730
doc: refactor gendoc for better reusability
Ludovic Chabant <ludovic@chabant.com>
parents:
51844
diff
changeset
|
616 cmdtable: the command table to get the names from |
1f5974f8f730
doc: refactor gendoc for better reusability
Ludovic Chabant <ludovic@chabant.com>
parents:
51844
diff
changeset
|
617 debugcmds: whether to include debug commands |
1f5974f8f730
doc: refactor gendoc for better reusability
Ludovic Chabant <ludovic@chabant.com>
parents:
51844
diff
changeset
|
618 |
1f5974f8f730
doc: refactor gendoc for better reusability
Ludovic Chabant <ludovic@chabant.com>
parents:
51844
diff
changeset
|
619 Returns a dictionary where the keys are the main command names, and the |
1f5974f8f730
doc: refactor gendoc for better reusability
Ludovic Chabant <ludovic@chabant.com>
parents:
51844
diff
changeset
|
620 values are the "raw" names (in the form of `name|alias1|alias2`). |
1f5974f8f730
doc: refactor gendoc for better reusability
Ludovic Chabant <ludovic@chabant.com>
parents:
51844
diff
changeset
|
621 """ |
1f5974f8f730
doc: refactor gendoc for better reusability
Ludovic Chabant <ludovic@chabant.com>
parents:
51844
diff
changeset
|
622 allcmdnames = {} |
1f5974f8f730
doc: refactor gendoc for better reusability
Ludovic Chabant <ludovic@chabant.com>
parents:
51844
diff
changeset
|
623 for rawnames, attr in cmdtable.items(): |
1f5974f8f730
doc: refactor gendoc for better reusability
Ludovic Chabant <ludovic@chabant.com>
parents:
51844
diff
changeset
|
624 mainname = rawnames.split(b"|")[0].lstrip(b"^") |
1f5974f8f730
doc: refactor gendoc for better reusability
Ludovic Chabant <ludovic@chabant.com>
parents:
51844
diff
changeset
|
625 if not debugcmds and mainname.startswith(b"debug"): |
1f5974f8f730
doc: refactor gendoc for better reusability
Ludovic Chabant <ludovic@chabant.com>
parents:
51844
diff
changeset
|
626 continue |
1f5974f8f730
doc: refactor gendoc for better reusability
Ludovic Chabant <ludovic@chabant.com>
parents:
51844
diff
changeset
|
627 allcmdnames[mainname] = rawnames |
1f5974f8f730
doc: refactor gendoc for better reusability
Ludovic Chabant <ludovic@chabant.com>
parents:
51844
diff
changeset
|
628 return allcmdnames |
1f5974f8f730
doc: refactor gendoc for better reusability
Ludovic Chabant <ludovic@chabant.com>
parents:
51844
diff
changeset
|
629 |
1f5974f8f730
doc: refactor gendoc for better reusability
Ludovic Chabant <ludovic@chabant.com>
parents:
51844
diff
changeset
|
630 |
12781
0d09991f91ee
gendoc: automatically create help for default extensions.
Erik Zielke <ez@aragost.com>
parents:
12780
diff
changeset
|
631 def allextensionnames(): |
52020
1f5974f8f730
doc: refactor gendoc for better reusability
Ludovic Chabant <ludovic@chabant.com>
parents:
51844
diff
changeset
|
632 """Get a set of all known extension names""" |
41004
e10641c48fa7
py3: byteify gendoc.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
40294
diff
changeset
|
633 return set(extensions.enabled().keys()) | set(extensions.disabled().keys()) |
12781
0d09991f91ee
gendoc: automatically create help for default extensions.
Erik Zielke <ez@aragost.com>
parents:
12780
diff
changeset
|
634 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42252
diff
changeset
|
635 |
1814
7956893e8458
generate hg manpage from commands.py docstring
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
636 if __name__ == "__main__": |
52020
1f5974f8f730
doc: refactor gendoc for better reusability
Ludovic Chabant <ludovic@chabant.com>
parents:
51844
diff
changeset
|
637 parser = argparse.ArgumentParser( |
1f5974f8f730
doc: refactor gendoc for better reusability
Ludovic Chabant <ludovic@chabant.com>
parents:
51844
diff
changeset
|
638 prog='gendoc', description="Generate mercurial documentation files" |
1f5974f8f730
doc: refactor gendoc for better reusability
Ludovic Chabant <ludovic@chabant.com>
parents:
51844
diff
changeset
|
639 ) |
1f5974f8f730
doc: refactor gendoc for better reusability
Ludovic Chabant <ludovic@chabant.com>
parents:
51844
diff
changeset
|
640 parser.add_argument('doc', default='hg.1.gendoc', nargs='?') |
1f5974f8f730
doc: refactor gendoc for better reusability
Ludovic Chabant <ludovic@chabant.com>
parents:
51844
diff
changeset
|
641 parser.add_argument( |
1f5974f8f730
doc: refactor gendoc for better reusability
Ludovic Chabant <ludovic@chabant.com>
parents:
51844
diff
changeset
|
642 '-d', |
1f5974f8f730
doc: refactor gendoc for better reusability
Ludovic Chabant <ludovic@chabant.com>
parents:
51844
diff
changeset
|
643 '--debug-cmds', |
1f5974f8f730
doc: refactor gendoc for better reusability
Ludovic Chabant <ludovic@chabant.com>
parents:
51844
diff
changeset
|
644 action='store_true', |
1f5974f8f730
doc: refactor gendoc for better reusability
Ludovic Chabant <ludovic@chabant.com>
parents:
51844
diff
changeset
|
645 help="Show debug commands in help pages", |
1f5974f8f730
doc: refactor gendoc for better reusability
Ludovic Chabant <ludovic@chabant.com>
parents:
51844
diff
changeset
|
646 ) |
1f5974f8f730
doc: refactor gendoc for better reusability
Ludovic Chabant <ludovic@chabant.com>
parents:
51844
diff
changeset
|
647 args = parser.parse_args() |
1f5974f8f730
doc: refactor gendoc for better reusability
Ludovic Chabant <ludovic@chabant.com>
parents:
51844
diff
changeset
|
648 |
1f5974f8f730
doc: refactor gendoc for better reusability
Ludovic Chabant <ludovic@chabant.com>
parents:
51844
diff
changeset
|
649 doc = encoding.strtolocal(args.doc) |
1f5974f8f730
doc: refactor gendoc for better reusability
Ludovic Chabant <ludovic@chabant.com>
parents:
51844
diff
changeset
|
650 debugcmds = args.debug_cmds |
19425
81fbd4e66ff5
gendoc: dispatch print document content by commandline arguments
Takumi IINO <trot.thunder@gmail.com>
parents:
19424
diff
changeset
|
651 |
30559
d83ca854fa21
ui: factor out ui.load() to create a ui without loading configs (API)
Yuya Nishihara <yuya@tcha.org>
parents:
29397
diff
changeset
|
652 ui = uimod.ui.load() |
46517
eb36f7a71291
gendoc: add support for loading extensions from config settings
Kyle Lippincott <spectral@google.com>
parents:
46516
diff
changeset
|
653 # Trigger extensions to load. This is disabled by default because it uses |
eb36f7a71291
gendoc: add support for loading extensions from config settings
Kyle Lippincott <spectral@google.com>
parents:
46516
diff
changeset
|
654 # the current user's configuration, which is often not what is wanted. |
eb36f7a71291
gendoc: add support for loading extensions from config settings
Kyle Lippincott <spectral@google.com>
parents:
46516
diff
changeset
|
655 if encoding.environ.get(b'GENDOC_LOAD_CONFIGURED_EXTENSIONS', b'0') != b'0': |
eb36f7a71291
gendoc: add support for loading extensions from config settings
Kyle Lippincott <spectral@google.com>
parents:
46516
diff
changeset
|
656 extensions.loadall(ui) |
eb36f7a71291
gendoc: add support for loading extensions from config settings
Kyle Lippincott <spectral@google.com>
parents:
46516
diff
changeset
|
657 |
52020
1f5974f8f730
doc: refactor gendoc for better reusability
Ludovic Chabant <ludovic@chabant.com>
parents:
51844
diff
changeset
|
658 # ui.debugflag determines if the help module returns debug commands to us. |
1f5974f8f730
doc: refactor gendoc for better reusability
Ludovic Chabant <ludovic@chabant.com>
parents:
51844
diff
changeset
|
659 ui.debugflag = debugcmds |
1f5974f8f730
doc: refactor gendoc for better reusability
Ludovic Chabant <ludovic@chabant.com>
parents:
51844
diff
changeset
|
660 |
52021
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
661 # Render the 'all-in-one' giant documentation file |
41004
e10641c48fa7
py3: byteify gendoc.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
40294
diff
changeset
|
662 if doc == b'hg.1.gendoc': |
26412
7e8e3c0920a6
gendoc: use real ui in place of stdout
Yuya Nishihara <yuya@tcha.org>
parents:
21793
diff
changeset
|
663 showdoc(ui) |
52021
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
664 # Render a command/help-topic/extension name list (for internal use) |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
665 elif doc == b'commandlist': |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
666 showcommandlist(ui, debugcmds=debugcmds) |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
667 elif doc == b'topiclist': |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
668 showtopiclist(ui) |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
669 elif doc == b'extensionlist': |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
670 showextensionlist(ui) |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
671 # Render the help index/main page |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
672 elif doc == b'index': |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
673 showhelpindex(ui, debugcmds=debugcmds) |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
674 # Render an individual command/help-topic/extension page |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
675 elif doc.startswith(b'cmd-'): |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
676 showcommand(ui, doc[4:]) |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
677 elif doc.startswith(b'topic-'): |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
678 showtopic(ui, doc[6:], wraptpl=True) |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
679 elif doc.startswith(b'ext-'): |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
680 showextension(ui, doc[4:], debugcmds=debugcmds) |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
681 # Render a help-topic page without any title/footer, for later inclusion |
2a875530a023
doc: generate separate commands/topics/extension pages
Ludovic Chabant <ludovic@chabant.com>
parents:
52020
diff
changeset
|
682 # into a hand-written help text file |
19425
81fbd4e66ff5
gendoc: dispatch print document content by commandline arguments
Takumi IINO <trot.thunder@gmail.com>
parents:
19424
diff
changeset
|
683 else: |
52020
1f5974f8f730
doc: refactor gendoc for better reusability
Ludovic Chabant <ludovic@chabant.com>
parents:
51844
diff
changeset
|
684 showtopic(ui, doc) |