author | Augie Fackler <augie@google.com> |
Sun, 06 Oct 2019 09:45:02 -0400 | |
changeset 43076 | 2372284d9457 |
parent 42466 | 9d31581cc44e |
child 43077 | 687b865b95ad |
permissions | -rw-r--r-- |
3795
17a11f4ff260
Add basic support for help topics and a dates topic
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
1 |
# help.py - help data for mercurial |
17a11f4ff260
Add basic support for help topics and a dates topic
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
2 |
# |
17a11f4ff260
Add basic support for help topics and a dates topic
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
3 |
# Copyright 2006 Matt Mackall <mpm@selenic.com> |
17a11f4ff260
Add basic support for help topics and a dates topic
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
4 |
# |
8225
46293a0c7e9f
updated license to be explicit about GPL version 2
Martin Geisler <mg@lazybytes.net>
parents:
8159
diff
changeset
|
5 |
# This software may be used and distributed according to the terms of the |
10263 | 6 |
# GNU General Public License version 2 or any later version. |
3795
17a11f4ff260
Add basic support for help topics and a dates topic
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
7 |
|
27479
3ce1d50daa99
help: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27400
diff
changeset
|
8 |
from __future__ import absolute_import |
3ce1d50daa99
help: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27400
diff
changeset
|
9 |
|
3ce1d50daa99
help: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27400
diff
changeset
|
10 |
import itertools |
3ce1d50daa99
help: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27400
diff
changeset
|
11 |
import os |
40412
e928bedf0919
help: describe what ui.tweakdefaults changes, concretely
Valentin Gatien-Baron <vgatien-baron@janestreet.com>
parents:
40295
diff
changeset
|
12 |
import re |
27479
3ce1d50daa99
help: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27400
diff
changeset
|
13 |
import textwrap |
3ce1d50daa99
help: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27400
diff
changeset
|
14 |
|
3ce1d50daa99
help: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27400
diff
changeset
|
15 |
from .i18n import ( |
3ce1d50daa99
help: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27400
diff
changeset
|
16 |
_, |
3ce1d50daa99
help: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27400
diff
changeset
|
17 |
gettext, |
3ce1d50daa99
help: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27400
diff
changeset
|
18 |
) |
3ce1d50daa99
help: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27400
diff
changeset
|
19 |
from . import ( |
3ce1d50daa99
help: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27400
diff
changeset
|
20 |
cmdutil, |
3ce1d50daa99
help: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27400
diff
changeset
|
21 |
encoding, |
3ce1d50daa99
help: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27400
diff
changeset
|
22 |
error, |
3ce1d50daa99
help: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27400
diff
changeset
|
23 |
extensions, |
37094
979c8ce9022d
fancyopts: fix rendering of customopt defaults in help text
Daniel Ploch <dploch@google.com>
parents:
36928
diff
changeset
|
24 |
fancyopts, |
27479
3ce1d50daa99
help: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27400
diff
changeset
|
25 |
filemerge, |
3ce1d50daa99
help: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27400
diff
changeset
|
26 |
fileset, |
3ce1d50daa99
help: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27400
diff
changeset
|
27 |
minirst, |
32192
964c6be36590
py3: make sure opts are passed and used correctly in help command
Pulkit Goyal <7895pulkit@gmail.com>
parents:
32076
diff
changeset
|
28 |
pycompat, |
40291
170926caf44c
help: adding support for command categories
rdamazio@google.com
parents:
40263
diff
changeset
|
29 |
registrar, |
27479
3ce1d50daa99
help: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27400
diff
changeset
|
30 |
revset, |
3ce1d50daa99
help: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27400
diff
changeset
|
31 |
templatefilters, |
36928
521f6c7e1756
templater: split template functions to new module
Yuya Nishihara <yuya@tcha.org>
parents:
36481
diff
changeset
|
32 |
templatefuncs, |
27479
3ce1d50daa99
help: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27400
diff
changeset
|
33 |
templatekw, |
40412
e928bedf0919
help: describe what ui.tweakdefaults changes, concretely
Valentin Gatien-Baron <vgatien-baron@janestreet.com>
parents:
40295
diff
changeset
|
34 |
ui as uimod, |
27479
3ce1d50daa99
help: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27400
diff
changeset
|
35 |
util, |
3ce1d50daa99
help: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27400
diff
changeset
|
36 |
) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
37 |
from .hgweb import webcommands |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
38 |
from .utils import compression |
8863
7b19c3c0172b
help: adding a new help topic about extensions
Cédric Duval <cedricduval@free.fr>
parents:
8668
diff
changeset
|
39 |
|
32331
bd872f64a8ba
cleanup: use set literals
Martin von Zweigbergk <martinvonz@google.com>
parents:
32192
diff
changeset
|
40 |
_exclkeywords = { |
31097
6918c9215201
help: hide command line options marked as "advanced"
Jun Wu <quark@fb.com>
parents:
31081
diff
changeset
|
41 |
"(ADVANCED)", |
26370
44cc9f63a2f1
help: include parens in DEPRECATED/EXPERIMENTAL keywords
Yuya Nishihara <yuya@tcha.org>
parents:
26369
diff
changeset
|
42 |
"(DEPRECATED)", |
44cc9f63a2f1
help: include parens in DEPRECATED/EXPERIMENTAL keywords
Yuya Nishihara <yuya@tcha.org>
parents:
26369
diff
changeset
|
43 |
"(EXPERIMENTAL)", |
31097
6918c9215201
help: hide command line options marked as "advanced"
Jun Wu <quark@fb.com>
parents:
31081
diff
changeset
|
44 |
# i18n: "(ADVANCED)" is a keyword, must be translated consistently |
6918c9215201
help: hide command line options marked as "advanced"
Jun Wu <quark@fb.com>
parents:
31081
diff
changeset
|
45 |
_("(ADVANCED)"), |
26370
44cc9f63a2f1
help: include parens in DEPRECATED/EXPERIMENTAL keywords
Yuya Nishihara <yuya@tcha.org>
parents:
26369
diff
changeset
|
46 |
# i18n: "(DEPRECATED)" is a keyword, must be translated consistently |
44cc9f63a2f1
help: include parens in DEPRECATED/EXPERIMENTAL keywords
Yuya Nishihara <yuya@tcha.org>
parents:
26369
diff
changeset
|
47 |
_("(DEPRECATED)"), |
44cc9f63a2f1
help: include parens in DEPRECATED/EXPERIMENTAL keywords
Yuya Nishihara <yuya@tcha.org>
parents:
26369
diff
changeset
|
48 |
# i18n: "(EXPERIMENTAL)" is a keyword, must be translated consistently |
44cc9f63a2f1
help: include parens in DEPRECATED/EXPERIMENTAL keywords
Yuya Nishihara <yuya@tcha.org>
parents:
26369
diff
changeset
|
49 |
_("(EXPERIMENTAL)"), |
32331
bd872f64a8ba
cleanup: use set literals
Martin von Zweigbergk <martinvonz@google.com>
parents:
32192
diff
changeset
|
50 |
} |
26369
4799b5c4aaf4
help: define list of keywords that should be excluded from non-verbose output
Yuya Nishihara <yuya@tcha.org>
parents:
26238
diff
changeset
|
51 |
|
40291
170926caf44c
help: adding support for command categories
rdamazio@google.com
parents:
40263
diff
changeset
|
52 |
# The order in which command categories will be displayed. |
170926caf44c
help: adding support for command categories
rdamazio@google.com
parents:
40263
diff
changeset
|
53 |
# Extensions with custom categories should insert them into this list |
170926caf44c
help: adding support for command categories
rdamazio@google.com
parents:
40263
diff
changeset
|
54 |
# after/before the appropriate item, rather than replacing the list or |
170926caf44c
help: adding support for command categories
rdamazio@google.com
parents:
40263
diff
changeset
|
55 |
# assuming absolute positions. |
170926caf44c
help: adding support for command categories
rdamazio@google.com
parents:
40263
diff
changeset
|
56 |
CATEGORY_ORDER = [ |
40293
c303d65d2e34
help: assigning categories to existing commands
rdamazio@google.com
parents:
40292
diff
changeset
|
57 |
registrar.command.CATEGORY_REPO_CREATION, |
c303d65d2e34
help: assigning categories to existing commands
rdamazio@google.com
parents:
40292
diff
changeset
|
58 |
registrar.command.CATEGORY_REMOTE_REPO_MANAGEMENT, |
c303d65d2e34
help: assigning categories to existing commands
rdamazio@google.com
parents:
40292
diff
changeset
|
59 |
registrar.command.CATEGORY_COMMITTING, |
c303d65d2e34
help: assigning categories to existing commands
rdamazio@google.com
parents:
40292
diff
changeset
|
60 |
registrar.command.CATEGORY_CHANGE_MANAGEMENT, |
c303d65d2e34
help: assigning categories to existing commands
rdamazio@google.com
parents:
40292
diff
changeset
|
61 |
registrar.command.CATEGORY_CHANGE_ORGANIZATION, |
c303d65d2e34
help: assigning categories to existing commands
rdamazio@google.com
parents:
40292
diff
changeset
|
62 |
registrar.command.CATEGORY_FILE_CONTENTS, |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
63 |
registrar.command.CATEGORY_CHANGE_NAVIGATION, |
40293
c303d65d2e34
help: assigning categories to existing commands
rdamazio@google.com
parents:
40292
diff
changeset
|
64 |
registrar.command.CATEGORY_WORKING_DIRECTORY, |
c303d65d2e34
help: assigning categories to existing commands
rdamazio@google.com
parents:
40292
diff
changeset
|
65 |
registrar.command.CATEGORY_IMPORT_EXPORT, |
c303d65d2e34
help: assigning categories to existing commands
rdamazio@google.com
parents:
40292
diff
changeset
|
66 |
registrar.command.CATEGORY_MAINTENANCE, |
c303d65d2e34
help: assigning categories to existing commands
rdamazio@google.com
parents:
40292
diff
changeset
|
67 |
registrar.command.CATEGORY_HELP, |
c303d65d2e34
help: assigning categories to existing commands
rdamazio@google.com
parents:
40292
diff
changeset
|
68 |
registrar.command.CATEGORY_MISC, |
40291
170926caf44c
help: adding support for command categories
rdamazio@google.com
parents:
40263
diff
changeset
|
69 |
registrar.command.CATEGORY_NONE, |
170926caf44c
help: adding support for command categories
rdamazio@google.com
parents:
40263
diff
changeset
|
70 |
] |
170926caf44c
help: adding support for command categories
rdamazio@google.com
parents:
40263
diff
changeset
|
71 |
|
170926caf44c
help: adding support for command categories
rdamazio@google.com
parents:
40263
diff
changeset
|
72 |
# Human-readable category names. These are translated. |
170926caf44c
help: adding support for command categories
rdamazio@google.com
parents:
40263
diff
changeset
|
73 |
# Extensions with custom categories should add their names here. |
170926caf44c
help: adding support for command categories
rdamazio@google.com
parents:
40263
diff
changeset
|
74 |
CATEGORY_NAMES = { |
40293
c303d65d2e34
help: assigning categories to existing commands
rdamazio@google.com
parents:
40292
diff
changeset
|
75 |
registrar.command.CATEGORY_REPO_CREATION: 'Repository creation', |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
76 |
registrar.command.CATEGORY_REMOTE_REPO_MANAGEMENT: 'Remote repository management', |
40293
c303d65d2e34
help: assigning categories to existing commands
rdamazio@google.com
parents:
40292
diff
changeset
|
77 |
registrar.command.CATEGORY_COMMITTING: 'Change creation', |
c303d65d2e34
help: assigning categories to existing commands
rdamazio@google.com
parents:
40292
diff
changeset
|
78 |
registrar.command.CATEGORY_CHANGE_NAVIGATION: 'Change navigation', |
c303d65d2e34
help: assigning categories to existing commands
rdamazio@google.com
parents:
40292
diff
changeset
|
79 |
registrar.command.CATEGORY_CHANGE_MANAGEMENT: 'Change manipulation', |
c303d65d2e34
help: assigning categories to existing commands
rdamazio@google.com
parents:
40292
diff
changeset
|
80 |
registrar.command.CATEGORY_CHANGE_ORGANIZATION: 'Change organization', |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
81 |
registrar.command.CATEGORY_WORKING_DIRECTORY: 'Working directory management', |
40293
c303d65d2e34
help: assigning categories to existing commands
rdamazio@google.com
parents:
40292
diff
changeset
|
82 |
registrar.command.CATEGORY_FILE_CONTENTS: 'File content management', |
c303d65d2e34
help: assigning categories to existing commands
rdamazio@google.com
parents:
40292
diff
changeset
|
83 |
registrar.command.CATEGORY_IMPORT_EXPORT: 'Change import/export', |
c303d65d2e34
help: assigning categories to existing commands
rdamazio@google.com
parents:
40292
diff
changeset
|
84 |
registrar.command.CATEGORY_MAINTENANCE: 'Repository maintenance', |
c303d65d2e34
help: assigning categories to existing commands
rdamazio@google.com
parents:
40292
diff
changeset
|
85 |
registrar.command.CATEGORY_HELP: 'Help', |
c303d65d2e34
help: assigning categories to existing commands
rdamazio@google.com
parents:
40292
diff
changeset
|
86 |
registrar.command.CATEGORY_MISC: 'Miscellaneous commands', |
40291
170926caf44c
help: adding support for command categories
rdamazio@google.com
parents:
40263
diff
changeset
|
87 |
registrar.command.CATEGORY_NONE: 'Uncategorized commands', |
170926caf44c
help: adding support for command categories
rdamazio@google.com
parents:
40263
diff
changeset
|
88 |
} |
170926caf44c
help: adding support for command categories
rdamazio@google.com
parents:
40263
diff
changeset
|
89 |
|
40292
9c6473d2038b
help: splitting the topics by category
Rodrigo Damazio <rdamazio@google.com>
parents:
40291
diff
changeset
|
90 |
# Topic categories. |
40294
fabbf9310025
help: assigning topic categories
Rodrigo Damazio <rdamazio@google.com>
parents:
40293
diff
changeset
|
91 |
TOPIC_CATEGORY_IDS = 'ids' |
fabbf9310025
help: assigning topic categories
Rodrigo Damazio <rdamazio@google.com>
parents:
40293
diff
changeset
|
92 |
TOPIC_CATEGORY_OUTPUT = 'output' |
fabbf9310025
help: assigning topic categories
Rodrigo Damazio <rdamazio@google.com>
parents:
40293
diff
changeset
|
93 |
TOPIC_CATEGORY_CONFIG = 'config' |
fabbf9310025
help: assigning topic categories
Rodrigo Damazio <rdamazio@google.com>
parents:
40293
diff
changeset
|
94 |
TOPIC_CATEGORY_CONCEPTS = 'concepts' |
fabbf9310025
help: assigning topic categories
Rodrigo Damazio <rdamazio@google.com>
parents:
40293
diff
changeset
|
95 |
TOPIC_CATEGORY_MISC = 'misc' |
40292
9c6473d2038b
help: splitting the topics by category
Rodrigo Damazio <rdamazio@google.com>
parents:
40291
diff
changeset
|
96 |
TOPIC_CATEGORY_NONE = 'none' |
9c6473d2038b
help: splitting the topics by category
Rodrigo Damazio <rdamazio@google.com>
parents:
40291
diff
changeset
|
97 |
|
9c6473d2038b
help: splitting the topics by category
Rodrigo Damazio <rdamazio@google.com>
parents:
40291
diff
changeset
|
98 |
# The order in which topic categories will be displayed. |
9c6473d2038b
help: splitting the topics by category
Rodrigo Damazio <rdamazio@google.com>
parents:
40291
diff
changeset
|
99 |
# Extensions with custom categories should insert them into this list |
9c6473d2038b
help: splitting the topics by category
Rodrigo Damazio <rdamazio@google.com>
parents:
40291
diff
changeset
|
100 |
# after/before the appropriate item, rather than replacing the list or |
9c6473d2038b
help: splitting the topics by category
Rodrigo Damazio <rdamazio@google.com>
parents:
40291
diff
changeset
|
101 |
# assuming absolute positions. |
9c6473d2038b
help: splitting the topics by category
Rodrigo Damazio <rdamazio@google.com>
parents:
40291
diff
changeset
|
102 |
TOPIC_CATEGORY_ORDER = [ |
40294
fabbf9310025
help: assigning topic categories
Rodrigo Damazio <rdamazio@google.com>
parents:
40293
diff
changeset
|
103 |
TOPIC_CATEGORY_IDS, |
fabbf9310025
help: assigning topic categories
Rodrigo Damazio <rdamazio@google.com>
parents:
40293
diff
changeset
|
104 |
TOPIC_CATEGORY_OUTPUT, |
fabbf9310025
help: assigning topic categories
Rodrigo Damazio <rdamazio@google.com>
parents:
40293
diff
changeset
|
105 |
TOPIC_CATEGORY_CONFIG, |
fabbf9310025
help: assigning topic categories
Rodrigo Damazio <rdamazio@google.com>
parents:
40293
diff
changeset
|
106 |
TOPIC_CATEGORY_CONCEPTS, |
fabbf9310025
help: assigning topic categories
Rodrigo Damazio <rdamazio@google.com>
parents:
40293
diff
changeset
|
107 |
TOPIC_CATEGORY_MISC, |
40292
9c6473d2038b
help: splitting the topics by category
Rodrigo Damazio <rdamazio@google.com>
parents:
40291
diff
changeset
|
108 |
TOPIC_CATEGORY_NONE, |
9c6473d2038b
help: splitting the topics by category
Rodrigo Damazio <rdamazio@google.com>
parents:
40291
diff
changeset
|
109 |
] |
9c6473d2038b
help: splitting the topics by category
Rodrigo Damazio <rdamazio@google.com>
parents:
40291
diff
changeset
|
110 |
|
9c6473d2038b
help: splitting the topics by category
Rodrigo Damazio <rdamazio@google.com>
parents:
40291
diff
changeset
|
111 |
# Human-readable topic category names. These are translated. |
9c6473d2038b
help: splitting the topics by category
Rodrigo Damazio <rdamazio@google.com>
parents:
40291
diff
changeset
|
112 |
TOPIC_CATEGORY_NAMES = { |
40294
fabbf9310025
help: assigning topic categories
Rodrigo Damazio <rdamazio@google.com>
parents:
40293
diff
changeset
|
113 |
TOPIC_CATEGORY_IDS: 'Mercurial identifiers', |
fabbf9310025
help: assigning topic categories
Rodrigo Damazio <rdamazio@google.com>
parents:
40293
diff
changeset
|
114 |
TOPIC_CATEGORY_OUTPUT: 'Mercurial output', |
fabbf9310025
help: assigning topic categories
Rodrigo Damazio <rdamazio@google.com>
parents:
40293
diff
changeset
|
115 |
TOPIC_CATEGORY_CONFIG: 'Mercurial configuration', |
fabbf9310025
help: assigning topic categories
Rodrigo Damazio <rdamazio@google.com>
parents:
40293
diff
changeset
|
116 |
TOPIC_CATEGORY_CONCEPTS: 'Concepts', |
fabbf9310025
help: assigning topic categories
Rodrigo Damazio <rdamazio@google.com>
parents:
40293
diff
changeset
|
117 |
TOPIC_CATEGORY_MISC: 'Miscellaneous', |
fabbf9310025
help: assigning topic categories
Rodrigo Damazio <rdamazio@google.com>
parents:
40293
diff
changeset
|
118 |
TOPIC_CATEGORY_NONE: 'Uncategorized topics', |
40292
9c6473d2038b
help: splitting the topics by category
Rodrigo Damazio <rdamazio@google.com>
parents:
40291
diff
changeset
|
119 |
} |
9c6473d2038b
help: splitting the topics by category
Rodrigo Damazio <rdamazio@google.com>
parents:
40291
diff
changeset
|
120 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
121 |
|
20582
02c303f64917
help: exclude deprecated extensions in the disabled part of 'help extensions'
Augie Fackler <raf@durin42.com>
parents:
20034
diff
changeset
|
122 |
def listexts(header, exts, indent=1, showdeprecated=False): |
8879
d0a3eadfbdb3
help: more improvements for the extensions topic
Cédric Duval <cedricduval@free.fr>
parents:
8871
diff
changeset
|
123 |
'''return a text listing of the given extensions''' |
16852
af69b2b64d6e
help: format extension lists using RST
Olav Reinert <seroton10@gmail.com>
parents:
16845
diff
changeset
|
124 |
rst = [] |
af69b2b64d6e
help: format extension lists using RST
Olav Reinert <seroton10@gmail.com>
parents:
16845
diff
changeset
|
125 |
if exts: |
af69b2b64d6e
help: format extension lists using RST
Olav Reinert <seroton10@gmail.com>
parents:
16845
diff
changeset
|
126 |
for name, desc in sorted(exts.iteritems()): |
26371
51b309ce6c7d
help: unify handling of DEPRECATED/EXPERIMENTAL keywords
Yuya Nishihara <yuya@tcha.org>
parents:
26370
diff
changeset
|
127 |
if not showdeprecated and any(w in desc for w in _exclkeywords): |
20582
02c303f64917
help: exclude deprecated extensions in the disabled part of 'help extensions'
Augie Fackler <raf@durin42.com>
parents:
20034
diff
changeset
|
128 |
continue |
16852
af69b2b64d6e
help: format extension lists using RST
Olav Reinert <seroton10@gmail.com>
parents:
16845
diff
changeset
|
129 |
rst.append('%s:%s: %s\n' % (' ' * indent, name, desc)) |
27151
7625f6387fc4
help: make listexts less confusing for deprecated exts
timeless <timeless@mozdev.org>
parents:
26845
diff
changeset
|
130 |
if rst: |
7625f6387fc4
help: make listexts less confusing for deprecated exts
timeless <timeless@mozdev.org>
parents:
26845
diff
changeset
|
131 |
rst.insert(0, '\n%s\n\n' % header) |
16852
af69b2b64d6e
help: format extension lists using RST
Olav Reinert <seroton10@gmail.com>
parents:
16845
diff
changeset
|
132 |
return rst |
8864
cad6370a15cb
help: refactor extensions listing, and show enabled ones in the dedicated topic
Cédric Duval <cedricduval@free.fr>
parents:
8863
diff
changeset
|
133 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
134 |
|
26413
e0c572d4d112
help: pass around ui to doc loader (API)
Yuya Nishihara <yuya@tcha.org>
parents:
26371
diff
changeset
|
135 |
def extshelp(ui): |
e0c572d4d112
help: pass around ui to doc loader (API)
Yuya Nishihara <yuya@tcha.org>
parents:
26371
diff
changeset
|
136 |
rst = loaddoc('extensions')(ui).splitlines(True) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
137 |
rst.extend( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
138 |
listexts( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
139 |
_('enabled extensions:'), extensions.enabled(), showdeprecated=True |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
140 |
) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
141 |
) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
142 |
rst.extend( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
143 |
listexts( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
144 |
_('disabled extensions:'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
145 |
extensions.disabled(), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
146 |
showdeprecated=ui.verbose, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
147 |
) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
148 |
) |
16852
af69b2b64d6e
help: format extension lists using RST
Olav Reinert <seroton10@gmail.com>
parents:
16845
diff
changeset
|
149 |
doc = ''.join(rst) |
8863
7b19c3c0172b
help: adding a new help topic about extensions
Cédric Duval <cedricduval@free.fr>
parents:
8668
diff
changeset
|
150 |
return doc |
7013
f56e788fa292
i18n: mark help strings for translation
Martin Geisler <mg@daimi.au.dk>
parents:
7012
diff
changeset
|
151 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
152 |
|
22116
161085f87b95
help: roll option list header into option formatter
Matt Mackall <mpm@selenic.com>
parents:
22115
diff
changeset
|
153 |
def optrst(header, options, verbose): |
16781
c0b98f436cce
help: move some helper functions to help.py
Olav Reinert <seroton10@gmail.com>
parents:
16711
diff
changeset
|
154 |
data = [] |
c0b98f436cce
help: move some helper functions to help.py
Olav Reinert <seroton10@gmail.com>
parents:
16711
diff
changeset
|
155 |
multioccur = False |
c0b98f436cce
help: move some helper functions to help.py
Olav Reinert <seroton10@gmail.com>
parents:
16711
diff
changeset
|
156 |
for option in options: |
c0b98f436cce
help: move some helper functions to help.py
Olav Reinert <seroton10@gmail.com>
parents:
16711
diff
changeset
|
157 |
if len(option) == 5: |
c0b98f436cce
help: move some helper functions to help.py
Olav Reinert <seroton10@gmail.com>
parents:
16711
diff
changeset
|
158 |
shortopt, longopt, default, desc, optlabel = option |
c0b98f436cce
help: move some helper functions to help.py
Olav Reinert <seroton10@gmail.com>
parents:
16711
diff
changeset
|
159 |
else: |
c0b98f436cce
help: move some helper functions to help.py
Olav Reinert <seroton10@gmail.com>
parents:
16711
diff
changeset
|
160 |
shortopt, longopt, default, desc = option |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
161 |
optlabel = _("VALUE") # default label |
16781
c0b98f436cce
help: move some helper functions to help.py
Olav Reinert <seroton10@gmail.com>
parents:
16711
diff
changeset
|
162 |
|
26369
4799b5c4aaf4
help: define list of keywords that should be excluded from non-verbose output
Yuya Nishihara <yuya@tcha.org>
parents:
26238
diff
changeset
|
163 |
if not verbose and any(w in desc for w in _exclkeywords): |
16781
c0b98f436cce
help: move some helper functions to help.py
Olav Reinert <seroton10@gmail.com>
parents:
16711
diff
changeset
|
164 |
continue |
c0b98f436cce
help: move some helper functions to help.py
Olav Reinert <seroton10@gmail.com>
parents:
16711
diff
changeset
|
165 |
|
c0b98f436cce
help: move some helper functions to help.py
Olav Reinert <seroton10@gmail.com>
parents:
16711
diff
changeset
|
166 |
so = '' |
c0b98f436cce
help: move some helper functions to help.py
Olav Reinert <seroton10@gmail.com>
parents:
16711
diff
changeset
|
167 |
if shortopt: |
c0b98f436cce
help: move some helper functions to help.py
Olav Reinert <seroton10@gmail.com>
parents:
16711
diff
changeset
|
168 |
so = '-' + shortopt |
c0b98f436cce
help: move some helper functions to help.py
Olav Reinert <seroton10@gmail.com>
parents:
16711
diff
changeset
|
169 |
lo = '--' + longopt |
41019
fcc0a7ac9ebd
help: show "[no-]" only for default-on Flags
Martin von Zweigbergk <martinvonz@google.com>
parents:
40968
diff
changeset
|
170 |
if default is True: |
40968
f6187e60f792
help: present boolean arguments as "--[no-]foo"
Martin von Zweigbergk <martinvonz@google.com>
parents:
40967
diff
changeset
|
171 |
lo = '--[no-]' + longopt |
37094
979c8ce9022d
fancyopts: fix rendering of customopt defaults in help text
Daniel Ploch <dploch@google.com>
parents:
36928
diff
changeset
|
172 |
|
979c8ce9022d
fancyopts: fix rendering of customopt defaults in help text
Daniel Ploch <dploch@google.com>
parents:
36928
diff
changeset
|
173 |
if isinstance(default, fancyopts.customopt): |
37095
ef6215df2402
fancyopts: prevent mutation of the default value in customopts
Daniel Ploch <dploch@google.com>
parents:
37094
diff
changeset
|
174 |
default = default.getdefaultvalue() |
41020
e8e2a7656e83
help: hide default value for default-off flags
Martin von Zweigbergk <martinvonz@google.com>
parents:
41019
diff
changeset
|
175 |
if default and not callable(default): |
32642
d110fb58424c
help: convert flag default to bytes portably
Augie Fackler <raf@durin42.com>
parents:
32638
diff
changeset
|
176 |
# default is of unknown type, and in Python 2 we abused |
d110fb58424c
help: convert flag default to bytes portably
Augie Fackler <raf@durin42.com>
parents:
32638
diff
changeset
|
177 |
# the %s-shows-repr property to handle integers etc. To |
d110fb58424c
help: convert flag default to bytes portably
Augie Fackler <raf@durin42.com>
parents:
32638
diff
changeset
|
178 |
# match that behavior on Python 3, we do str(default) and |
d110fb58424c
help: convert flag default to bytes portably
Augie Fackler <raf@durin42.com>
parents:
32638
diff
changeset
|
179 |
# then convert it to bytes. |
40966
05abb5fb146a
help: use "default: on" instead of "default: True"
Martin von Zweigbergk <martinvonz@google.com>
parents:
40642
diff
changeset
|
180 |
defaultstr = pycompat.bytestr(default) |
41020
e8e2a7656e83
help: hide default value for default-off flags
Martin von Zweigbergk <martinvonz@google.com>
parents:
41019
diff
changeset
|
181 |
if default is True: |
e8e2a7656e83
help: hide default value for default-off flags
Martin von Zweigbergk <martinvonz@google.com>
parents:
41019
diff
changeset
|
182 |
defaultstr = _("on") |
40966
05abb5fb146a
help: use "default: on" instead of "default: True"
Martin von Zweigbergk <martinvonz@google.com>
parents:
40642
diff
changeset
|
183 |
desc += _(" (default: %s)") % defaultstr |
16781
c0b98f436cce
help: move some helper functions to help.py
Olav Reinert <seroton10@gmail.com>
parents:
16711
diff
changeset
|
184 |
|
c0b98f436cce
help: move some helper functions to help.py
Olav Reinert <seroton10@gmail.com>
parents:
16711
diff
changeset
|
185 |
if isinstance(default, list): |
c0b98f436cce
help: move some helper functions to help.py
Olav Reinert <seroton10@gmail.com>
parents:
16711
diff
changeset
|
186 |
lo += " %s [+]" % optlabel |
c0b98f436cce
help: move some helper functions to help.py
Olav Reinert <seroton10@gmail.com>
parents:
16711
diff
changeset
|
187 |
multioccur = True |
c0b98f436cce
help: move some helper functions to help.py
Olav Reinert <seroton10@gmail.com>
parents:
16711
diff
changeset
|
188 |
elif (default is not None) and not isinstance(default, bool): |
c0b98f436cce
help: move some helper functions to help.py
Olav Reinert <seroton10@gmail.com>
parents:
16711
diff
changeset
|
189 |
lo += " %s" % optlabel |
c0b98f436cce
help: move some helper functions to help.py
Olav Reinert <seroton10@gmail.com>
parents:
16711
diff
changeset
|
190 |
|
c0b98f436cce
help: move some helper functions to help.py
Olav Reinert <seroton10@gmail.com>
parents:
16711
diff
changeset
|
191 |
data.append((so, lo, desc)) |
c0b98f436cce
help: move some helper functions to help.py
Olav Reinert <seroton10@gmail.com>
parents:
16711
diff
changeset
|
192 |
|
22117
c1d93edcf004
help: fold repeatable option message into option table header
Matt Mackall <mpm@selenic.com>
parents:
22116
diff
changeset
|
193 |
if multioccur: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
194 |
header += _(" ([+] can be repeated)") |
16781
c0b98f436cce
help: move some helper functions to help.py
Olav Reinert <seroton10@gmail.com>
parents:
16711
diff
changeset
|
195 |
|
22116
161085f87b95
help: roll option list header into option formatter
Matt Mackall <mpm@selenic.com>
parents:
22115
diff
changeset
|
196 |
rst = ['\n%s:\n\n' % header] |
161085f87b95
help: roll option list header into option formatter
Matt Mackall <mpm@selenic.com>
parents:
22115
diff
changeset
|
197 |
rst.extend(minirst.maketable(data, 1)) |
16781
c0b98f436cce
help: move some helper functions to help.py
Olav Reinert <seroton10@gmail.com>
parents:
16711
diff
changeset
|
198 |
|
16815
e740746ea557
minirst: generate tables as a list of joined lines
Olav Reinert <seroton10@gmail.com>
parents:
16781
diff
changeset
|
199 |
return ''.join(rst) |
16781
c0b98f436cce
help: move some helper functions to help.py
Olav Reinert <seroton10@gmail.com>
parents:
16711
diff
changeset
|
200 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
201 |
|
17837
b623e323c561
help: indicate help omitting if help document is not fully displayed
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
17323
diff
changeset
|
202 |
def indicateomitted(rst, omitted, notomitted=None): |
b623e323c561
help: indicate help omitting if help document is not fully displayed
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
17323
diff
changeset
|
203 |
rst.append('\n\n.. container:: omitted\n\n %s\n\n' % omitted) |
b623e323c561
help: indicate help omitting if help document is not fully displayed
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
17323
diff
changeset
|
204 |
if notomitted: |
b623e323c561
help: indicate help omitting if help document is not fully displayed
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
17323
diff
changeset
|
205 |
rst.append('\n\n.. container:: notomitted\n\n %s\n\n' % notomitted) |
b623e323c561
help: indicate help omitting if help document is not fully displayed
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
17323
diff
changeset
|
206 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
207 |
|
40490
444861dc1e55
help: displaying documented aliases by default
rdamazio@google.com
parents:
40489
diff
changeset
|
208 |
def filtercmd(ui, cmd, func, kw, doc): |
27323 | 209 |
if not ui.debugflag and cmd.startswith("debug") and kw != "debug": |
40490
444861dc1e55
help: displaying documented aliases by default
rdamazio@google.com
parents:
40489
diff
changeset
|
210 |
# Debug command, and user is not looking for those. |
27323 | 211 |
return True |
40490
444861dc1e55
help: displaying documented aliases by default
rdamazio@google.com
parents:
40489
diff
changeset
|
212 |
if not ui.verbose: |
444861dc1e55
help: displaying documented aliases by default
rdamazio@google.com
parents:
40489
diff
changeset
|
213 |
if not kw and not doc: |
444861dc1e55
help: displaying documented aliases by default
rdamazio@google.com
parents:
40489
diff
changeset
|
214 |
# Command had no documentation, no point in showing it by default. |
444861dc1e55
help: displaying documented aliases by default
rdamazio@google.com
parents:
40489
diff
changeset
|
215 |
return True |
444861dc1e55
help: displaying documented aliases by default
rdamazio@google.com
parents:
40489
diff
changeset
|
216 |
if getattr(func, 'alias', False) and not getattr(func, 'owndoc', False): |
444861dc1e55
help: displaying documented aliases by default
rdamazio@google.com
parents:
40489
diff
changeset
|
217 |
# Alias didn't have its own documentation. |
444861dc1e55
help: displaying documented aliases by default
rdamazio@google.com
parents:
40489
diff
changeset
|
218 |
return True |
444861dc1e55
help: displaying documented aliases by default
rdamazio@google.com
parents:
40489
diff
changeset
|
219 |
if doc and any(w in doc for w in _exclkeywords): |
444861dc1e55
help: displaying documented aliases by default
rdamazio@google.com
parents:
40489
diff
changeset
|
220 |
# Documentation has excluded keywords. |
444861dc1e55
help: displaying documented aliases by default
rdamazio@google.com
parents:
40489
diff
changeset
|
221 |
return True |
444861dc1e55
help: displaying documented aliases by default
rdamazio@google.com
parents:
40489
diff
changeset
|
222 |
if kw == "shortlist" and not getattr(func, 'helpbasic', False): |
444861dc1e55
help: displaying documented aliases by default
rdamazio@google.com
parents:
40489
diff
changeset
|
223 |
# We're presenting the short list but the command is not basic. |
27323 | 224 |
return True |
40488 | 225 |
if ui.configbool('help', 'hidden-command.%s' % cmd): |
40490
444861dc1e55
help: displaying documented aliases by default
rdamazio@google.com
parents:
40489
diff
changeset
|
226 |
# Configuration explicitly hides the command. |
27323 | 227 |
return True |
228 |
return False |
|
229 |
||
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
230 |
|
40489 | 231 |
def filtertopic(ui, topic): |
232 |
return ui.configbool('help', 'hidden-topic.%s' % topic, False) |
|
233 |
||
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
234 |
|
32599
1b90036f42f0
help: pass commands module by argument
Yuya Nishihara <yuya@tcha.org>
parents:
32582
diff
changeset
|
235 |
def topicmatch(ui, commands, kw): |
16710
a17983680f12
help: introduce topicmatch for finding topics matching a keyword
Augie Fackler <raf@durin42.com>
parents:
16568
diff
changeset
|
236 |
"""Return help topics matching kw. |
a17983680f12
help: introduce topicmatch for finding topics matching a keyword
Augie Fackler <raf@durin42.com>
parents:
16568
diff
changeset
|
237 |
|
a17983680f12
help: introduce topicmatch for finding topics matching a keyword
Augie Fackler <raf@durin42.com>
parents:
16568
diff
changeset
|
238 |
Returns {'section': [(name, summary), ...], ...} where section is |
a17983680f12
help: introduce topicmatch for finding topics matching a keyword
Augie Fackler <raf@durin42.com>
parents:
16568
diff
changeset
|
239 |
one of topics, commands, extensions, or extensioncommands. |
a17983680f12
help: introduce topicmatch for finding topics matching a keyword
Augie Fackler <raf@durin42.com>
parents:
16568
diff
changeset
|
240 |
""" |
a17983680f12
help: introduce topicmatch for finding topics matching a keyword
Augie Fackler <raf@durin42.com>
parents:
16568
diff
changeset
|
241 |
kw = encoding.lower(kw) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
242 |
|
16710
a17983680f12
help: introduce topicmatch for finding topics matching a keyword
Augie Fackler <raf@durin42.com>
parents:
16568
diff
changeset
|
243 |
def lowercontains(container): |
16845
4594729c61ee
help: fix search with `-k` option in non-ASCII locales
Nikolaj Sjujskij <sterkrig@myopera.com>
parents:
16816
diff
changeset
|
244 |
return kw in encoding.lower(container) # translated in helptable |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
245 |
|
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
246 |
results = { |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
247 |
'topics': [], |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
248 |
'commands': [], |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
249 |
'extensions': [], |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
250 |
'extensioncommands': [], |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
251 |
} |
40292
9c6473d2038b
help: splitting the topics by category
Rodrigo Damazio <rdamazio@google.com>
parents:
40291
diff
changeset
|
252 |
for topic in helptable: |
9c6473d2038b
help: splitting the topics by category
Rodrigo Damazio <rdamazio@google.com>
parents:
40291
diff
changeset
|
253 |
names, header, doc = topic[0:3] |
22322
e284de138f00
help: only call doc() when it is callable
Gregory Szorc <gregory.szorc@gmail.com>
parents:
21796
diff
changeset
|
254 |
# Old extensions may use a str as doc. |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
255 |
if ( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
256 |
sum(map(lowercontains, names)) |
16710
a17983680f12
help: introduce topicmatch for finding topics matching a keyword
Augie Fackler <raf@durin42.com>
parents:
16568
diff
changeset
|
257 |
or lowercontains(header) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
258 |
or (callable(doc) and lowercontains(doc(ui))) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
259 |
): |
40489 | 260 |
name = names[0] |
261 |
if not filtertopic(ui, name): |
|
262 |
results['topics'].append((names[0], header)) |
|
16710
a17983680f12
help: introduce topicmatch for finding topics matching a keyword
Augie Fackler <raf@durin42.com>
parents:
16568
diff
changeset
|
263 |
for cmd, entry in commands.table.iteritems(): |
a17983680f12
help: introduce topicmatch for finding topics matching a keyword
Augie Fackler <raf@durin42.com>
parents:
16568
diff
changeset
|
264 |
if len(entry) == 3: |
a17983680f12
help: introduce topicmatch for finding topics matching a keyword
Augie Fackler <raf@durin42.com>
parents:
16568
diff
changeset
|
265 |
summary = entry[2] |
a17983680f12
help: introduce topicmatch for finding topics matching a keyword
Augie Fackler <raf@durin42.com>
parents:
16568
diff
changeset
|
266 |
else: |
a17983680f12
help: introduce topicmatch for finding topics matching a keyword
Augie Fackler <raf@durin42.com>
parents:
16568
diff
changeset
|
267 |
summary = '' |
16845
4594729c61ee
help: fix search with `-k` option in non-ASCII locales
Nikolaj Sjujskij <sterkrig@myopera.com>
parents:
16816
diff
changeset
|
268 |
# translate docs *before* searching there |
40490
444861dc1e55
help: displaying documented aliases by default
rdamazio@google.com
parents:
40489
diff
changeset
|
269 |
func = entry[0] |
444861dc1e55
help: displaying documented aliases by default
rdamazio@google.com
parents:
40489
diff
changeset
|
270 |
docs = _(pycompat.getdoc(func)) or '' |
16710
a17983680f12
help: introduce topicmatch for finding topics matching a keyword
Augie Fackler <raf@durin42.com>
parents:
16568
diff
changeset
|
271 |
if kw in cmd or lowercontains(summary) or lowercontains(docs): |
16845
4594729c61ee
help: fix search with `-k` option in non-ASCII locales
Nikolaj Sjujskij <sterkrig@myopera.com>
parents:
16816
diff
changeset
|
272 |
doclines = docs.splitlines() |
16710
a17983680f12
help: introduce topicmatch for finding topics matching a keyword
Augie Fackler <raf@durin42.com>
parents:
16568
diff
changeset
|
273 |
if doclines: |
a17983680f12
help: introduce topicmatch for finding topics matching a keyword
Augie Fackler <raf@durin42.com>
parents:
16568
diff
changeset
|
274 |
summary = doclines[0] |
36283
4174970c9147
help: use cmdutil.parsealiases() to resolve command name
Yuya Nishihara <yuya@tcha.org>
parents:
36282
diff
changeset
|
275 |
cmdname = cmdutil.parsealiases(cmd)[0] |
40490
444861dc1e55
help: displaying documented aliases by default
rdamazio@google.com
parents:
40489
diff
changeset
|
276 |
if filtercmd(ui, cmdname, func, kw, docs): |
27324
5456374561a7
help: call filtercmd from topicmatch
timeless <timeless@mozdev.org>
parents:
27323
diff
changeset
|
277 |
continue |
16710
a17983680f12
help: introduce topicmatch for finding topics matching a keyword
Augie Fackler <raf@durin42.com>
parents:
16568
diff
changeset
|
278 |
results['commands'].append((cmdname, summary)) |
a17983680f12
help: introduce topicmatch for finding topics matching a keyword
Augie Fackler <raf@durin42.com>
parents:
16568
diff
changeset
|
279 |
for name, docs in itertools.chain( |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
280 |
extensions.enabled(False).iteritems(), extensions.disabled().iteritems() |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
281 |
): |
28058
ff6e8dc659f8
help: don't crash in keyword search if an extension fails to provide docs
Simon Farnsworth <simonfar@fb.com>
parents:
27660
diff
changeset
|
282 |
if not docs: |
ff6e8dc659f8
help: don't crash in keyword search if an extension fails to provide docs
Simon Farnsworth <simonfar@fb.com>
parents:
27660
diff
changeset
|
283 |
continue |
26845
7a77ee434179
help: replace some str.split() calls by str.partition() or str.rpartition()
Anton Shestakov <av6@dwimlabs.net>
parents:
26587
diff
changeset
|
284 |
name = name.rpartition('.')[-1] |
16710
a17983680f12
help: introduce topicmatch for finding topics matching a keyword
Augie Fackler <raf@durin42.com>
parents:
16568
diff
changeset
|
285 |
if lowercontains(name) or lowercontains(docs): |
16845
4594729c61ee
help: fix search with `-k` option in non-ASCII locales
Nikolaj Sjujskij <sterkrig@myopera.com>
parents:
16816
diff
changeset
|
286 |
# extension docs are already translated |
4594729c61ee
help: fix search with `-k` option in non-ASCII locales
Nikolaj Sjujskij <sterkrig@myopera.com>
parents:
16816
diff
changeset
|
287 |
results['extensions'].append((name, docs.splitlines()[0])) |
34912
1e2454b60e59
help: do not abort topicmatch() because of unimportable extensions
Yuya Nishihara <yuya@tcha.org>
parents:
33499
diff
changeset
|
288 |
try: |
1e2454b60e59
help: do not abort topicmatch() because of unimportable extensions
Yuya Nishihara <yuya@tcha.org>
parents:
33499
diff
changeset
|
289 |
mod = extensions.load(ui, name, '') |
1e2454b60e59
help: do not abort topicmatch() because of unimportable extensions
Yuya Nishihara <yuya@tcha.org>
parents:
33499
diff
changeset
|
290 |
except ImportError: |
1e2454b60e59
help: do not abort topicmatch() because of unimportable extensions
Yuya Nishihara <yuya@tcha.org>
parents:
33499
diff
changeset
|
291 |
# debug message would be printed in extensions.load() |
1e2454b60e59
help: do not abort topicmatch() because of unimportable extensions
Yuya Nishihara <yuya@tcha.org>
parents:
33499
diff
changeset
|
292 |
continue |
16710
a17983680f12
help: introduce topicmatch for finding topics matching a keyword
Augie Fackler <raf@durin42.com>
parents:
16568
diff
changeset
|
293 |
for cmd, entry in getattr(mod, 'cmdtable', {}).iteritems(): |
16711
497deec204d1
help: add --keyword (-k) for searching help
Augie Fackler <raf@durin42.com>
parents:
16710
diff
changeset
|
294 |
if kw in cmd or (len(entry) > 2 and lowercontains(entry[2])): |
36283
4174970c9147
help: use cmdutil.parsealiases() to resolve command name
Yuya Nishihara <yuya@tcha.org>
parents:
36282
diff
changeset
|
295 |
cmdname = cmdutil.parsealiases(cmd)[0] |
40490
444861dc1e55
help: displaying documented aliases by default
rdamazio@google.com
parents:
40489
diff
changeset
|
296 |
func = entry[0] |
444861dc1e55
help: displaying documented aliases by default
rdamazio@google.com
parents:
40489
diff
changeset
|
297 |
cmddoc = pycompat.getdoc(func) |
32638
c9318beb7c1a
py3: convert __doc__ back to bytes in help.py
Yuya Nishihara <yuya@tcha.org>
parents:
32599
diff
changeset
|
298 |
if cmddoc: |
c9318beb7c1a
py3: convert __doc__ back to bytes in help.py
Yuya Nishihara <yuya@tcha.org>
parents:
32599
diff
changeset
|
299 |
cmddoc = gettext(cmddoc).splitlines()[0] |
16884
4fd1f1d7569b
help: fix 'hg help -k' matching an extension without docs
Thomas Arendsen Hein <thomas@intevation.de>
parents:
16855
diff
changeset
|
300 |
else: |
4fd1f1d7569b
help: fix 'hg help -k' matching an extension without docs
Thomas Arendsen Hein <thomas@intevation.de>
parents:
16855
diff
changeset
|
301 |
cmddoc = _('(no help text available)') |
40490
444861dc1e55
help: displaying documented aliases by default
rdamazio@google.com
parents:
40489
diff
changeset
|
302 |
if filtercmd(ui, cmdname, func, kw, cmddoc): |
27387
dfab0afde928
help: filter extension commands
timeless <timeless@mozdev.org>
parents:
27379
diff
changeset
|
303 |
continue |
16884
4fd1f1d7569b
help: fix 'hg help -k' matching an extension without docs
Thomas Arendsen Hein <thomas@intevation.de>
parents:
16855
diff
changeset
|
304 |
results['extensioncommands'].append((cmdname, cmddoc)) |
16710
a17983680f12
help: introduce topicmatch for finding topics matching a keyword
Augie Fackler <raf@durin42.com>
parents:
16568
diff
changeset
|
305 |
return results |
a17983680f12
help: introduce topicmatch for finding topics matching a keyword
Augie Fackler <raf@durin42.com>
parents:
16568
diff
changeset
|
306 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
307 |
|
27375
c4a062d090ee
help: teach loaddoc to load from a different directory
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27325
diff
changeset
|
308 |
def loaddoc(topic, subdir=None): |
9539
c904e76e3834
help: move help topics from mercurial/help.py to help/*.txt
Martin Geisler <mg@lazybytes.net>
parents:
9536
diff
changeset
|
309 |
"""Return a delayed loader for help/topic.txt.""" |
3798 | 310 |
|
26413
e0c572d4d112
help: pass around ui to doc loader (API)
Yuya Nishihara <yuya@tcha.org>
parents:
26371
diff
changeset
|
311 |
def loader(ui): |
22637
149141c3a25f
help: don't search randomly for help data - trust util.datapath
Mads Kiilerich <madski@unity3d.com>
parents:
22633
diff
changeset
|
312 |
docdir = os.path.join(util.datapath, 'help') |
27375
c4a062d090ee
help: teach loaddoc to load from a different directory
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27325
diff
changeset
|
313 |
if subdir: |
c4a062d090ee
help: teach loaddoc to load from a different directory
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27325
diff
changeset
|
314 |
docdir = os.path.join(docdir, subdir) |
9539
c904e76e3834
help: move help topics from mercurial/help.py to help/*.txt
Martin Geisler <mg@lazybytes.net>
parents:
9536
diff
changeset
|
315 |
path = os.path.join(docdir, topic + ".txt") |
14168
135e244776f0
prevent transient leaks of file handle by using new helper functions
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
14044
diff
changeset
|
316 |
doc = gettext(util.readfile(path)) |
12820
0edc0aa7432d
help: add topic rewriting hooks
Patrick Mezard <pmezard@gmail.com>
parents:
12818
diff
changeset
|
317 |
for rewriter in helphooks.get(topic, []): |
26414
c44b507e7c78
help: pass around ui to rewriter hooks (API)
Yuya Nishihara <yuya@tcha.org>
parents:
26413
diff
changeset
|
318 |
doc = rewriter(ui, topic, doc) |
12820
0edc0aa7432d
help: add topic rewriting hooks
Patrick Mezard <pmezard@gmail.com>
parents:
12818
diff
changeset
|
319 |
return doc |
0edc0aa7432d
help: add topic rewriting hooks
Patrick Mezard <pmezard@gmail.com>
parents:
12818
diff
changeset
|
320 |
|
9539
c904e76e3834
help: move help topics from mercurial/help.py to help/*.txt
Martin Geisler <mg@lazybytes.net>
parents:
9536
diff
changeset
|
321 |
return loader |
7677
6a0bc2dc9da6
help: add a topic about some of the templating features
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7387
diff
changeset
|
322 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
323 |
|
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
324 |
internalstable = sorted( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
325 |
[ |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
326 |
(['bundle2'], _('Bundle2'), loaddoc('bundle2', subdir='internals')), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
327 |
(['bundles'], _('Bundles'), loaddoc('bundles', subdir='internals')), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
328 |
(['cbor'], _('CBOR'), loaddoc('cbor', subdir='internals')), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
329 |
(['censor'], _('Censor'), loaddoc('censor', subdir='internals')), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
330 |
( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
331 |
['changegroups'], |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
332 |
_('Changegroups'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
333 |
loaddoc('changegroups', subdir='internals'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
334 |
), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
335 |
( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
336 |
['config'], |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
337 |
_('Config Registrar'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
338 |
loaddoc('config', subdir='internals'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
339 |
), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
340 |
( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
341 |
['extensions', 'extension'], |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
342 |
_('Extension API'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
343 |
loaddoc('extensions', subdir='internals'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
344 |
), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
345 |
( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
346 |
['mergestate'], |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
347 |
_('Mergestate'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
348 |
loaddoc('mergestate', subdir='internals'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
349 |
), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
350 |
( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
351 |
['requirements'], |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
352 |
_('Repository Requirements'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
353 |
loaddoc('requirements', subdir='internals'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
354 |
), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
355 |
( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
356 |
['revlogs'], |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
357 |
_('Revision Logs'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
358 |
loaddoc('revlogs', subdir='internals'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
359 |
), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
360 |
( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
361 |
['wireprotocol'], |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
362 |
_('Wire Protocol'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
363 |
loaddoc('wireprotocol', subdir='internals'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
364 |
), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
365 |
( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
366 |
['wireprotocolrpc'], |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
367 |
_('Wire Protocol RPC'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
368 |
loaddoc('wireprotocolrpc', subdir='internals'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
369 |
), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
370 |
( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
371 |
['wireprotocolv2'], |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
372 |
_('Wire Protocol Version 2'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
373 |
loaddoc('wireprotocolv2', subdir='internals'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
374 |
), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
375 |
] |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
376 |
) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
377 |
|
27376
fc810d950278
help: add "internals" topic
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27375
diff
changeset
|
378 |
|
fc810d950278
help: add "internals" topic
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27375
diff
changeset
|
379 |
def internalshelp(ui): |
fc810d950278
help: add "internals" topic
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27375
diff
changeset
|
380 |
"""Generate the index for the "internals" topic.""" |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
381 |
lines = [ |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
382 |
'To access a subtopic, use "hg help internals.{subtopic-name}"\n', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
383 |
'\n', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
384 |
] |
27376
fc810d950278
help: add "internals" topic
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27375
diff
changeset
|
385 |
for names, header, doc in internalstable: |
27400
64208bd4c580
help: add missed last new line to "internals" topic
Yuya Nishihara <yuya@tcha.org>
parents:
27387
diff
changeset
|
386 |
lines.append(' :%s: %s\n' % (names[0], header)) |
27376
fc810d950278
help: add "internals" topic
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27375
diff
changeset
|
387 |
|
27400
64208bd4c580
help: add missed last new line to "internals" topic
Yuya Nishihara <yuya@tcha.org>
parents:
27387
diff
changeset
|
388 |
return ''.join(lines) |
27376
fc810d950278
help: add "internals" topic
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27375
diff
changeset
|
389 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
390 |
|
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
391 |
helptable = sorted( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
392 |
[ |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
393 |
( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
394 |
['bundlespec'], |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
395 |
_("Bundle File Formats"), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
396 |
loaddoc('bundlespec'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
397 |
TOPIC_CATEGORY_CONCEPTS, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
398 |
), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
399 |
( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
400 |
['color'], |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
401 |
_("Colorizing Outputs"), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
402 |
loaddoc('color'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
403 |
TOPIC_CATEGORY_OUTPUT, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
404 |
), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
405 |
( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
406 |
["config", "hgrc"], |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
407 |
_("Configuration Files"), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
408 |
loaddoc('config'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
409 |
TOPIC_CATEGORY_CONFIG, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
410 |
), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
411 |
( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
412 |
['deprecated'], |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
413 |
_("Deprecated Features"), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
414 |
loaddoc('deprecated'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
415 |
TOPIC_CATEGORY_MISC, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
416 |
), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
417 |
(["dates"], _("Date Formats"), loaddoc('dates'), TOPIC_CATEGORY_OUTPUT), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
418 |
( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
419 |
["flags"], |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
420 |
_("Command-line flags"), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
421 |
loaddoc('flags'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
422 |
TOPIC_CATEGORY_CONFIG, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
423 |
), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
424 |
( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
425 |
["patterns"], |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
426 |
_("File Name Patterns"), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
427 |
loaddoc('patterns'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
428 |
TOPIC_CATEGORY_IDS, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
429 |
), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
430 |
( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
431 |
['environment', 'env'], |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
432 |
_('Environment Variables'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
433 |
loaddoc('environment'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
434 |
TOPIC_CATEGORY_CONFIG, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
435 |
), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
436 |
( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
437 |
['revisions', 'revs', 'revsets', 'revset', 'multirevs', 'mrevs'], |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
438 |
_('Specifying Revisions'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
439 |
loaddoc('revisions'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
440 |
TOPIC_CATEGORY_IDS, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
441 |
), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
442 |
( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
443 |
['filesets', 'fileset'], |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
444 |
_("Specifying File Sets"), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
445 |
loaddoc('filesets'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
446 |
TOPIC_CATEGORY_IDS, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
447 |
), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
448 |
(['diffs'], _('Diff Formats'), loaddoc('diffs'), TOPIC_CATEGORY_OUTPUT), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
449 |
( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
450 |
['merge-tools', 'mergetools', 'mergetool'], |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
451 |
_('Merge Tools'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
452 |
loaddoc('merge-tools'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
453 |
TOPIC_CATEGORY_CONFIG, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
454 |
), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
455 |
( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
456 |
['templating', 'templates', 'template', 'style'], |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
457 |
_('Template Usage'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
458 |
loaddoc('templates'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
459 |
TOPIC_CATEGORY_OUTPUT, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
460 |
), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
461 |
(['urls'], _('URL Paths'), loaddoc('urls'), TOPIC_CATEGORY_IDS), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
462 |
( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
463 |
["extensions"], |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
464 |
_("Using Additional Features"), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
465 |
extshelp, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
466 |
TOPIC_CATEGORY_CONFIG, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
467 |
), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
468 |
( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
469 |
["subrepos", "subrepo"], |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
470 |
_("Subrepositories"), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
471 |
loaddoc('subrepos'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
472 |
TOPIC_CATEGORY_CONCEPTS, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
473 |
), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
474 |
( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
475 |
["hgweb"], |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
476 |
_("Configuring hgweb"), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
477 |
loaddoc('hgweb'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
478 |
TOPIC_CATEGORY_CONFIG, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
479 |
), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
480 |
( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
481 |
["glossary"], |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
482 |
_("Glossary"), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
483 |
loaddoc('glossary'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
484 |
TOPIC_CATEGORY_CONCEPTS, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
485 |
), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
486 |
( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
487 |
["hgignore", "ignore"], |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
488 |
_("Syntax for Mercurial Ignore Files"), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
489 |
loaddoc('hgignore'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
490 |
TOPIC_CATEGORY_IDS, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
491 |
), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
492 |
( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
493 |
["phases"], |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
494 |
_("Working with Phases"), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
495 |
loaddoc('phases'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
496 |
TOPIC_CATEGORY_CONCEPTS, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
497 |
), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
498 |
( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
499 |
['scripting'], |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
500 |
_('Using Mercurial from scripts and automation'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
501 |
loaddoc('scripting'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
502 |
TOPIC_CATEGORY_MISC, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
503 |
), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
504 |
( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
505 |
['internals'], |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
506 |
_("Technical implementation topics"), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
507 |
internalshelp, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
508 |
TOPIC_CATEGORY_MISC, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
509 |
), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
510 |
( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
511 |
['pager'], |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
512 |
_("Pager Support"), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
513 |
loaddoc('pager'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
514 |
TOPIC_CATEGORY_CONFIG, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
515 |
), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
516 |
] |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
517 |
) |
12820
0edc0aa7432d
help: add topic rewriting hooks
Patrick Mezard <pmezard@gmail.com>
parents:
12818
diff
changeset
|
518 |
|
27379
2278870bb997
help: support loading sub-topics
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27378
diff
changeset
|
519 |
# Maps topics with sub-topics to a list of their sub-topics. |
2278870bb997
help: support loading sub-topics
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27378
diff
changeset
|
520 |
subtopics = { |
2278870bb997
help: support loading sub-topics
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27378
diff
changeset
|
521 |
'internals': internalstable, |
2278870bb997
help: support loading sub-topics
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27378
diff
changeset
|
522 |
} |
2278870bb997
help: support loading sub-topics
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27378
diff
changeset
|
523 |
|
12820
0edc0aa7432d
help: add topic rewriting hooks
Patrick Mezard <pmezard@gmail.com>
parents:
12818
diff
changeset
|
524 |
# Map topics to lists of callable taking the current topic help and |
0edc0aa7432d
help: add topic rewriting hooks
Patrick Mezard <pmezard@gmail.com>
parents:
12818
diff
changeset
|
525 |
# returning the updated version |
14318
1f46be4689ed
help: consolidate topic hooks in help.py
Matt Mackall <mpm@selenic.com>
parents:
14317
diff
changeset
|
526 |
helphooks = {} |
12820
0edc0aa7432d
help: add topic rewriting hooks
Patrick Mezard <pmezard@gmail.com>
parents:
12818
diff
changeset
|
527 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
528 |
|
12820
0edc0aa7432d
help: add topic rewriting hooks
Patrick Mezard <pmezard@gmail.com>
parents:
12818
diff
changeset
|
529 |
def addtopichook(topic, rewriter): |
0edc0aa7432d
help: add topic rewriting hooks
Patrick Mezard <pmezard@gmail.com>
parents:
12818
diff
changeset
|
530 |
helphooks.setdefault(topic, []).append(rewriter) |
13593
cc4721ed7a2a
help: extract items doc generation function
Patrick Mezard <pmezard@gmail.com>
parents:
12828
diff
changeset
|
531 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
532 |
|
26414
c44b507e7c78
help: pass around ui to rewriter hooks (API)
Yuya Nishihara <yuya@tcha.org>
parents:
26413
diff
changeset
|
533 |
def makeitemsdoc(ui, topic, doc, marker, items, dedent=False): |
13593
cc4721ed7a2a
help: extract items doc generation function
Patrick Mezard <pmezard@gmail.com>
parents:
12828
diff
changeset
|
534 |
"""Extract docstring from the items key to function mapping, build a |
26196
3a4620ad4490
help: fix makeitemsdoc English description
timeless@mozdev.org
parents:
25881
diff
changeset
|
535 |
single documentation block and use it to overwrite the marker in doc. |
13593
cc4721ed7a2a
help: extract items doc generation function
Patrick Mezard <pmezard@gmail.com>
parents:
12828
diff
changeset
|
536 |
""" |
cc4721ed7a2a
help: extract items doc generation function
Patrick Mezard <pmezard@gmail.com>
parents:
12828
diff
changeset
|
537 |
entries = [] |
cc4721ed7a2a
help: extract items doc generation function
Patrick Mezard <pmezard@gmail.com>
parents:
12828
diff
changeset
|
538 |
for name in sorted(items): |
32638
c9318beb7c1a
py3: convert __doc__ back to bytes in help.py
Yuya Nishihara <yuya@tcha.org>
parents:
32599
diff
changeset
|
539 |
text = (pycompat.getdoc(items[name]) or '').rstrip() |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
540 |
if not text or not ui.verbose and any(w in text for w in _exclkeywords): |
13593
cc4721ed7a2a
help: extract items doc generation function
Patrick Mezard <pmezard@gmail.com>
parents:
12828
diff
changeset
|
541 |
continue |
cc4721ed7a2a
help: extract items doc generation function
Patrick Mezard <pmezard@gmail.com>
parents:
12828
diff
changeset
|
542 |
text = gettext(text) |
24098
067540702f64
help: teach topic symbols how to dedent
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24080
diff
changeset
|
543 |
if dedent: |
32582
633c635a790a
help: work around textwrap.dedent() only working on strings
Augie Fackler <raf@durin42.com>
parents:
32580
diff
changeset
|
544 |
# Abuse latin1 to use textwrap.dedent() on bytes. |
633c635a790a
help: work around textwrap.dedent() only working on strings
Augie Fackler <raf@durin42.com>
parents:
32580
diff
changeset
|
545 |
text = textwrap.dedent(text.decode('latin1')).encode('latin1') |
13593
cc4721ed7a2a
help: extract items doc generation function
Patrick Mezard <pmezard@gmail.com>
parents:
12828
diff
changeset
|
546 |
lines = text.splitlines() |
16250
684864d54903
help: strip doctest from dochelp
"Yann E. MORIN" <yann.morin.1998@free.fr>
parents:
16126
diff
changeset
|
547 |
doclines = [(lines[0])] |
684864d54903
help: strip doctest from dochelp
"Yann E. MORIN" <yann.morin.1998@free.fr>
parents:
16126
diff
changeset
|
548 |
for l in lines[1:]: |
684864d54903
help: strip doctest from dochelp
"Yann E. MORIN" <yann.morin.1998@free.fr>
parents:
16126
diff
changeset
|
549 |
# Stop once we find some Python doctest |
684864d54903
help: strip doctest from dochelp
"Yann E. MORIN" <yann.morin.1998@free.fr>
parents:
16126
diff
changeset
|
550 |
if l.strip().startswith('>>>'): |
684864d54903
help: strip doctest from dochelp
"Yann E. MORIN" <yann.morin.1998@free.fr>
parents:
16126
diff
changeset
|
551 |
break |
24098
067540702f64
help: teach topic symbols how to dedent
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24080
diff
changeset
|
552 |
if dedent: |
067540702f64
help: teach topic symbols how to dedent
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24080
diff
changeset
|
553 |
doclines.append(l.rstrip()) |
067540702f64
help: teach topic symbols how to dedent
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24080
diff
changeset
|
554 |
else: |
067540702f64
help: teach topic symbols how to dedent
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24080
diff
changeset
|
555 |
doclines.append(' ' + l.strip()) |
16250
684864d54903
help: strip doctest from dochelp
"Yann E. MORIN" <yann.morin.1998@free.fr>
parents:
16126
diff
changeset
|
556 |
entries.append('\n'.join(doclines)) |
13593
cc4721ed7a2a
help: extract items doc generation function
Patrick Mezard <pmezard@gmail.com>
parents:
12828
diff
changeset
|
557 |
entries = '\n\n'.join(entries) |
cc4721ed7a2a
help: extract items doc generation function
Patrick Mezard <pmezard@gmail.com>
parents:
12828
diff
changeset
|
558 |
return doc.replace(marker, entries) |
14318
1f46be4689ed
help: consolidate topic hooks in help.py
Matt Mackall <mpm@selenic.com>
parents:
14317
diff
changeset
|
559 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
560 |
|
24098
067540702f64
help: teach topic symbols how to dedent
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24080
diff
changeset
|
561 |
def addtopicsymbols(topic, marker, symbols, dedent=False): |
26414
c44b507e7c78
help: pass around ui to rewriter hooks (API)
Yuya Nishihara <yuya@tcha.org>
parents:
26413
diff
changeset
|
562 |
def add(ui, topic, doc): |
c44b507e7c78
help: pass around ui to rewriter hooks (API)
Yuya Nishihara <yuya@tcha.org>
parents:
26413
diff
changeset
|
563 |
return makeitemsdoc(ui, topic, doc, marker, symbols, dedent=dedent) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
564 |
|
14318
1f46be4689ed
help: consolidate topic hooks in help.py
Matt Mackall <mpm@selenic.com>
parents:
14317
diff
changeset
|
565 |
addtopichook(topic, add) |
1f46be4689ed
help: consolidate topic hooks in help.py
Matt Mackall <mpm@selenic.com>
parents:
14317
diff
changeset
|
566 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
567 |
|
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
568 |
addtopicsymbols( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
569 |
'bundlespec', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
570 |
'.. bundlecompressionmarker', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
571 |
compression.bundlecompressiontopics(), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
572 |
) |
14686 | 573 |
addtopicsymbols('filesets', '.. predicatesmarker', fileset.symbols) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
574 |
addtopicsymbols('merge-tools', '.. internaltoolsmarker', filemerge.internalsdoc) |
30769
e520f0f4b1cf
help: merge revsets.txt into revisions.txt
Martin von Zweigbergk <martinvonz@google.com>
parents:
30615
diff
changeset
|
575 |
addtopicsymbols('revisions', '.. predicatesmarker', revset.symbols) |
26436
a2291c9c85a1
templatekw: remove dockeywords hack
Yuya Nishihara <yuya@tcha.org>
parents:
26415
diff
changeset
|
576 |
addtopicsymbols('templates', '.. keywordsmarker', templatekw.keywords) |
14318
1f46be4689ed
help: consolidate topic hooks in help.py
Matt Mackall <mpm@selenic.com>
parents:
14317
diff
changeset
|
577 |
addtopicsymbols('templates', '.. filtersmarker', templatefilters.filters) |
36928
521f6c7e1756
templater: split template functions to new module
Yuya Nishihara <yuya@tcha.org>
parents:
36481
diff
changeset
|
578 |
addtopicsymbols('templates', '.. functionsmarker', templatefuncs.funcs) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
579 |
addtopicsymbols( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
580 |
'hgweb', '.. webcommandsmarker', webcommands.commands, dedent=True |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
581 |
) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
582 |
|
18746
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
583 |
|
40412
e928bedf0919
help: describe what ui.tweakdefaults changes, concretely
Valentin Gatien-Baron <vgatien-baron@janestreet.com>
parents:
40295
diff
changeset
|
584 |
def inserttweakrc(ui, topic, doc): |
e928bedf0919
help: describe what ui.tweakdefaults changes, concretely
Valentin Gatien-Baron <vgatien-baron@janestreet.com>
parents:
40295
diff
changeset
|
585 |
marker = '.. tweakdefaultsmarker' |
e928bedf0919
help: describe what ui.tweakdefaults changes, concretely
Valentin Gatien-Baron <vgatien-baron@janestreet.com>
parents:
40295
diff
changeset
|
586 |
repl = uimod.tweakrc |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
587 |
|
40412
e928bedf0919
help: describe what ui.tweakdefaults changes, concretely
Valentin Gatien-Baron <vgatien-baron@janestreet.com>
parents:
40295
diff
changeset
|
588 |
def sub(m): |
e928bedf0919
help: describe what ui.tweakdefaults changes, concretely
Valentin Gatien-Baron <vgatien-baron@janestreet.com>
parents:
40295
diff
changeset
|
589 |
lines = [m.group(1) + s for s in repl.splitlines()] |
e928bedf0919
help: describe what ui.tweakdefaults changes, concretely
Valentin Gatien-Baron <vgatien-baron@janestreet.com>
parents:
40295
diff
changeset
|
590 |
return '\n'.join(lines) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
591 |
|
40412
e928bedf0919
help: describe what ui.tweakdefaults changes, concretely
Valentin Gatien-Baron <vgatien-baron@janestreet.com>
parents:
40295
diff
changeset
|
592 |
return re.sub(br'( *)%s' % re.escape(marker), sub, doc) |
e928bedf0919
help: describe what ui.tweakdefaults changes, concretely
Valentin Gatien-Baron <vgatien-baron@janestreet.com>
parents:
40295
diff
changeset
|
593 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
594 |
|
40412
e928bedf0919
help: describe what ui.tweakdefaults changes, concretely
Valentin Gatien-Baron <vgatien-baron@janestreet.com>
parents:
40295
diff
changeset
|
595 |
addtopichook('config', inserttweakrc) |
e928bedf0919
help: describe what ui.tweakdefaults changes, concretely
Valentin Gatien-Baron <vgatien-baron@janestreet.com>
parents:
40295
diff
changeset
|
596 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
597 |
|
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
598 |
def help_( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
599 |
ui, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
600 |
commands, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
601 |
name, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
602 |
unknowncmd=False, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
603 |
full=True, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
604 |
subtopic=None, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
605 |
fullname=None, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
606 |
**opts |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
607 |
): |
18746
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
608 |
''' |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
609 |
Generate the help for 'name' as unformatted restructured text. If |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
610 |
'name' is None, describe the commands available. |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
611 |
''' |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
612 |
|
32192
964c6be36590
py3: make sure opts are passed and used correctly in help command
Pulkit Goyal <7895pulkit@gmail.com>
parents:
32076
diff
changeset
|
613 |
opts = pycompat.byteskwargs(opts) |
18746
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
614 |
|
27378
c709b515218e
help: pass sub-topic into help query functions
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27377
diff
changeset
|
615 |
def helpcmd(name, subtopic=None): |
18746
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
616 |
try: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
617 |
aliases, entry = cmdutil.findcmd( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
618 |
name, commands.table, strict=unknowncmd |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
619 |
) |
25660
328739ea70c3
global: mass rewrite to use modern exception syntax
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24871
diff
changeset
|
620 |
except error.AmbiguousCommand as inst: |
40263
8cf459d8b111
py3: use py3 as the test tag, dropping the k
Martijn Pieters <mj@octobus.net>
parents:
39630
diff
changeset
|
621 |
# py3 fix: except vars can't be used outside the scope of the |
18746
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
622 |
# except block, nor can be used inside a lambda. python issue4617 |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
623 |
prefix = inst.args[0] |
36283
4174970c9147
help: use cmdutil.parsealiases() to resolve command name
Yuya Nishihara <yuya@tcha.org>
parents:
36282
diff
changeset
|
624 |
select = lambda c: cmdutil.parsealiases(c)[0].startswith(prefix) |
18746
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
625 |
rst = helplist(select) |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
626 |
return rst |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
627 |
|
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
628 |
rst = [] |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
629 |
|
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
630 |
# check if it's an invalid alias and display its error if it is |
22160
645457f73aa6
alias: keep error message in "badalias" so that help can see it
Yuya Nishihara <yuya@tcha.org>
parents:
22118
diff
changeset
|
631 |
if getattr(entry[0], 'badalias', None): |
22162
7ada34676db8
help: provide help of bad alias without executing aliascmd()
Yuya Nishihara <yuya@tcha.org>
parents:
22160
diff
changeset
|
632 |
rst.append(entry[0].badalias + '\n') |
7ada34676db8
help: provide help of bad alias without executing aliascmd()
Yuya Nishihara <yuya@tcha.org>
parents:
22160
diff
changeset
|
633 |
if entry[0].unknowncmd: |
7ada34676db8
help: provide help of bad alias without executing aliascmd()
Yuya Nishihara <yuya@tcha.org>
parents:
22160
diff
changeset
|
634 |
try: |
7ada34676db8
help: provide help of bad alias without executing aliascmd()
Yuya Nishihara <yuya@tcha.org>
parents:
22160
diff
changeset
|
635 |
rst.extend(helpextcmd(entry[0].cmdname)) |
7ada34676db8
help: provide help of bad alias without executing aliascmd()
Yuya Nishihara <yuya@tcha.org>
parents:
22160
diff
changeset
|
636 |
except error.UnknownCommand: |
7ada34676db8
help: provide help of bad alias without executing aliascmd()
Yuya Nishihara <yuya@tcha.org>
parents:
22160
diff
changeset
|
637 |
pass |
18746
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
638 |
return rst |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
639 |
|
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
640 |
# synopsis |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
641 |
if len(entry) > 2: |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
642 |
if entry[2].startswith('hg'): |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
643 |
rst.append("%s\n" % entry[2]) |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
644 |
else: |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
645 |
rst.append('hg %s %s\n' % (aliases[0], entry[2])) |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
646 |
else: |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
647 |
rst.append('hg %s\n' % aliases[0]) |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
648 |
# aliases |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
649 |
if full and not ui.quiet and len(aliases) > 1: |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
650 |
rst.append(_("\naliases: %s\n") % ', '.join(aliases[1:])) |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
651 |
rst.append('\n') |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
652 |
|
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
653 |
# description |
32638
c9318beb7c1a
py3: convert __doc__ back to bytes in help.py
Yuya Nishihara <yuya@tcha.org>
parents:
32599
diff
changeset
|
654 |
doc = gettext(pycompat.getdoc(entry[0])) |
18746
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
655 |
if not doc: |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
656 |
doc = _("(no help text available)") |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
657 |
if util.safehasattr(entry[0], 'definition'): # aliased command |
28828
3640c1702c43
help: report source of aliases
timeless <timeless@mozdev.org>
parents:
28523
diff
changeset
|
658 |
source = entry[0].source |
18746
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
659 |
if entry[0].definition.startswith('!'): # shell alias |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
660 |
doc = _('shell alias for: %s\n\n%s\n\ndefined by: %s\n') % ( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
661 |
entry[0].definition[1:], |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
662 |
doc, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
663 |
source, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
664 |
) |
18746
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
665 |
else: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
666 |
doc = _('alias for: hg %s\n\n%s\n\ndefined by: %s\n') % ( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
667 |
entry[0].definition, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
668 |
doc, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
669 |
source, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
670 |
) |
18746
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
671 |
doc = doc.splitlines(True) |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
672 |
if ui.quiet or not full: |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
673 |
rst.append(doc[0]) |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
674 |
else: |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
675 |
rst.extend(doc) |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
676 |
rst.append('\n') |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
677 |
|
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
678 |
# check if this command shadows a non-trivial (multi-line) |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
679 |
# extension help text |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
680 |
try: |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
681 |
mod = extensions.find(name) |
32638
c9318beb7c1a
py3: convert __doc__ back to bytes in help.py
Yuya Nishihara <yuya@tcha.org>
parents:
32599
diff
changeset
|
682 |
doc = gettext(pycompat.getdoc(mod)) or '' |
18746
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
683 |
if '\n' in doc.strip(): |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
684 |
msg = _( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
685 |
"(use 'hg help -e %s' to show help for " "the %s extension)" |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
686 |
) % (name, name) |
18746
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
687 |
rst.append('\n%s\n' % msg) |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
688 |
except KeyError: |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
689 |
pass |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
690 |
|
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
691 |
# options |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
692 |
if not ui.quiet and entry[1]: |
22116
161085f87b95
help: roll option list header into option formatter
Matt Mackall <mpm@selenic.com>
parents:
22115
diff
changeset
|
693 |
rst.append(optrst(_("options"), entry[1], ui.verbose)) |
18746
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
694 |
|
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
695 |
if ui.verbose: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
696 |
rst.append( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
697 |
optrst(_("global options"), commands.globalopts, ui.verbose) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
698 |
) |
18746
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
699 |
|
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
700 |
if not ui.verbose: |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
701 |
if not full: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
702 |
rst.append(_("\n(use 'hg %s -h' to show more help)\n") % name) |
18746
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
703 |
elif not ui.quiet: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
704 |
rst.append( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
705 |
_( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
706 |
'\n(some details hidden, use --verbose ' |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
707 |
'to show complete help)' |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
708 |
) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
709 |
) |
18746
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
710 |
|
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
711 |
return rst |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
712 |
|
27325
eadbbd14bdc1
help: fix help -c/help -e/help -k
timeless <timeless@mozdev.org>
parents:
27324
diff
changeset
|
713 |
def helplist(select=None, **opts): |
40291
170926caf44c
help: adding support for command categories
rdamazio@google.com
parents:
40263
diff
changeset
|
714 |
# Category -> list of commands |
170926caf44c
help: adding support for command categories
rdamazio@google.com
parents:
40263
diff
changeset
|
715 |
cats = {} |
170926caf44c
help: adding support for command categories
rdamazio@google.com
parents:
40263
diff
changeset
|
716 |
# Command -> short description |
18746
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
717 |
h = {} |
40291
170926caf44c
help: adding support for command categories
rdamazio@google.com
parents:
40263
diff
changeset
|
718 |
# Command -> string showing synonyms |
170926caf44c
help: adding support for command categories
rdamazio@google.com
parents:
40263
diff
changeset
|
719 |
syns = {} |
18746
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
720 |
for c, e in commands.table.iteritems(): |
36283
4174970c9147
help: use cmdutil.parsealiases() to resolve command name
Yuya Nishihara <yuya@tcha.org>
parents:
36282
diff
changeset
|
721 |
fs = cmdutil.parsealiases(c) |
4174970c9147
help: use cmdutil.parsealiases() to resolve command name
Yuya Nishihara <yuya@tcha.org>
parents:
36282
diff
changeset
|
722 |
f = fs[0] |
40291
170926caf44c
help: adding support for command categories
rdamazio@google.com
parents:
40263
diff
changeset
|
723 |
syns[f] = ', '.join(fs) |
170926caf44c
help: adding support for command categories
rdamazio@google.com
parents:
40263
diff
changeset
|
724 |
func = e[0] |
40295
fa88170c10bb
help: adding a proper declaration for shortlist/basic commands (API)
Rodrigo Damazio <rdamazio@google.com>
parents:
40294
diff
changeset
|
725 |
if select and not select(f): |
18746
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
726 |
continue |
40291
170926caf44c
help: adding support for command categories
rdamazio@google.com
parents:
40263
diff
changeset
|
727 |
doc = pycompat.getdoc(func) |
40490
444861dc1e55
help: displaying documented aliases by default
rdamazio@google.com
parents:
40489
diff
changeset
|
728 |
if filtercmd(ui, f, func, name, doc): |
18746
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
729 |
continue |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
730 |
doc = gettext(doc) |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
731 |
if not doc: |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
732 |
doc = _("(no help text available)") |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
733 |
h[f] = doc.splitlines()[0].rstrip() |
40291
170926caf44c
help: adding support for command categories
rdamazio@google.com
parents:
40263
diff
changeset
|
734 |
|
170926caf44c
help: adding support for command categories
rdamazio@google.com
parents:
40263
diff
changeset
|
735 |
cat = getattr(func, 'helpcategory', None) or ( |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
736 |
registrar.command.CATEGORY_NONE |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
737 |
) |
40291
170926caf44c
help: adding support for command categories
rdamazio@google.com
parents:
40263
diff
changeset
|
738 |
cats.setdefault(cat, []).append(f) |
18746
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
739 |
|
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
740 |
rst = [] |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
741 |
if not h: |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
742 |
if not ui.quiet: |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
743 |
rst.append(_('no commands defined\n')) |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
744 |
return rst |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
745 |
|
40291
170926caf44c
help: adding support for command categories
rdamazio@google.com
parents:
40263
diff
changeset
|
746 |
# Output top header. |
18746
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
747 |
if not ui.quiet: |
40291
170926caf44c
help: adding support for command categories
rdamazio@google.com
parents:
40263
diff
changeset
|
748 |
if name == "shortlist": |
170926caf44c
help: adding support for command categories
rdamazio@google.com
parents:
40263
diff
changeset
|
749 |
rst.append(_('basic commands:\n\n')) |
170926caf44c
help: adding support for command categories
rdamazio@google.com
parents:
40263
diff
changeset
|
750 |
elif name == "debug": |
170926caf44c
help: adding support for command categories
rdamazio@google.com
parents:
40263
diff
changeset
|
751 |
rst.append(_('debug commands (internal and unsupported):\n\n')) |
18746
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
752 |
else: |
40291
170926caf44c
help: adding support for command categories
rdamazio@google.com
parents:
40263
diff
changeset
|
753 |
rst.append(_('list of commands:\n')) |
170926caf44c
help: adding support for command categories
rdamazio@google.com
parents:
40263
diff
changeset
|
754 |
|
170926caf44c
help: adding support for command categories
rdamazio@google.com
parents:
40263
diff
changeset
|
755 |
def appendcmds(cmds): |
170926caf44c
help: adding support for command categories
rdamazio@google.com
parents:
40263
diff
changeset
|
756 |
cmds = sorted(cmds) |
170926caf44c
help: adding support for command categories
rdamazio@google.com
parents:
40263
diff
changeset
|
757 |
for c in cmds: |
170926caf44c
help: adding support for command categories
rdamazio@google.com
parents:
40263
diff
changeset
|
758 |
if ui.verbose: |
170926caf44c
help: adding support for command categories
rdamazio@google.com
parents:
40263
diff
changeset
|
759 |
rst.append(" :%s: %s\n" % (syns[c], h[c])) |
170926caf44c
help: adding support for command categories
rdamazio@google.com
parents:
40263
diff
changeset
|
760 |
else: |
170926caf44c
help: adding support for command categories
rdamazio@google.com
parents:
40263
diff
changeset
|
761 |
rst.append(' :%s: %s\n' % (c, h[c])) |
170926caf44c
help: adding support for command categories
rdamazio@google.com
parents:
40263
diff
changeset
|
762 |
|
170926caf44c
help: adding support for command categories
rdamazio@google.com
parents:
40263
diff
changeset
|
763 |
if name in ('shortlist', 'debug'): |
170926caf44c
help: adding support for command categories
rdamazio@google.com
parents:
40263
diff
changeset
|
764 |
# List without categories. |
170926caf44c
help: adding support for command categories
rdamazio@google.com
parents:
40263
diff
changeset
|
765 |
appendcmds(h) |
170926caf44c
help: adding support for command categories
rdamazio@google.com
parents:
40263
diff
changeset
|
766 |
else: |
170926caf44c
help: adding support for command categories
rdamazio@google.com
parents:
40263
diff
changeset
|
767 |
# Check that all categories have an order. |
170926caf44c
help: adding support for command categories
rdamazio@google.com
parents:
40263
diff
changeset
|
768 |
missing_order = set(cats.keys()) - set(CATEGORY_ORDER) |
170926caf44c
help: adding support for command categories
rdamazio@google.com
parents:
40263
diff
changeset
|
769 |
if missing_order: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
770 |
ui.develwarn( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
771 |
'help categories missing from CATEGORY_ORDER: %s' |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
772 |
% missing_order |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
773 |
) |
40291
170926caf44c
help: adding support for command categories
rdamazio@google.com
parents:
40263
diff
changeset
|
774 |
|
170926caf44c
help: adding support for command categories
rdamazio@google.com
parents:
40263
diff
changeset
|
775 |
# List per category. |
170926caf44c
help: adding support for command categories
rdamazio@google.com
parents:
40263
diff
changeset
|
776 |
for cat in CATEGORY_ORDER: |
170926caf44c
help: adding support for command categories
rdamazio@google.com
parents:
40263
diff
changeset
|
777 |
catfns = cats.get(cat, []) |
170926caf44c
help: adding support for command categories
rdamazio@google.com
parents:
40263
diff
changeset
|
778 |
if catfns: |
170926caf44c
help: adding support for command categories
rdamazio@google.com
parents:
40263
diff
changeset
|
779 |
if len(cats) > 1: |
170926caf44c
help: adding support for command categories
rdamazio@google.com
parents:
40263
diff
changeset
|
780 |
catname = gettext(CATEGORY_NAMES[cat]) |
170926caf44c
help: adding support for command categories
rdamazio@google.com
parents:
40263
diff
changeset
|
781 |
rst.append("\n%s:\n" % catname) |
170926caf44c
help: adding support for command categories
rdamazio@google.com
parents:
40263
diff
changeset
|
782 |
rst.append("\n") |
170926caf44c
help: adding support for command categories
rdamazio@google.com
parents:
40263
diff
changeset
|
783 |
appendcmds(catfns) |
18746
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
784 |
|
27325
eadbbd14bdc1
help: fix help -c/help -e/help -k
timeless <timeless@mozdev.org>
parents:
27324
diff
changeset
|
785 |
ex = opts.get |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
786 |
anyopts = ex(r'keyword') or not (ex(r'command') or ex(r'extension')) |
27325
eadbbd14bdc1
help: fix help -c/help -e/help -k
timeless <timeless@mozdev.org>
parents:
27324
diff
changeset
|
787 |
if not name and anyopts: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
788 |
exts = listexts( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
789 |
_('enabled extensions:'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
790 |
extensions.enabled(), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
791 |
showdeprecated=ui.verbose, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
792 |
) |
18746
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
793 |
if exts: |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
794 |
rst.append('\n') |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
795 |
rst.extend(exts) |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
796 |
|
40292
9c6473d2038b
help: splitting the topics by category
Rodrigo Damazio <rdamazio@google.com>
parents:
40291
diff
changeset
|
797 |
rst.append(_("\nadditional help topics:\n")) |
9c6473d2038b
help: splitting the topics by category
Rodrigo Damazio <rdamazio@google.com>
parents:
40291
diff
changeset
|
798 |
# Group commands by category. |
9c6473d2038b
help: splitting the topics by category
Rodrigo Damazio <rdamazio@google.com>
parents:
40291
diff
changeset
|
799 |
topiccats = {} |
9c6473d2038b
help: splitting the topics by category
Rodrigo Damazio <rdamazio@google.com>
parents:
40291
diff
changeset
|
800 |
for topic in helptable: |
9c6473d2038b
help: splitting the topics by category
Rodrigo Damazio <rdamazio@google.com>
parents:
40291
diff
changeset
|
801 |
names, header, doc = topic[0:3] |
9c6473d2038b
help: splitting the topics by category
Rodrigo Damazio <rdamazio@google.com>
parents:
40291
diff
changeset
|
802 |
if len(topic) > 3 and topic[3]: |
9c6473d2038b
help: splitting the topics by category
Rodrigo Damazio <rdamazio@google.com>
parents:
40291
diff
changeset
|
803 |
category = topic[3] |
9c6473d2038b
help: splitting the topics by category
Rodrigo Damazio <rdamazio@google.com>
parents:
40291
diff
changeset
|
804 |
else: |
9c6473d2038b
help: splitting the topics by category
Rodrigo Damazio <rdamazio@google.com>
parents:
40291
diff
changeset
|
805 |
category = TOPIC_CATEGORY_NONE |
9c6473d2038b
help: splitting the topics by category
Rodrigo Damazio <rdamazio@google.com>
parents:
40291
diff
changeset
|
806 |
|
40489 | 807 |
topicname = names[0] |
808 |
if not filtertopic(ui, topicname): |
|
809 |
topiccats.setdefault(category, []).append( |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
810 |
(topicname, header) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
811 |
) |
40292
9c6473d2038b
help: splitting the topics by category
Rodrigo Damazio <rdamazio@google.com>
parents:
40291
diff
changeset
|
812 |
|
9c6473d2038b
help: splitting the topics by category
Rodrigo Damazio <rdamazio@google.com>
parents:
40291
diff
changeset
|
813 |
# Check that all categories have an order. |
9c6473d2038b
help: splitting the topics by category
Rodrigo Damazio <rdamazio@google.com>
parents:
40291
diff
changeset
|
814 |
missing_order = set(topiccats.keys()) - set(TOPIC_CATEGORY_ORDER) |
9c6473d2038b
help: splitting the topics by category
Rodrigo Damazio <rdamazio@google.com>
parents:
40291
diff
changeset
|
815 |
if missing_order: |
9c6473d2038b
help: splitting the topics by category
Rodrigo Damazio <rdamazio@google.com>
parents:
40291
diff
changeset
|
816 |
ui.develwarn( |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
817 |
'help categories missing from TOPIC_CATEGORY_ORDER: %s' |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
818 |
% missing_order |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
819 |
) |
40292
9c6473d2038b
help: splitting the topics by category
Rodrigo Damazio <rdamazio@google.com>
parents:
40291
diff
changeset
|
820 |
|
9c6473d2038b
help: splitting the topics by category
Rodrigo Damazio <rdamazio@google.com>
parents:
40291
diff
changeset
|
821 |
# Output topics per category. |
9c6473d2038b
help: splitting the topics by category
Rodrigo Damazio <rdamazio@google.com>
parents:
40291
diff
changeset
|
822 |
for cat in TOPIC_CATEGORY_ORDER: |
9c6473d2038b
help: splitting the topics by category
Rodrigo Damazio <rdamazio@google.com>
parents:
40291
diff
changeset
|
823 |
topics = topiccats.get(cat, []) |
9c6473d2038b
help: splitting the topics by category
Rodrigo Damazio <rdamazio@google.com>
parents:
40291
diff
changeset
|
824 |
if topics: |
9c6473d2038b
help: splitting the topics by category
Rodrigo Damazio <rdamazio@google.com>
parents:
40291
diff
changeset
|
825 |
if len(topiccats) > 1: |
9c6473d2038b
help: splitting the topics by category
Rodrigo Damazio <rdamazio@google.com>
parents:
40291
diff
changeset
|
826 |
catname = gettext(TOPIC_CATEGORY_NAMES[cat]) |
9c6473d2038b
help: splitting the topics by category
Rodrigo Damazio <rdamazio@google.com>
parents:
40291
diff
changeset
|
827 |
rst.append("\n%s:\n" % catname) |
9c6473d2038b
help: splitting the topics by category
Rodrigo Damazio <rdamazio@google.com>
parents:
40291
diff
changeset
|
828 |
rst.append("\n") |
9c6473d2038b
help: splitting the topics by category
Rodrigo Damazio <rdamazio@google.com>
parents:
40291
diff
changeset
|
829 |
for t, desc in topics: |
9c6473d2038b
help: splitting the topics by category
Rodrigo Damazio <rdamazio@google.com>
parents:
40291
diff
changeset
|
830 |
rst.append(" :%s: %s\n" % (t, desc)) |
18746
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
831 |
|
22115
8465625f7364
help: refactor helplist optlist mess
Matt Mackall <mpm@selenic.com>
parents:
22114
diff
changeset
|
832 |
if ui.quiet: |
8465625f7364
help: refactor helplist optlist mess
Matt Mackall <mpm@selenic.com>
parents:
22114
diff
changeset
|
833 |
pass |
8465625f7364
help: refactor helplist optlist mess
Matt Mackall <mpm@selenic.com>
parents:
22114
diff
changeset
|
834 |
elif ui.verbose: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
835 |
rst.append( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
836 |
'\n%s\n' |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
837 |
% optrst(_("global options"), commands.globalopts, ui.verbose) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
838 |
) |
22115
8465625f7364
help: refactor helplist optlist mess
Matt Mackall <mpm@selenic.com>
parents:
22114
diff
changeset
|
839 |
if name == 'shortlist': |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
840 |
rst.append( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
841 |
_("\n(use 'hg help' for the full list " "of commands)\n") |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
842 |
) |
22115
8465625f7364
help: refactor helplist optlist mess
Matt Mackall <mpm@selenic.com>
parents:
22114
diff
changeset
|
843 |
else: |
8465625f7364
help: refactor helplist optlist mess
Matt Mackall <mpm@selenic.com>
parents:
22114
diff
changeset
|
844 |
if name == 'shortlist': |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
845 |
rst.append( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
846 |
_( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
847 |
"\n(use 'hg help' for the full list of commands " |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
848 |
"or 'hg -v' for details)\n" |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
849 |
) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
850 |
) |
22115
8465625f7364
help: refactor helplist optlist mess
Matt Mackall <mpm@selenic.com>
parents:
22114
diff
changeset
|
851 |
elif name and not full: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
852 |
rst.append( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
853 |
_("\n(use 'hg help %s' to show the full help " "text)\n") |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
854 |
% name |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
855 |
) |
40291
170926caf44c
help: adding support for command categories
rdamazio@google.com
parents:
40263
diff
changeset
|
856 |
elif name and syns and name in syns.keys(): |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
857 |
rst.append( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
858 |
_( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
859 |
"\n(use 'hg help -v -e %s' to show built-in " |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
860 |
"aliases and global options)\n" |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
861 |
) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
862 |
% name |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
863 |
) |
18746
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
864 |
else: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
865 |
rst.append( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
866 |
_( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
867 |
"\n(use 'hg help -v%s' to show built-in aliases " |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
868 |
"and global options)\n" |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
869 |
) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
870 |
% (name and " " + name or "") |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
871 |
) |
18746
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
872 |
return rst |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
873 |
|
27378
c709b515218e
help: pass sub-topic into help query functions
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27377
diff
changeset
|
874 |
def helptopic(name, subtopic=None): |
27379
2278870bb997
help: support loading sub-topics
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27378
diff
changeset
|
875 |
# Look for sub-topic entry first. |
2278870bb997
help: support loading sub-topics
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27378
diff
changeset
|
876 |
header, doc = None, None |
2278870bb997
help: support loading sub-topics
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27378
diff
changeset
|
877 |
if subtopic and name in subtopics: |
2278870bb997
help: support loading sub-topics
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27378
diff
changeset
|
878 |
for names, header, doc in subtopics[name]: |
2278870bb997
help: support loading sub-topics
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27378
diff
changeset
|
879 |
if subtopic in names: |
2278870bb997
help: support loading sub-topics
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27378
diff
changeset
|
880 |
break |
42412
a84564b1a0b1
help: check if a subtopic exists and raise an error if it doesn't (issue6145)
Nathan Goldbaum <nathan12343@gmail.com>
parents:
42057
diff
changeset
|
881 |
if not any(subtopic in s[0] for s in subtopics[name]): |
a84564b1a0b1
help: check if a subtopic exists and raise an error if it doesn't (issue6145)
Nathan Goldbaum <nathan12343@gmail.com>
parents:
42057
diff
changeset
|
882 |
raise error.UnknownCommand(name) |
27379
2278870bb997
help: support loading sub-topics
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27378
diff
changeset
|
883 |
|
2278870bb997
help: support loading sub-topics
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27378
diff
changeset
|
884 |
if not header: |
40292
9c6473d2038b
help: splitting the topics by category
Rodrigo Damazio <rdamazio@google.com>
parents:
40291
diff
changeset
|
885 |
for topic in helptable: |
9c6473d2038b
help: splitting the topics by category
Rodrigo Damazio <rdamazio@google.com>
parents:
40291
diff
changeset
|
886 |
names, header, doc = topic[0:3] |
27379
2278870bb997
help: support loading sub-topics
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27378
diff
changeset
|
887 |
if name in names: |
2278870bb997
help: support loading sub-topics
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27378
diff
changeset
|
888 |
break |
2278870bb997
help: support loading sub-topics
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27378
diff
changeset
|
889 |
else: |
2278870bb997
help: support loading sub-topics
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27378
diff
changeset
|
890 |
raise error.UnknownCommand(name) |
18746
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
891 |
|
18748
6e676fb6ea44
help: use a full header for topic titles
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
18746
diff
changeset
|
892 |
rst = [minirst.section(header)] |
6e676fb6ea44
help: use a full header for topic titles
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
18746
diff
changeset
|
893 |
|
18746
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
894 |
# description |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
895 |
if not doc: |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
896 |
rst.append(" %s\n" % _("(no help text available)")) |
21796
8225bb1f0ad3
help: restore use of callable() since it was readded in Python 3.2
Augie Fackler <raf@durin42.com>
parents:
21289
diff
changeset
|
897 |
if callable(doc): |
26413
e0c572d4d112
help: pass around ui to doc loader (API)
Yuya Nishihara <yuya@tcha.org>
parents:
26371
diff
changeset
|
898 |
rst += [" %s\n" % l for l in doc(ui).splitlines()] |
18746
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
899 |
|
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
900 |
if not ui.verbose: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
901 |
omitted = _( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
902 |
'(some details hidden, use --verbose' ' to show complete help)' |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
903 |
) |
18746
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
904 |
indicateomitted(rst, omitted) |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
905 |
|
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
906 |
try: |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
907 |
cmdutil.findcmd(name, commands.table) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
908 |
rst.append( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
909 |
_("\nuse 'hg help -c %s' to see help for " "the %s command\n") |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
910 |
% (name, name) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
911 |
) |
18746
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
912 |
except error.UnknownCommand: |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
913 |
pass |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
914 |
return rst |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
915 |
|
27378
c709b515218e
help: pass sub-topic into help query functions
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27377
diff
changeset
|
916 |
def helpext(name, subtopic=None): |
18746
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
917 |
try: |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
918 |
mod = extensions.find(name) |
32638
c9318beb7c1a
py3: convert __doc__ back to bytes in help.py
Yuya Nishihara <yuya@tcha.org>
parents:
32599
diff
changeset
|
919 |
doc = gettext(pycompat.getdoc(mod)) or _('no help text available') |
18746
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
920 |
except KeyError: |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
921 |
mod = None |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
922 |
doc = extensions.disabledext(name) |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
923 |
if not doc: |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
924 |
raise error.UnknownCommand(name) |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
925 |
|
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
926 |
if '\n' not in doc: |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
927 |
head, tail = doc, "" |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
928 |
else: |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
929 |
head, tail = doc.split('\n', 1) |
26845
7a77ee434179
help: replace some str.split() calls by str.partition() or str.rpartition()
Anton Shestakov <av6@dwimlabs.net>
parents:
26587
diff
changeset
|
930 |
rst = [_('%s extension - %s\n\n') % (name.rpartition('.')[-1], head)] |
18746
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
931 |
if tail: |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
932 |
rst.extend(tail.splitlines(True)) |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
933 |
rst.append('\n') |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
934 |
|
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
935 |
if not ui.verbose: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
936 |
omitted = _( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
937 |
'(some details hidden, use --verbose' ' to show complete help)' |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
938 |
) |
18746
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
939 |
indicateomitted(rst, omitted) |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
940 |
|
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
941 |
if mod: |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
942 |
try: |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
943 |
ct = mod.cmdtable |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
944 |
except AttributeError: |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
945 |
ct = {} |
42057
566daffc607d
cleanup: use set literals where possible
Martin von Zweigbergk <martinvonz@google.com>
parents:
42041
diff
changeset
|
946 |
modcmds = {c.partition('|')[0] for c in ct} |
18746
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
947 |
rst.extend(helplist(modcmds.__contains__)) |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
948 |
else: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
949 |
rst.append( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
950 |
_( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
951 |
"(use 'hg help extensions' for information on enabling" |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
952 |
" extensions)\n" |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
953 |
) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
954 |
) |
18746
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
955 |
return rst |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
956 |
|
27378
c709b515218e
help: pass sub-topic into help query functions
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27377
diff
changeset
|
957 |
def helpextcmd(name, subtopic=None): |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
958 |
cmd, ext, doc = extensions.disabledcmd( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
959 |
ui, name, ui.configbool('ui', 'strict') |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
960 |
) |
38019
6e526b0961a8
help: load module doc of disabled extension in extensions.disabledcmd()
Yuya Nishihara <yuya@tcha.org>
parents:
37137
diff
changeset
|
961 |
doc = doc.splitlines()[0] |
18746
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
962 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
963 |
rst = listexts( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
964 |
_("'%s' is provided by the following " "extension:") % cmd, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
965 |
{ext: doc}, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
966 |
indent=4, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
967 |
showdeprecated=True, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
968 |
) |
18746
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
969 |
rst.append('\n') |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
970 |
rst.append( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
971 |
_( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
972 |
"(use 'hg help extensions' for information on enabling " |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
973 |
"extensions)\n" |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
974 |
) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
975 |
) |
18746
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
976 |
return rst |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
977 |
|
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
978 |
rst = [] |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
979 |
kw = opts.get('keyword') |
27325
eadbbd14bdc1
help: fix help -c/help -e/help -k
timeless <timeless@mozdev.org>
parents:
27324
diff
changeset
|
980 |
if kw or name is None and any(opts[o] for o in opts): |
32599
1b90036f42f0
help: pass commands module by argument
Yuya Nishihara <yuya@tcha.org>
parents:
32582
diff
changeset
|
981 |
matches = topicmatch(ui, commands, name or '') |
26238
69da16b366ad
help: fix help argument parsing and documentation
timeless@mozdev.org
parents:
26196
diff
changeset
|
982 |
helpareas = [] |
69da16b366ad
help: fix help argument parsing and documentation
timeless@mozdev.org
parents:
26196
diff
changeset
|
983 |
if opts.get('extension'): |
69da16b366ad
help: fix help argument parsing and documentation
timeless@mozdev.org
parents:
26196
diff
changeset
|
984 |
helpareas += [('extensions', _('Extensions'))] |
69da16b366ad
help: fix help argument parsing and documentation
timeless@mozdev.org
parents:
26196
diff
changeset
|
985 |
if opts.get('command'): |
69da16b366ad
help: fix help argument parsing and documentation
timeless@mozdev.org
parents:
26196
diff
changeset
|
986 |
helpareas += [('commands', _('Commands'))] |
69da16b366ad
help: fix help argument parsing and documentation
timeless@mozdev.org
parents:
26196
diff
changeset
|
987 |
if not helpareas: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
988 |
helpareas = [ |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
989 |
('topics', _('Topics')), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
990 |
('commands', _('Commands')), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
991 |
('extensions', _('Extensions')), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
992 |
('extensioncommands', _('Extension Commands')), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
993 |
] |
26238
69da16b366ad
help: fix help argument parsing and documentation
timeless@mozdev.org
parents:
26196
diff
changeset
|
994 |
for t, title in helpareas: |
18746
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
995 |
if matches[t]: |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
996 |
rst.append('%s:\n\n' % title) |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
997 |
rst.extend(minirst.maketable(sorted(matches[t]), 1)) |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
998 |
rst.append('\n') |
21288
eb6eaef7ae44
help: provide a more helpful message when no keyword are matched
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20823
diff
changeset
|
999 |
if not rst: |
eb6eaef7ae44
help: provide a more helpful message when no keyword are matched
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20823
diff
changeset
|
1000 |
msg = _('no matches') |
29978
7109d5ddeb0c
help: use single quotes in use warning
timeless <timeless@mozdev.org>
parents:
29865
diff
changeset
|
1001 |
hint = _("try 'hg help' for a list of topics") |
26587
56b2bcea2529
error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26436
diff
changeset
|
1002 |
raise error.Abort(msg, hint=hint) |
18746
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
1003 |
elif name and name != 'shortlist': |
26238
69da16b366ad
help: fix help argument parsing and documentation
timeless@mozdev.org
parents:
26196
diff
changeset
|
1004 |
queries = [] |
18746
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
1005 |
if unknowncmd: |
26238
69da16b366ad
help: fix help argument parsing and documentation
timeless@mozdev.org
parents:
26196
diff
changeset
|
1006 |
queries += [helpextcmd] |
69da16b366ad
help: fix help argument parsing and documentation
timeless@mozdev.org
parents:
26196
diff
changeset
|
1007 |
if opts.get('extension'): |
69da16b366ad
help: fix help argument parsing and documentation
timeless@mozdev.org
parents:
26196
diff
changeset
|
1008 |
queries += [helpext] |
69da16b366ad
help: fix help argument parsing and documentation
timeless@mozdev.org
parents:
26196
diff
changeset
|
1009 |
if opts.get('command'): |
69da16b366ad
help: fix help argument parsing and documentation
timeless@mozdev.org
parents:
26196
diff
changeset
|
1010 |
queries += [helpcmd] |
69da16b366ad
help: fix help argument parsing and documentation
timeless@mozdev.org
parents:
26196
diff
changeset
|
1011 |
if not queries: |
18746
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
1012 |
queries = (helptopic, helpcmd, helpext, helpextcmd) |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
1013 |
for f in queries: |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
1014 |
try: |
27378
c709b515218e
help: pass sub-topic into help query functions
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27377
diff
changeset
|
1015 |
rst = f(name, subtopic) |
18746
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
1016 |
break |
21289
c3784e3c3e8d
help: suggest keyword search when no topic is found
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21288
diff
changeset
|
1017 |
except error.UnknownCommand: |
c3784e3c3e8d
help: suggest keyword search when no topic is found
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21288
diff
changeset
|
1018 |
pass |
c3784e3c3e8d
help: suggest keyword search when no topic is found
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21288
diff
changeset
|
1019 |
else: |
c3784e3c3e8d
help: suggest keyword search when no topic is found
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21288
diff
changeset
|
1020 |
if unknowncmd: |
c3784e3c3e8d
help: suggest keyword search when no topic is found
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21288
diff
changeset
|
1021 |
raise error.UnknownCommand(name) |
c3784e3c3e8d
help: suggest keyword search when no topic is found
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21288
diff
changeset
|
1022 |
else: |
42413
ad55a0a5894f
help: include subtopic in error message if passed
Nathan Goldbaum <nathan12343@gmail.com>
parents:
42412
diff
changeset
|
1023 |
if fullname: |
ad55a0a5894f
help: include subtopic in error message if passed
Nathan Goldbaum <nathan12343@gmail.com>
parents:
42412
diff
changeset
|
1024 |
formatname = fullname |
ad55a0a5894f
help: include subtopic in error message if passed
Nathan Goldbaum <nathan12343@gmail.com>
parents:
42412
diff
changeset
|
1025 |
else: |
ad55a0a5894f
help: include subtopic in error message if passed
Nathan Goldbaum <nathan12343@gmail.com>
parents:
42412
diff
changeset
|
1026 |
formatname = name |
ad55a0a5894f
help: include subtopic in error message if passed
Nathan Goldbaum <nathan12343@gmail.com>
parents:
42412
diff
changeset
|
1027 |
if subtopic: |
ad55a0a5894f
help: include subtopic in error message if passed
Nathan Goldbaum <nathan12343@gmail.com>
parents:
42412
diff
changeset
|
1028 |
hintname = subtopic |
ad55a0a5894f
help: include subtopic in error message if passed
Nathan Goldbaum <nathan12343@gmail.com>
parents:
42412
diff
changeset
|
1029 |
else: |
ad55a0a5894f
help: include subtopic in error message if passed
Nathan Goldbaum <nathan12343@gmail.com>
parents:
42412
diff
changeset
|
1030 |
hintname = name |
ad55a0a5894f
help: include subtopic in error message if passed
Nathan Goldbaum <nathan12343@gmail.com>
parents:
42412
diff
changeset
|
1031 |
msg = _('no such help topic: %s') % formatname |
ad55a0a5894f
help: include subtopic in error message if passed
Nathan Goldbaum <nathan12343@gmail.com>
parents:
42412
diff
changeset
|
1032 |
hint = _("try 'hg help --keyword %s'") % hintname |
26587
56b2bcea2529
error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26436
diff
changeset
|
1033 |
raise error.Abort(msg, hint=hint) |
18746
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
1034 |
else: |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
1035 |
# program name |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
1036 |
if not ui.quiet: |
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
1037 |
rst = [_("Mercurial Distributed SCM\n"), '\n'] |
32580
0cec8ad579d4
help: convert dict to strkwargs
Augie Fackler <raf@durin42.com>
parents:
32331
diff
changeset
|
1038 |
rst.extend(helplist(None, **pycompat.strkwargs(opts))) |
18746
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
1039 |
|
c0087d48ec3a
help: move the majority of the help command to the help module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
17837
diff
changeset
|
1040 |
return ''.join(rst) |
31079
2a0c8e3636b0
help: move rst formatting of help documents into help.py
Augie Fackler <augie@google.com>
parents:
30812
diff
changeset
|
1041 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
1042 |
|
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
1043 |
def formattedhelp( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
1044 |
ui, commands, fullname, keep=None, unknowncmd=False, full=True, **opts |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
1045 |
): |
31079
2a0c8e3636b0
help: move rst formatting of help documents into help.py
Augie Fackler <augie@google.com>
parents:
30812
diff
changeset
|
1046 |
"""get help for a given topic (as a dotted name) as rendered rst |
2a0c8e3636b0
help: move rst formatting of help documents into help.py
Augie Fackler <augie@google.com>
parents:
30812
diff
changeset
|
1047 |
|
2a0c8e3636b0
help: move rst formatting of help documents into help.py
Augie Fackler <augie@google.com>
parents:
30812
diff
changeset
|
1048 |
Either returns the rendered help text or raises an exception. |
2a0c8e3636b0
help: move rst formatting of help documents into help.py
Augie Fackler <augie@google.com>
parents:
30812
diff
changeset
|
1049 |
""" |
2a0c8e3636b0
help: move rst formatting of help documents into help.py
Augie Fackler <augie@google.com>
parents:
30812
diff
changeset
|
1050 |
if keep is None: |
2a0c8e3636b0
help: move rst formatting of help documents into help.py
Augie Fackler <augie@google.com>
parents:
30812
diff
changeset
|
1051 |
keep = [] |
31275
79715ba22f9c
help: avoid mutating passed-in `keep` list in `formattedhelp`
Augie Fackler <augie@google.com>
parents:
31144
diff
changeset
|
1052 |
else: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
1053 |
keep = list(keep) # make a copy so we can mutate this later |
39366
d30867a745a1
help: rewrite parsing of help topic to not drop section name with dots
Yuya Nishihara <yuya@tcha.org>
parents:
39336
diff
changeset
|
1054 |
|
d30867a745a1
help: rewrite parsing of help topic to not drop section name with dots
Yuya Nishihara <yuya@tcha.org>
parents:
39336
diff
changeset
|
1055 |
# <fullname> := <name>[.<subtopic][.<section>] |
d30867a745a1
help: rewrite parsing of help topic to not drop section name with dots
Yuya Nishihara <yuya@tcha.org>
parents:
39336
diff
changeset
|
1056 |
name = subtopic = section = None |
d30867a745a1
help: rewrite parsing of help topic to not drop section name with dots
Yuya Nishihara <yuya@tcha.org>
parents:
39336
diff
changeset
|
1057 |
if fullname is not None: |
d30867a745a1
help: rewrite parsing of help topic to not drop section name with dots
Yuya Nishihara <yuya@tcha.org>
parents:
39336
diff
changeset
|
1058 |
nameparts = fullname.split('.') |
d30867a745a1
help: rewrite parsing of help topic to not drop section name with dots
Yuya Nishihara <yuya@tcha.org>
parents:
39336
diff
changeset
|
1059 |
name = nameparts.pop(0) |
d30867a745a1
help: rewrite parsing of help topic to not drop section name with dots
Yuya Nishihara <yuya@tcha.org>
parents:
39336
diff
changeset
|
1060 |
if nameparts and name in subtopics: |
d30867a745a1
help: rewrite parsing of help topic to not drop section name with dots
Yuya Nishihara <yuya@tcha.org>
parents:
39336
diff
changeset
|
1061 |
subtopic = nameparts.pop(0) |
d30867a745a1
help: rewrite parsing of help topic to not drop section name with dots
Yuya Nishihara <yuya@tcha.org>
parents:
39336
diff
changeset
|
1062 |
if nameparts: |
d30867a745a1
help: rewrite parsing of help topic to not drop section name with dots
Yuya Nishihara <yuya@tcha.org>
parents:
39336
diff
changeset
|
1063 |
section = encoding.lower('.'.join(nameparts)) |
d30867a745a1
help: rewrite parsing of help topic to not drop section name with dots
Yuya Nishihara <yuya@tcha.org>
parents:
39336
diff
changeset
|
1064 |
|
33499
0407a51b9d8c
codemod: register core configitems using a script
Jun Wu <quark@fb.com>
parents:
32642
diff
changeset
|
1065 |
textwidth = ui.configint('ui', 'textwidth') |
31079
2a0c8e3636b0
help: move rst formatting of help documents into help.py
Augie Fackler <augie@google.com>
parents:
30812
diff
changeset
|
1066 |
termwidth = ui.termwidth() - 2 |
2a0c8e3636b0
help: move rst formatting of help documents into help.py
Augie Fackler <augie@google.com>
parents:
30812
diff
changeset
|
1067 |
if textwidth <= 0 or termwidth < textwidth: |
2a0c8e3636b0
help: move rst formatting of help documents into help.py
Augie Fackler <augie@google.com>
parents:
30812
diff
changeset
|
1068 |
textwidth = termwidth |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
1069 |
text = help_( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
1070 |
ui, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
1071 |
commands, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
1072 |
name, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
1073 |
fullname=fullname, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
1074 |
subtopic=subtopic, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
1075 |
unknowncmd=unknowncmd, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
1076 |
full=full, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
1077 |
**opts |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42466
diff
changeset
|
1078 |
) |
31079
2a0c8e3636b0
help: move rst formatting of help documents into help.py
Augie Fackler <augie@google.com>
parents:
30812
diff
changeset
|
1079 |
|
39335
9b800601701c
help: inline minirst.format()
Yuya Nishihara <yuya@tcha.org>
parents:
38041
diff
changeset
|
1080 |
blocks, pruned = minirst.parse(text, keep=keep) |
31079
2a0c8e3636b0
help: move rst formatting of help documents into help.py
Augie Fackler <augie@google.com>
parents:
30812
diff
changeset
|
1081 |
if 'verbose' in pruned: |
2a0c8e3636b0
help: move rst formatting of help documents into help.py
Augie Fackler <augie@google.com>
parents:
30812
diff
changeset
|
1082 |
keep.append('omitted') |
2a0c8e3636b0
help: move rst formatting of help documents into help.py
Augie Fackler <augie@google.com>
parents:
30812
diff
changeset
|
1083 |
else: |
2a0c8e3636b0
help: move rst formatting of help documents into help.py
Augie Fackler <augie@google.com>
parents:
30812
diff
changeset
|
1084 |
keep.append('notomitted') |
39335
9b800601701c
help: inline minirst.format()
Yuya Nishihara <yuya@tcha.org>
parents:
38041
diff
changeset
|
1085 |
blocks, pruned = minirst.parse(text, keep=keep) |
9b800601701c
help: inline minirst.format()
Yuya Nishihara <yuya@tcha.org>
parents:
38041
diff
changeset
|
1086 |
if section: |
9b800601701c
help: inline minirst.format()
Yuya Nishihara <yuya@tcha.org>
parents:
38041
diff
changeset
|
1087 |
blocks = minirst.filtersections(blocks, section) |
39336
0a766cb1092a
help: reorder section filtering flow to not format help text twice
Yuya Nishihara <yuya@tcha.org>
parents:
39335
diff
changeset
|
1088 |
|
0a766cb1092a
help: reorder section filtering flow to not format help text twice
Yuya Nishihara <yuya@tcha.org>
parents:
39335
diff
changeset
|
1089 |
# We could have been given a weird ".foo" section without a name |
0a766cb1092a
help: reorder section filtering flow to not format help text twice
Yuya Nishihara <yuya@tcha.org>
parents:
39335
diff
changeset
|
1090 |
# to look for, or we could have simply failed to found "foo.bar" |
0a766cb1092a
help: reorder section filtering flow to not format help text twice
Yuya Nishihara <yuya@tcha.org>
parents:
39335
diff
changeset
|
1091 |
# because bar isn't a section of foo |
0a766cb1092a
help: reorder section filtering flow to not format help text twice
Yuya Nishihara <yuya@tcha.org>
parents:
39335
diff
changeset
|
1092 |
if section and not (blocks and name): |
0a766cb1092a
help: reorder section filtering flow to not format help text twice
Yuya Nishihara <yuya@tcha.org>
parents:
39335
diff
changeset
|
1093 |
raise error.Abort(_("help section not found: %s") % fullname) |
0a766cb1092a
help: reorder section filtering flow to not format help text twice
Yuya Nishihara <yuya@tcha.org>
parents:
39335
diff
changeset
|
1094 |
|
39335
9b800601701c
help: inline minirst.format()
Yuya Nishihara <yuya@tcha.org>
parents:
38041
diff
changeset
|
1095 |
return minirst.formatplain(blocks, textwidth) |