##// END OF EJS Templates
sidedata: rename the configuration option to `exp-use-side-data`...
sidedata: rename the configuration option to `exp-use-side-data` We don't want setup configured to use the final version that would end using the experimental one while using and older version. Differential Revision: https://phab.mercurial-scm.org/D7040

File last commit:

r43387:8ff1ecfa default
r43437:bca9d1a6 default
Show More
help.py
1119 lines | 35.0 KiB | text/x-python | PythonLexer
Matt Mackall
Add basic support for help topics and a dates topic
r3795 # help.py - help data for mercurial
#
# Copyright 2006 Matt Mackall <mpm@selenic.com>
#
Martin Geisler
updated license to be explicit about GPL version 2
r8225 # This software may be used and distributed according to the terms of the
Matt Mackall
Update license to GPLv2+
r10263 # GNU General Public License version 2 or any later version.
Matt Mackall
Add basic support for help topics and a dates topic
r3795
Gregory Szorc
help: use absolute_import
r27479 from __future__ import absolute_import
import itertools
import os
Valentin Gatien-Baron
help: describe what ui.tweakdefaults changes, concretely...
r40472 import re
Gregory Szorc
help: use absolute_import
r27479 import textwrap
from .i18n import (
_,
gettext,
)
Gregory Szorc
py3: manually import getattr where it is needed...
r43359 from .pycompat import getattr
Gregory Szorc
help: use absolute_import
r27479 from . import (
cmdutil,
encoding,
error,
extensions,
Daniel Ploch
fancyopts: fix rendering of customopt defaults in help text...
r37109 fancyopts,
Gregory Szorc
help: use absolute_import
r27479 filemerge,
fileset,
minirst,
Pulkit Goyal
py3: make sure opts are passed and used correctly in help command...
r32143 pycompat,
rdamazio@google.com
help: adding support for command categories...
r40327 registrar,
Gregory Szorc
help: use absolute_import
r27479 revset,
templatefilters,
Yuya Nishihara
templater: split template functions to new module...
r36940 templatefuncs,
Gregory Szorc
help: use absolute_import
r27479 templatekw,
Valentin Gatien-Baron
help: describe what ui.tweakdefaults changes, concretely...
r40472 ui as uimod,
Gregory Szorc
help: use absolute_import
r27479 util,
)
Augie Fackler
formatting: blacken the codebase...
r43346 from .hgweb import webcommands
from .utils import compression
Cédric Duval
help: adding a new help topic about extensions...
r8863
Martin von Zweigbergk
cleanup: use set literals...
r32291 _exclkeywords = {
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 b"(ADVANCED)",
b"(DEPRECATED)",
b"(EXPERIMENTAL)",
Jun Wu
help: hide command line options marked as "advanced"...
r31080 # i18n: "(ADVANCED)" is a keyword, must be translated consistently
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 _(b"(ADVANCED)"),
Yuya Nishihara
help: include parens in DEPRECATED/EXPERIMENTAL keywords...
r26370 # i18n: "(DEPRECATED)" is a keyword, must be translated consistently
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 _(b"(DEPRECATED)"),
Yuya Nishihara
help: include parens in DEPRECATED/EXPERIMENTAL keywords...
r26370 # i18n: "(EXPERIMENTAL)" is a keyword, must be translated consistently
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 _(b"(EXPERIMENTAL)"),
Martin von Zweigbergk
cleanup: use set literals...
r32291 }
Yuya Nishihara
help: define list of keywords that should be excluded from non-verbose output...
r26369
rdamazio@google.com
help: adding support for command categories...
r40327 # The order in which command categories will be displayed.
# Extensions with custom categories should insert them into this list
# after/before the appropriate item, rather than replacing the list or
# assuming absolute positions.
CATEGORY_ORDER = [
rdamazio@google.com
help: assigning categories to existing commands...
r40329 registrar.command.CATEGORY_REPO_CREATION,
registrar.command.CATEGORY_REMOTE_REPO_MANAGEMENT,
registrar.command.CATEGORY_COMMITTING,
registrar.command.CATEGORY_CHANGE_MANAGEMENT,
registrar.command.CATEGORY_CHANGE_ORGANIZATION,
registrar.command.CATEGORY_FILE_CONTENTS,
Augie Fackler
formatting: blacken the codebase...
r43346 registrar.command.CATEGORY_CHANGE_NAVIGATION,
rdamazio@google.com
help: assigning categories to existing commands...
r40329 registrar.command.CATEGORY_WORKING_DIRECTORY,
registrar.command.CATEGORY_IMPORT_EXPORT,
registrar.command.CATEGORY_MAINTENANCE,
registrar.command.CATEGORY_HELP,
registrar.command.CATEGORY_MISC,
rdamazio@google.com
help: adding support for command categories...
r40327 registrar.command.CATEGORY_NONE,
]
# Human-readable category names. These are translated.
# Extensions with custom categories should add their names here.
CATEGORY_NAMES = {
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 registrar.command.CATEGORY_REPO_CREATION: b'Repository creation',
registrar.command.CATEGORY_REMOTE_REPO_MANAGEMENT: b'Remote repository management',
registrar.command.CATEGORY_COMMITTING: b'Change creation',
registrar.command.CATEGORY_CHANGE_NAVIGATION: b'Change navigation',
registrar.command.CATEGORY_CHANGE_MANAGEMENT: b'Change manipulation',
registrar.command.CATEGORY_CHANGE_ORGANIZATION: b'Change organization',
registrar.command.CATEGORY_WORKING_DIRECTORY: b'Working directory management',
registrar.command.CATEGORY_FILE_CONTENTS: b'File content management',
registrar.command.CATEGORY_IMPORT_EXPORT: b'Change import/export',
registrar.command.CATEGORY_MAINTENANCE: b'Repository maintenance',
registrar.command.CATEGORY_HELP: b'Help',
registrar.command.CATEGORY_MISC: b'Miscellaneous commands',
registrar.command.CATEGORY_NONE: b'Uncategorized commands',
rdamazio@google.com
help: adding support for command categories...
r40327 }
Rodrigo Damazio
help: splitting the topics by category...
r40328 # Topic categories.
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 TOPIC_CATEGORY_IDS = b'ids'
TOPIC_CATEGORY_OUTPUT = b'output'
TOPIC_CATEGORY_CONFIG = b'config'
TOPIC_CATEGORY_CONCEPTS = b'concepts'
TOPIC_CATEGORY_MISC = b'misc'
TOPIC_CATEGORY_NONE = b'none'
Rodrigo Damazio
help: splitting the topics by category...
r40328
# The order in which topic categories will be displayed.
# Extensions with custom categories should insert them into this list
# after/before the appropriate item, rather than replacing the list or
# assuming absolute positions.
TOPIC_CATEGORY_ORDER = [
Rodrigo Damazio
help: assigning topic categories...
r40330 TOPIC_CATEGORY_IDS,
TOPIC_CATEGORY_OUTPUT,
TOPIC_CATEGORY_CONFIG,
TOPIC_CATEGORY_CONCEPTS,
TOPIC_CATEGORY_MISC,
Rodrigo Damazio
help: splitting the topics by category...
r40328 TOPIC_CATEGORY_NONE,
]
# Human-readable topic category names. These are translated.
TOPIC_CATEGORY_NAMES = {
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 TOPIC_CATEGORY_IDS: b'Mercurial identifiers',
TOPIC_CATEGORY_OUTPUT: b'Mercurial output',
TOPIC_CATEGORY_CONFIG: b'Mercurial configuration',
TOPIC_CATEGORY_CONCEPTS: b'Concepts',
TOPIC_CATEGORY_MISC: b'Miscellaneous',
TOPIC_CATEGORY_NONE: b'Uncategorized topics',
Rodrigo Damazio
help: splitting the topics by category...
r40328 }
Augie Fackler
formatting: blacken the codebase...
r43346
Augie Fackler
help: exclude deprecated extensions in the disabled part of 'help extensions'
r20582 def listexts(header, exts, indent=1, showdeprecated=False):
Cédric Duval
help: more improvements for the extensions topic...
r8879 '''return a text listing of the given extensions'''
Olav Reinert
help: format extension lists using RST...
r16852 rst = []
if exts:
Gregory Szorc
py3: finish porting iteritems() to pycompat and remove source transformer...
r43376 for name, desc in sorted(pycompat.iteritems(exts)):
Yuya Nishihara
help: unify handling of DEPRECATED/EXPERIMENTAL keywords...
r26371 if not showdeprecated and any(w in desc for w in _exclkeywords):
Augie Fackler
help: exclude deprecated extensions in the disabled part of 'help extensions'
r20582 continue
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 rst.append(b'%s:%s: %s\n' % (b' ' * indent, name, desc))
timeless
help: make listexts less confusing for deprecated exts...
r27151 if rst:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 rst.insert(0, b'\n%s\n\n' % header)
Olav Reinert
help: format extension lists using RST...
r16852 return rst
Cédric Duval
help: refactor extensions listing, and show enabled ones in the dedicated topic
r8864
Augie Fackler
formatting: blacken the codebase...
r43346
Yuya Nishihara
help: pass around ui to doc loader (API)...
r26413 def extshelp(ui):
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 rst = loaddoc(b'extensions')(ui).splitlines(True)
Augie Fackler
formatting: blacken the codebase...
r43346 rst.extend(
listexts(
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 _(b'enabled extensions:'), extensions.enabled(), showdeprecated=True
Augie Fackler
formatting: blacken the codebase...
r43346 )
)
rst.extend(
listexts(
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 _(b'disabled extensions:'),
Augie Fackler
formatting: blacken the codebase...
r43346 extensions.disabled(),
showdeprecated=ui.verbose,
)
)
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 doc = b''.join(rst)
Cédric Duval
help: adding a new help topic about extensions...
r8863 return doc
Martin Geisler
i18n: mark help strings for translation...
r7013
Augie Fackler
formatting: blacken the codebase...
r43346
Matt Mackall
help: roll option list header into option formatter
r22116 def optrst(header, options, verbose):
Olav Reinert
help: move some helper functions to help.py
r16781 data = []
multioccur = False
for option in options:
if len(option) == 5:
shortopt, longopt, default, desc, optlabel = option
else:
shortopt, longopt, default, desc = option
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 optlabel = _(b"VALUE") # default label
Olav Reinert
help: move some helper functions to help.py
r16781
Yuya Nishihara
help: define list of keywords that should be excluded from non-verbose output...
r26369 if not verbose and any(w in desc for w in _exclkeywords):
Olav Reinert
help: move some helper functions to help.py
r16781 continue
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 so = b''
Olav Reinert
help: move some helper functions to help.py
r16781 if shortopt:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 so = b'-' + shortopt
lo = b'--' + longopt
Martin von Zweigbergk
help: show "[no-]" only for default-on Flags...
r41045 if default is True:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 lo = b'--[no-]' + longopt
Daniel Ploch
fancyopts: fix rendering of customopt defaults in help text...
r37109
if isinstance(default, fancyopts.customopt):
Daniel Ploch
fancyopts: prevent mutation of the default value in customopts...
r37110 default = default.getdefaultvalue()
Martin von Zweigbergk
help: hide default value for default-off flags...
r41046 if default and not callable(default):
Augie Fackler
help: convert flag default to bytes portably...
r32619 # default is of unknown type, and in Python 2 we abused
# the %s-shows-repr property to handle integers etc. To
# match that behavior on Python 3, we do str(default) and
# then convert it to bytes.
Martin von Zweigbergk
help: use "default: on" instead of "default: True"...
r40989 defaultstr = pycompat.bytestr(default)
Martin von Zweigbergk
help: hide default value for default-off flags...
r41046 if default is True:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 defaultstr = _(b"on")
desc += _(b" (default: %s)") % defaultstr
Olav Reinert
help: move some helper functions to help.py
r16781
if isinstance(default, list):
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 lo += b" %s [+]" % optlabel
Olav Reinert
help: move some helper functions to help.py
r16781 multioccur = True
elif (default is not None) and not isinstance(default, bool):
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 lo += b" %s" % optlabel
Olav Reinert
help: move some helper functions to help.py
r16781
data.append((so, lo, desc))
Matt Mackall
help: fold repeatable option message into option table header...
r22117 if multioccur:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 header += _(b" ([+] can be repeated)")
Olav Reinert
help: move some helper functions to help.py
r16781
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 rst = [b'\n%s:\n\n' % header]
Matt Mackall
help: roll option list header into option formatter
r22116 rst.extend(minirst.maketable(data, 1))
Olav Reinert
help: move some helper functions to help.py
r16781
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 return b''.join(rst)
Olav Reinert
help: move some helper functions to help.py
r16781
Augie Fackler
formatting: blacken the codebase...
r43346
FUJIWARA Katsunori
help: indicate help omitting if help document is not fully displayed...
r17837 def indicateomitted(rst, omitted, notomitted=None):
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 rst.append(b'\n\n.. container:: omitted\n\n %s\n\n' % omitted)
FUJIWARA Katsunori
help: indicate help omitting if help document is not fully displayed...
r17837 if notomitted:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 rst.append(b'\n\n.. container:: notomitted\n\n %s\n\n' % notomitted)
FUJIWARA Katsunori
help: indicate help omitting if help document is not fully displayed...
r17837
Augie Fackler
formatting: blacken the codebase...
r43346
rdamazio@google.com
help: displaying documented aliases by default...
r40450 def filtercmd(ui, cmd, func, kw, doc):
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 if not ui.debugflag and cmd.startswith(b"debug") and kw != b"debug":
rdamazio@google.com
help: displaying documented aliases by default...
r40450 # Debug command, and user is not looking for those.
timeless
help: refactor filtercmd
r27323 return True
rdamazio@google.com
help: displaying documented aliases by default...
r40450 if not ui.verbose:
if not kw and not doc:
# Command had no documentation, no point in showing it by default.
return True
if getattr(func, 'alias', False) and not getattr(func, 'owndoc', False):
# Alias didn't have its own documentation.
return True
if doc and any(w in doc for w in _exclkeywords):
# Documentation has excluded keywords.
return True
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 if kw == b"shortlist" and not getattr(func, 'helpbasic', False):
rdamazio@google.com
help: displaying documented aliases by default...
r40450 # We're presenting the short list but the command is not basic.
timeless
help: refactor filtercmd
r27323 return True
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 if ui.configbool(b'help', b'hidden-command.%s' % cmd):
rdamazio@google.com
help: displaying documented aliases by default...
r40450 # Configuration explicitly hides the command.
timeless
help: refactor filtercmd
r27323 return True
return False
Augie Fackler
formatting: blacken the codebase...
r43346
rdamazio@google.com
help: allow hiding of help topics...
r40449 def filtertopic(ui, topic):
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 return ui.configbool(b'help', b'hidden-topic.%s' % topic, False)
rdamazio@google.com
help: allow hiding of help topics...
r40449
Augie Fackler
formatting: blacken the codebase...
r43346
Yuya Nishihara
help: pass commands module by argument...
r32567 def topicmatch(ui, commands, kw):
Augie Fackler
help: introduce topicmatch for finding topics matching a keyword
r16710 """Return help topics matching kw.
Returns {'section': [(name, summary), ...], ...} where section is
one of topics, commands, extensions, or extensioncommands.
"""
kw = encoding.lower(kw)
Augie Fackler
formatting: blacken the codebase...
r43346
Augie Fackler
help: introduce topicmatch for finding topics matching a keyword
r16710 def lowercontains(container):
Nikolaj Sjujskij
help: fix search with `-k` option in non-ASCII locales...
r16845 return kw in encoding.lower(container) # translated in helptable
Augie Fackler
formatting: blacken the codebase...
r43346
results = {
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 b'topics': [],
b'commands': [],
b'extensions': [],
b'extensioncommands': [],
Augie Fackler
formatting: blacken the codebase...
r43346 }
Rodrigo Damazio
help: splitting the topics by category...
r40328 for topic in helptable:
names, header, doc = topic[0:3]
Gregory Szorc
help: only call doc() when it is callable...
r22322 # Old extensions may use a str as doc.
Augie Fackler
formatting: blacken the codebase...
r43346 if (
sum(map(lowercontains, names))
Augie Fackler
help: introduce topicmatch for finding topics matching a keyword
r16710 or lowercontains(header)
Augie Fackler
formatting: blacken the codebase...
r43346 or (callable(doc) and lowercontains(doc(ui)))
):
rdamazio@google.com
help: allow hiding of help topics...
r40449 name = names[0]
if not filtertopic(ui, name):
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 results[b'topics'].append((names[0], header))
Gregory Szorc
py3: finish porting iteritems() to pycompat and remove source transformer...
r43376 for cmd, entry in pycompat.iteritems(commands.table):
Augie Fackler
help: introduce topicmatch for finding topics matching a keyword
r16710 if len(entry) == 3:
summary = entry[2]
else:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 summary = b''
Nikolaj Sjujskij
help: fix search with `-k` option in non-ASCII locales...
r16845 # translate docs *before* searching there
rdamazio@google.com
help: displaying documented aliases by default...
r40450 func = entry[0]
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 docs = _(pycompat.getdoc(func)) or b''
Augie Fackler
help: introduce topicmatch for finding topics matching a keyword
r16710 if kw in cmd or lowercontains(summary) or lowercontains(docs):
Nikolaj Sjujskij
help: fix search with `-k` option in non-ASCII locales...
r16845 doclines = docs.splitlines()
Augie Fackler
help: introduce topicmatch for finding topics matching a keyword
r16710 if doclines:
summary = doclines[0]
Yuya Nishihara
help: use cmdutil.parsealiases() to resolve command name...
r36264 cmdname = cmdutil.parsealiases(cmd)[0]
rdamazio@google.com
help: displaying documented aliases by default...
r40450 if filtercmd(ui, cmdname, func, kw, docs):
timeless
help: call filtercmd from topicmatch...
r27324 continue
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 results[b'commands'].append((cmdname, summary))
Augie Fackler
help: introduce topicmatch for finding topics matching a keyword
r16710 for name, docs in itertools.chain(
Gregory Szorc
py3: finish porting iteritems() to pycompat and remove source transformer...
r43376 pycompat.iteritems(extensions.enabled(False)),
pycompat.iteritems(extensions.disabled()),
Augie Fackler
formatting: blacken the codebase...
r43346 ):
Simon Farnsworth
help: don't crash in keyword search if an extension fails to provide docs...
r28058 if not docs:
continue
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 name = name.rpartition(b'.')[-1]
Augie Fackler
help: introduce topicmatch for finding topics matching a keyword
r16710 if lowercontains(name) or lowercontains(docs):
Nikolaj Sjujskij
help: fix search with `-k` option in non-ASCII locales...
r16845 # extension docs are already translated
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 results[b'extensions'].append((name, docs.splitlines()[0]))
Yuya Nishihara
help: do not abort topicmatch() because of unimportable extensions...
r34913 try:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 mod = extensions.load(ui, name, b'')
Yuya Nishihara
help: do not abort topicmatch() because of unimportable extensions...
r34913 except ImportError:
# debug message would be printed in extensions.load()
continue
Gregory Szorc
py3: finish porting iteritems() to pycompat and remove source transformer...
r43376 for cmd, entry in pycompat.iteritems(getattr(mod, 'cmdtable', {})):
Augie Fackler
help: add --keyword (-k) for searching help
r16711 if kw in cmd or (len(entry) > 2 and lowercontains(entry[2])):
Yuya Nishihara
help: use cmdutil.parsealiases() to resolve command name...
r36264 cmdname = cmdutil.parsealiases(cmd)[0]
rdamazio@google.com
help: displaying documented aliases by default...
r40450 func = entry[0]
cmddoc = pycompat.getdoc(func)
Yuya Nishihara
py3: convert __doc__ back to bytes in help.py...
r32615 if cmddoc:
cmddoc = gettext(cmddoc).splitlines()[0]
Thomas Arendsen Hein
help: fix 'hg help -k' matching an extension without docs...
r16884 else:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 cmddoc = _(b'(no help text available)')
rdamazio@google.com
help: displaying documented aliases by default...
r40450 if filtercmd(ui, cmdname, func, kw, cmddoc):
timeless
help: filter extension commands
r27387 continue
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 results[b'extensioncommands'].append((cmdname, cmddoc))
Augie Fackler
help: introduce topicmatch for finding topics matching a keyword
r16710 return results
Augie Fackler
formatting: blacken the codebase...
r43346
Gregory Szorc
help: teach loaddoc to load from a different directory...
r27375 def loaddoc(topic, subdir=None):
Martin Geisler
help: move help topics from mercurial/help.py to help/*.txt...
r9539 """Return a delayed loader for help/topic.txt."""
Matt Mackall
move environment topic
r3798
Yuya Nishihara
help: pass around ui to doc loader (API)...
r26413 def loader(ui):
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 docdir = os.path.join(util.datapath, b'help')
Gregory Szorc
help: teach loaddoc to load from a different directory...
r27375 if subdir:
docdir = os.path.join(docdir, subdir)
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 path = os.path.join(docdir, topic + b".txt")
Dan Villiom Podlaski Christiansen
prevent transient leaks of file handle by using new helper functions...
r14168 doc = gettext(util.readfile(path))
Patrick Mezard
help: add topic rewriting hooks...
r12820 for rewriter in helphooks.get(topic, []):
Yuya Nishihara
help: pass around ui to rewriter hooks (API)...
r26414 doc = rewriter(ui, topic, doc)
Patrick Mezard
help: add topic rewriting hooks...
r12820 return doc
Martin Geisler
help: move help topics from mercurial/help.py to help/*.txt...
r9539 return loader
Alexander Solovyov
help: add a topic about some of the templating features
r7677
Augie Fackler
formatting: blacken the codebase...
r43346
internalstable = sorted(
[
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 ([b'bundle2'], _(b'Bundle2'), loaddoc(b'bundle2', subdir=b'internals')),
([b'bundles'], _(b'Bundles'), loaddoc(b'bundles', subdir=b'internals')),
([b'cbor'], _(b'CBOR'), loaddoc(b'cbor', subdir=b'internals')),
([b'censor'], _(b'Censor'), loaddoc(b'censor', subdir=b'internals')),
Augie Fackler
formatting: blacken the codebase...
r43346 (
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 [b'changegroups'],
_(b'Changegroups'),
loaddoc(b'changegroups', subdir=b'internals'),
Augie Fackler
formatting: blacken the codebase...
r43346 ),
(
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 [b'config'],
_(b'Config Registrar'),
loaddoc(b'config', subdir=b'internals'),
Augie Fackler
formatting: blacken the codebase...
r43346 ),
(
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 [b'extensions', b'extension'],
_(b'Extension API'),
loaddoc(b'extensions', subdir=b'internals'),
Augie Fackler
formatting: blacken the codebase...
r43346 ),
(
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 [b'mergestate'],
_(b'Mergestate'),
loaddoc(b'mergestate', subdir=b'internals'),
Augie Fackler
formatting: blacken the codebase...
r43346 ),
(
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 [b'requirements'],
_(b'Repository Requirements'),
loaddoc(b'requirements', subdir=b'internals'),
Augie Fackler
formatting: blacken the codebase...
r43346 ),
(
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 [b'revlogs'],
_(b'Revision Logs'),
loaddoc(b'revlogs', subdir=b'internals'),
Augie Fackler
formatting: blacken the codebase...
r43346 ),
(
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 [b'wireprotocol'],
_(b'Wire Protocol'),
loaddoc(b'wireprotocol', subdir=b'internals'),
Augie Fackler
formatting: blacken the codebase...
r43346 ),
(
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 [b'wireprotocolrpc'],
_(b'Wire Protocol RPC'),
loaddoc(b'wireprotocolrpc', subdir=b'internals'),
Augie Fackler
formatting: blacken the codebase...
r43346 ),
(
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 [b'wireprotocolv2'],
_(b'Wire Protocol Version 2'),
loaddoc(b'wireprotocolv2', subdir=b'internals'),
Augie Fackler
formatting: blacken the codebase...
r43346 ),
]
)
Gregory Szorc
help: add "internals" topic...
r27376
def internalshelp(ui):
"""Generate the index for the "internals" topic."""
Augie Fackler
formatting: blacken the codebase...
r43346 lines = [
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 b'To access a subtopic, use "hg help internals.{subtopic-name}"\n',
b'\n',
Augie Fackler
formatting: blacken the codebase...
r43346 ]
Gregory Szorc
help: add "internals" topic...
r27376 for names, header, doc in internalstable:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 lines.append(b' :%s: %s\n' % (names[0], header))
Gregory Szorc
help: add "internals" topic...
r27376
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 return b''.join(lines)
Gregory Szorc
help: add "internals" topic...
r27376
Augie Fackler
formatting: blacken the codebase...
r43346
helptable = sorted(
[
(
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 [b'bundlespec'],
_(b"Bundle File Formats"),
loaddoc(b'bundlespec'),
Augie Fackler
formatting: blacken the codebase...
r43346 TOPIC_CATEGORY_CONCEPTS,
),
(
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 [b'color'],
_(b"Colorizing Outputs"),
loaddoc(b'color'),
Augie Fackler
formatting: blacken the codebase...
r43346 TOPIC_CATEGORY_OUTPUT,
),
(
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 [b"config", b"hgrc"],
_(b"Configuration Files"),
loaddoc(b'config'),
Augie Fackler
formatting: blacken the codebase...
r43346 TOPIC_CATEGORY_CONFIG,
),
(
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 [b'deprecated'],
_(b"Deprecated Features"),
loaddoc(b'deprecated'),
Augie Fackler
formatting: blacken the codebase...
r43346 TOPIC_CATEGORY_MISC,
),
(
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 [b"dates"],
_(b"Date Formats"),
loaddoc(b'dates'),
TOPIC_CATEGORY_OUTPUT,
),
(
[b"flags"],
_(b"Command-line flags"),
loaddoc(b'flags'),
Augie Fackler
formatting: blacken the codebase...
r43346 TOPIC_CATEGORY_CONFIG,
),
(
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 [b"patterns"],
_(b"File Name Patterns"),
loaddoc(b'patterns'),
Augie Fackler
formatting: blacken the codebase...
r43346 TOPIC_CATEGORY_IDS,
),
(
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 [b'environment', b'env'],
_(b'Environment Variables'),
loaddoc(b'environment'),
Augie Fackler
formatting: blacken the codebase...
r43346 TOPIC_CATEGORY_CONFIG,
),
(
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 [
b'revisions',
b'revs',
b'revsets',
b'revset',
b'multirevs',
b'mrevs',
],
_(b'Specifying Revisions'),
loaddoc(b'revisions'),
Augie Fackler
formatting: blacken the codebase...
r43346 TOPIC_CATEGORY_IDS,
),
(
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 [b'filesets', b'fileset'],
_(b"Specifying File Sets"),
loaddoc(b'filesets'),
Augie Fackler
formatting: blacken the codebase...
r43346 TOPIC_CATEGORY_IDS,
),
(
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 [b'diffs'],
_(b'Diff Formats'),
loaddoc(b'diffs'),
TOPIC_CATEGORY_OUTPUT,
),
(
[b'merge-tools', b'mergetools', b'mergetool'],
_(b'Merge Tools'),
loaddoc(b'merge-tools'),
Augie Fackler
formatting: blacken the codebase...
r43346 TOPIC_CATEGORY_CONFIG,
),
(
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 [b'templating', b'templates', b'template', b'style'],
_(b'Template Usage'),
loaddoc(b'templates'),
Augie Fackler
formatting: blacken the codebase...
r43346 TOPIC_CATEGORY_OUTPUT,
),
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 ([b'urls'], _(b'URL Paths'), loaddoc(b'urls'), TOPIC_CATEGORY_IDS),
Augie Fackler
formatting: blacken the codebase...
r43346 (
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 [b"extensions"],
_(b"Using Additional Features"),
Augie Fackler
formatting: blacken the codebase...
r43346 extshelp,
TOPIC_CATEGORY_CONFIG,
),
(
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 [b"subrepos", b"subrepo"],
_(b"Subrepositories"),
loaddoc(b'subrepos'),
Augie Fackler
formatting: blacken the codebase...
r43346 TOPIC_CATEGORY_CONCEPTS,
),
(
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 [b"hgweb"],
_(b"Configuring hgweb"),
loaddoc(b'hgweb'),
Augie Fackler
formatting: blacken the codebase...
r43346 TOPIC_CATEGORY_CONFIG,
),
(
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 [b"glossary"],
_(b"Glossary"),
loaddoc(b'glossary'),
Augie Fackler
formatting: blacken the codebase...
r43346 TOPIC_CATEGORY_CONCEPTS,
),
(
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 [b"hgignore", b"ignore"],
_(b"Syntax for Mercurial Ignore Files"),
loaddoc(b'hgignore'),
Augie Fackler
formatting: blacken the codebase...
r43346 TOPIC_CATEGORY_IDS,
),
(
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 [b"phases"],
_(b"Working with Phases"),
loaddoc(b'phases'),
Augie Fackler
formatting: blacken the codebase...
r43346 TOPIC_CATEGORY_CONCEPTS,
),
(
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 [b'scripting'],
_(b'Using Mercurial from scripts and automation'),
loaddoc(b'scripting'),
Augie Fackler
formatting: blacken the codebase...
r43346 TOPIC_CATEGORY_MISC,
),
(
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 [b'internals'],
_(b"Technical implementation topics"),
Augie Fackler
formatting: blacken the codebase...
r43346 internalshelp,
TOPIC_CATEGORY_MISC,
),
(
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 [b'pager'],
_(b"Pager Support"),
loaddoc(b'pager'),
Augie Fackler
formatting: blacken the codebase...
r43346 TOPIC_CATEGORY_CONFIG,
),
]
)
Patrick Mezard
help: add topic rewriting hooks...
r12820
Gregory Szorc
help: support loading sub-topics...
r27379 # Maps topics with sub-topics to a list of their sub-topics.
subtopics = {
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 b'internals': internalstable,
Gregory Szorc
help: support loading sub-topics...
r27379 }
Patrick Mezard
help: add topic rewriting hooks...
r12820 # Map topics to lists of callable taking the current topic help and
# returning the updated version
Matt Mackall
help: consolidate topic hooks in help.py...
r14318 helphooks = {}
Patrick Mezard
help: add topic rewriting hooks...
r12820
Augie Fackler
formatting: blacken the codebase...
r43346
Patrick Mezard
help: add topic rewriting hooks...
r12820 def addtopichook(topic, rewriter):
helphooks.setdefault(topic, []).append(rewriter)
Patrick Mezard
help: extract items doc generation function
r13593
Augie Fackler
formatting: blacken the codebase...
r43346
Yuya Nishihara
help: pass around ui to rewriter hooks (API)...
r26414 def makeitemsdoc(ui, topic, doc, marker, items, dedent=False):
Patrick Mezard
help: extract items doc generation function
r13593 """Extract docstring from the items key to function mapping, build a
timeless@mozdev.org
help: fix makeitemsdoc English description
r26196 single documentation block and use it to overwrite the marker in doc.
Patrick Mezard
help: extract items doc generation function
r13593 """
entries = []
for name in sorted(items):
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 text = (pycompat.getdoc(items[name]) or b'').rstrip()
Augie Fackler
formatting: blacken the codebase...
r43346 if not text or not ui.verbose and any(w in text for w in _exclkeywords):
Patrick Mezard
help: extract items doc generation function
r13593 continue
text = gettext(text)
Gregory Szorc
help: teach topic symbols how to dedent...
r24098 if dedent:
Augie Fackler
help: work around textwrap.dedent() only working on strings
r32549 # Abuse latin1 to use textwrap.dedent() on bytes.
text = textwrap.dedent(text.decode('latin1')).encode('latin1')
Patrick Mezard
help: extract items doc generation function
r13593 lines = text.splitlines()
"Yann E. MORIN"
help: strip doctest from dochelp...
r16250 doclines = [(lines[0])]
for l in lines[1:]:
# Stop once we find some Python doctest
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 if l.strip().startswith(b'>>>'):
"Yann E. MORIN"
help: strip doctest from dochelp...
r16250 break
Gregory Szorc
help: teach topic symbols how to dedent...
r24098 if dedent:
doclines.append(l.rstrip())
else:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 doclines.append(b' ' + l.strip())
entries.append(b'\n'.join(doclines))
entries = b'\n\n'.join(entries)
Patrick Mezard
help: extract items doc generation function
r13593 return doc.replace(marker, entries)
Matt Mackall
help: consolidate topic hooks in help.py...
r14318
Augie Fackler
formatting: blacken the codebase...
r43346
Gregory Szorc
help: teach topic symbols how to dedent...
r24098 def addtopicsymbols(topic, marker, symbols, dedent=False):
Yuya Nishihara
help: pass around ui to rewriter hooks (API)...
r26414 def add(ui, topic, doc):
return makeitemsdoc(ui, topic, doc, marker, symbols, dedent=dedent)
Augie Fackler
formatting: blacken the codebase...
r43346
Matt Mackall
help: consolidate topic hooks in help.py...
r14318 addtopichook(topic, add)
Augie Fackler
formatting: blacken the codebase...
r43346
addtopicsymbols(
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 b'bundlespec',
b'.. bundlecompressionmarker',
Augie Fackler
formatting: blacken the codebase...
r43346 compression.bundlecompressiontopics(),
)
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 addtopicsymbols(b'filesets', b'.. predicatesmarker', fileset.symbols)
Augie Fackler
formatting: blacken the codebase...
r43346 addtopicsymbols(
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 b'merge-tools', b'.. internaltoolsmarker', filemerge.internalsdoc
)
addtopicsymbols(b'revisions', b'.. predicatesmarker', revset.symbols)
addtopicsymbols(b'templates', b'.. keywordsmarker', templatekw.keywords)
addtopicsymbols(b'templates', b'.. filtersmarker', templatefilters.filters)
addtopicsymbols(b'templates', b'.. functionsmarker', templatefuncs.funcs)
addtopicsymbols(
b'hgweb', b'.. webcommandsmarker', webcommands.commands, dedent=True
Augie Fackler
formatting: blacken the codebase...
r43346 )
Dan Villiom Podlaski Christiansen
help: move the majority of the help command to the help module...
r18746
Valentin Gatien-Baron
help: describe what ui.tweakdefaults changes, concretely...
r40472 def inserttweakrc(ui, topic, doc):
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 marker = b'.. tweakdefaultsmarker'
Valentin Gatien-Baron
help: describe what ui.tweakdefaults changes, concretely...
r40472 repl = uimod.tweakrc
Augie Fackler
formatting: blacken the codebase...
r43346
Valentin Gatien-Baron
help: describe what ui.tweakdefaults changes, concretely...
r40472 def sub(m):
lines = [m.group(1) + s for s in repl.splitlines()]
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 return b'\n'.join(lines)
Augie Fackler
formatting: blacken the codebase...
r43346
Valentin Gatien-Baron
help: describe what ui.tweakdefaults changes, concretely...
r40472 return re.sub(br'( *)%s' % re.escape(marker), sub, doc)
Augie Fackler
formatting: blacken the codebase...
r43346
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 addtopichook(b'config', inserttweakrc)
Valentin Gatien-Baron
help: describe what ui.tweakdefaults changes, concretely...
r40472
Augie Fackler
formatting: blacken the codebase...
r43346
def help_(
ui,
commands,
name,
unknowncmd=False,
full=True,
subtopic=None,
fullname=None,
**opts
):
Dan Villiom Podlaski Christiansen
help: move the majority of the help command to the help module...
r18746 '''
Generate the help for 'name' as unformatted restructured text. If
'name' is None, describe the commands available.
'''
Pulkit Goyal
py3: make sure opts are passed and used correctly in help command...
r32143 opts = pycompat.byteskwargs(opts)
Dan Villiom Podlaski Christiansen
help: move the majority of the help command to the help module...
r18746
Gregory Szorc
help: pass sub-topic into help query functions...
r27378 def helpcmd(name, subtopic=None):
Dan Villiom Podlaski Christiansen
help: move the majority of the help command to the help module...
r18746 try:
Augie Fackler
formatting: blacken the codebase...
r43346 aliases, entry = cmdutil.findcmd(
name, commands.table, strict=unknowncmd
)
Gregory Szorc
global: mass rewrite to use modern exception syntax...
r25660 except error.AmbiguousCommand as inst:
Martijn Pieters
py3: use py3 as the test tag, dropping the k...
r40299 # py3 fix: except vars can't be used outside the scope of the
Dan Villiom Podlaski Christiansen
help: move the majority of the help command to the help module...
r18746 # except block, nor can be used inside a lambda. python issue4617
prefix = inst.args[0]
Yuya Nishihara
help: use cmdutil.parsealiases() to resolve command name...
r36264 select = lambda c: cmdutil.parsealiases(c)[0].startswith(prefix)
Dan Villiom Podlaski Christiansen
help: move the majority of the help command to the help module...
r18746 rst = helplist(select)
return rst
rst = []
# check if it's an invalid alias and display its error if it is
Yuya Nishihara
alias: keep error message in "badalias" so that help can see it...
r22160 if getattr(entry[0], 'badalias', None):
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 rst.append(entry[0].badalias + b'\n')
Yuya Nishihara
help: provide help of bad alias without executing aliascmd()...
r22162 if entry[0].unknowncmd:
try:
rst.extend(helpextcmd(entry[0].cmdname))
except error.UnknownCommand:
pass
Dan Villiom Podlaski Christiansen
help: move the majority of the help command to the help module...
r18746 return rst
# synopsis
if len(entry) > 2:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 if entry[2].startswith(b'hg'):
rst.append(b"%s\n" % entry[2])
Dan Villiom Podlaski Christiansen
help: move the majority of the help command to the help module...
r18746 else:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 rst.append(b'hg %s %s\n' % (aliases[0], entry[2]))
Dan Villiom Podlaski Christiansen
help: move the majority of the help command to the help module...
r18746 else:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 rst.append(b'hg %s\n' % aliases[0])
Dan Villiom Podlaski Christiansen
help: move the majority of the help command to the help module...
r18746 # aliases
if full and not ui.quiet and len(aliases) > 1:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 rst.append(_(b"\naliases: %s\n") % b', '.join(aliases[1:]))
rst.append(b'\n')
Dan Villiom Podlaski Christiansen
help: move the majority of the help command to the help module...
r18746
# description
Yuya Nishihara
py3: convert __doc__ back to bytes in help.py...
r32615 doc = gettext(pycompat.getdoc(entry[0]))
Dan Villiom Podlaski Christiansen
help: move the majority of the help command to the help module...
r18746 if not doc:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 doc = _(b"(no help text available)")
if util.safehasattr(entry[0], b'definition'): # aliased command
timeless
help: report source of aliases
r28828 source = entry[0].source
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 if entry[0].definition.startswith(b'!'): # shell alias
doc = _(b'shell alias for: %s\n\n%s\n\ndefined by: %s\n') % (
Augie Fackler
formatting: blacken the codebase...
r43346 entry[0].definition[1:],
doc,
source,
)
Dan Villiom Podlaski Christiansen
help: move the majority of the help command to the help module...
r18746 else:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 doc = _(b'alias for: hg %s\n\n%s\n\ndefined by: %s\n') % (
Augie Fackler
formatting: blacken the codebase...
r43346 entry[0].definition,
doc,
source,
)
Dan Villiom Podlaski Christiansen
help: move the majority of the help command to the help module...
r18746 doc = doc.splitlines(True)
if ui.quiet or not full:
rst.append(doc[0])
else:
rst.extend(doc)
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 rst.append(b'\n')
Dan Villiom Podlaski Christiansen
help: move the majority of the help command to the help module...
r18746
# check if this command shadows a non-trivial (multi-line)
# extension help text
try:
mod = extensions.find(name)
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 doc = gettext(pycompat.getdoc(mod)) or b''
if b'\n' in doc.strip():
Augie Fackler
formatting: blacken the codebase...
r43346 msg = _(
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 b"(use 'hg help -e %s' to show help for "
b"the %s extension)"
Augie Fackler
formatting: blacken the codebase...
r43346 ) % (name, name)
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 rst.append(b'\n%s\n' % msg)
Dan Villiom Podlaski Christiansen
help: move the majority of the help command to the help module...
r18746 except KeyError:
pass
# options
if not ui.quiet and entry[1]:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 rst.append(optrst(_(b"options"), entry[1], ui.verbose))
Dan Villiom Podlaski Christiansen
help: move the majority of the help command to the help module...
r18746
if ui.verbose:
Augie Fackler
formatting: blacken the codebase...
r43346 rst.append(
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 optrst(_(b"global options"), commands.globalopts, ui.verbose)
Augie Fackler
formatting: blacken the codebase...
r43346 )
Dan Villiom Podlaski Christiansen
help: move the majority of the help command to the help module...
r18746
if not ui.verbose:
if not full:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 rst.append(_(b"\n(use 'hg %s -h' to show more help)\n") % name)
Dan Villiom Podlaski Christiansen
help: move the majority of the help command to the help module...
r18746 elif not ui.quiet:
Augie Fackler
formatting: blacken the codebase...
r43346 rst.append(
_(
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 b'\n(some details hidden, use --verbose '
b'to show complete help)'
Augie Fackler
formatting: blacken the codebase...
r43346 )
)
Dan Villiom Podlaski Christiansen
help: move the majority of the help command to the help module...
r18746
return rst
timeless
help: fix help -c/help -e/help -k...
r27325 def helplist(select=None, **opts):
rdamazio@google.com
help: adding support for command categories...
r40327 # Category -> list of commands
cats = {}
# Command -> short description
Dan Villiom Podlaski Christiansen
help: move the majority of the help command to the help module...
r18746 h = {}
rdamazio@google.com
help: adding support for command categories...
r40327 # Command -> string showing synonyms
syns = {}
Gregory Szorc
py3: finish porting iteritems() to pycompat and remove source transformer...
r43376 for c, e in pycompat.iteritems(commands.table):
Yuya Nishihara
help: use cmdutil.parsealiases() to resolve command name...
r36264 fs = cmdutil.parsealiases(c)
f = fs[0]
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 syns[f] = b', '.join(fs)
rdamazio@google.com
help: adding support for command categories...
r40327 func = e[0]
Rodrigo Damazio
help: adding a proper declaration for shortlist/basic commands (API)...
r40331 if select and not select(f):
Dan Villiom Podlaski Christiansen
help: move the majority of the help command to the help module...
r18746 continue
rdamazio@google.com
help: adding support for command categories...
r40327 doc = pycompat.getdoc(func)
rdamazio@google.com
help: displaying documented aliases by default...
r40450 if filtercmd(ui, f, func, name, doc):
Dan Villiom Podlaski Christiansen
help: move the majority of the help command to the help module...
r18746 continue
doc = gettext(doc)
if not doc:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 doc = _(b"(no help text available)")
Dan Villiom Podlaski Christiansen
help: move the majority of the help command to the help module...
r18746 h[f] = doc.splitlines()[0].rstrip()
rdamazio@google.com
help: adding support for command categories...
r40327
cat = getattr(func, 'helpcategory', None) or (
Augie Fackler
formatting: blacken the codebase...
r43346 registrar.command.CATEGORY_NONE
)
rdamazio@google.com
help: adding support for command categories...
r40327 cats.setdefault(cat, []).append(f)
Dan Villiom Podlaski Christiansen
help: move the majority of the help command to the help module...
r18746
rst = []
if not h:
if not ui.quiet:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 rst.append(_(b'no commands defined\n'))
Dan Villiom Podlaski Christiansen
help: move the majority of the help command to the help module...
r18746 return rst
rdamazio@google.com
help: adding support for command categories...
r40327 # Output top header.
Dan Villiom Podlaski Christiansen
help: move the majority of the help command to the help module...
r18746 if not ui.quiet:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 if name == b"shortlist":
rst.append(_(b'basic commands:\n\n'))
elif name == b"debug":
rst.append(_(b'debug commands (internal and unsupported):\n\n'))
Dan Villiom Podlaski Christiansen
help: move the majority of the help command to the help module...
r18746 else:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 rst.append(_(b'list of commands:\n'))
rdamazio@google.com
help: adding support for command categories...
r40327
def appendcmds(cmds):
cmds = sorted(cmds)
for c in cmds:
if ui.verbose:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 rst.append(b" :%s: %s\n" % (syns[c], h[c]))
rdamazio@google.com
help: adding support for command categories...
r40327 else:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 rst.append(b' :%s: %s\n' % (c, h[c]))
rdamazio@google.com
help: adding support for command categories...
r40327
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 if name in (b'shortlist', b'debug'):
rdamazio@google.com
help: adding support for command categories...
r40327 # List without categories.
appendcmds(h)
else:
# Check that all categories have an order.
missing_order = set(cats.keys()) - set(CATEGORY_ORDER)
if missing_order:
Augie Fackler
formatting: blacken the codebase...
r43346 ui.develwarn(
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 b'help categories missing from CATEGORY_ORDER: %s'
Augie Fackler
formatting: blacken the codebase...
r43346 % missing_order
)
rdamazio@google.com
help: adding support for command categories...
r40327
# List per category.
for cat in CATEGORY_ORDER:
catfns = cats.get(cat, [])
if catfns:
if len(cats) > 1:
catname = gettext(CATEGORY_NAMES[cat])
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 rst.append(b"\n%s:\n" % catname)
rst.append(b"\n")
rdamazio@google.com
help: adding support for command categories...
r40327 appendcmds(catfns)
Dan Villiom Podlaski Christiansen
help: move the majority of the help command to the help module...
r18746
timeless
help: fix help -c/help -e/help -k...
r27325 ex = opts.get
Augie Fackler
formatting: blacken the codebase...
r43346 anyopts = ex(r'keyword') or not (ex(r'command') or ex(r'extension'))
timeless
help: fix help -c/help -e/help -k...
r27325 if not name and anyopts:
Augie Fackler
formatting: blacken the codebase...
r43346 exts = listexts(
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 _(b'enabled extensions:'),
Augie Fackler
formatting: blacken the codebase...
r43346 extensions.enabled(),
showdeprecated=ui.verbose,
)
Dan Villiom Podlaski Christiansen
help: move the majority of the help command to the help module...
r18746 if exts:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 rst.append(b'\n')
Dan Villiom Podlaski Christiansen
help: move the majority of the help command to the help module...
r18746 rst.extend(exts)
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 rst.append(_(b"\nadditional help topics:\n"))
Rodrigo Damazio
help: splitting the topics by category...
r40328 # Group commands by category.
topiccats = {}
for topic in helptable:
names, header, doc = topic[0:3]
if len(topic) > 3 and topic[3]:
category = topic[3]
else:
category = TOPIC_CATEGORY_NONE
rdamazio@google.com
help: allow hiding of help topics...
r40449 topicname = names[0]
if not filtertopic(ui, topicname):
topiccats.setdefault(category, []).append(
Augie Fackler
formatting: blacken the codebase...
r43346 (topicname, header)
)
Rodrigo Damazio
help: splitting the topics by category...
r40328
# Check that all categories have an order.
missing_order = set(topiccats.keys()) - set(TOPIC_CATEGORY_ORDER)
if missing_order:
ui.develwarn(
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 b'help categories missing from TOPIC_CATEGORY_ORDER: %s'
Augie Fackler
formatting: blacken the codebase...
r43346 % missing_order
)
Rodrigo Damazio
help: splitting the topics by category...
r40328
# Output topics per category.
for cat in TOPIC_CATEGORY_ORDER:
topics = topiccats.get(cat, [])
if topics:
if len(topiccats) > 1:
catname = gettext(TOPIC_CATEGORY_NAMES[cat])
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 rst.append(b"\n%s:\n" % catname)
rst.append(b"\n")
Rodrigo Damazio
help: splitting the topics by category...
r40328 for t, desc in topics:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 rst.append(b" :%s: %s\n" % (t, desc))
Dan Villiom Podlaski Christiansen
help: move the majority of the help command to the help module...
r18746
Matt Mackall
help: refactor helplist optlist mess...
r22115 if ui.quiet:
pass
elif ui.verbose:
Augie Fackler
formatting: blacken the codebase...
r43346 rst.append(
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 b'\n%s\n'
% optrst(_(b"global options"), commands.globalopts, ui.verbose)
Augie Fackler
formatting: blacken the codebase...
r43346 )
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 if name == b'shortlist':
Augie Fackler
formatting: blacken the codebase...
r43346 rst.append(
Martin von Zweigbergk
cleanup: join string literals that are already on one line...
r43387 _(b"\n(use 'hg help' for the full list of commands)\n")
Augie Fackler
formatting: blacken the codebase...
r43346 )
Matt Mackall
help: refactor helplist optlist mess...
r22115 else:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 if name == b'shortlist':
Augie Fackler
formatting: blacken the codebase...
r43346 rst.append(
_(
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 b"\n(use 'hg help' for the full list of commands "
b"or 'hg -v' for details)\n"
Augie Fackler
formatting: blacken the codebase...
r43346 )
)
Matt Mackall
help: refactor helplist optlist mess...
r22115 elif name and not full:
Augie Fackler
formatting: blacken the codebase...
r43346 rst.append(
Martin von Zweigbergk
cleanup: join string literals that are already on one line...
r43387 _(b"\n(use 'hg help %s' to show the full help text)\n")
Augie Fackler
formatting: blacken the codebase...
r43346 % name
)
rdamazio@google.com
help: adding support for command categories...
r40327 elif name and syns and name in syns.keys():
Augie Fackler
formatting: blacken the codebase...
r43346 rst.append(
_(
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 b"\n(use 'hg help -v -e %s' to show built-in "
b"aliases and global options)\n"
Augie Fackler
formatting: blacken the codebase...
r43346 )
% name
)
Dan Villiom Podlaski Christiansen
help: move the majority of the help command to the help module...
r18746 else:
Augie Fackler
formatting: blacken the codebase...
r43346 rst.append(
_(
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 b"\n(use 'hg help -v%s' to show built-in aliases "
b"and global options)\n"
Augie Fackler
formatting: blacken the codebase...
r43346 )
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 % (name and b" " + name or b"")
Augie Fackler
formatting: blacken the codebase...
r43346 )
Dan Villiom Podlaski Christiansen
help: move the majority of the help command to the help module...
r18746 return rst
Gregory Szorc
help: pass sub-topic into help query functions...
r27378 def helptopic(name, subtopic=None):
Gregory Szorc
help: support loading sub-topics...
r27379 # Look for sub-topic entry first.
header, doc = None, None
if subtopic and name in subtopics:
for names, header, doc in subtopics[name]:
if subtopic in names:
break
Nathan Goldbaum
help: check if a subtopic exists and raise an error if it doesn't (issue6145)...
r42585 if not any(subtopic in s[0] for s in subtopics[name]):
raise error.UnknownCommand(name)
Gregory Szorc
help: support loading sub-topics...
r27379
if not header:
Rodrigo Damazio
help: splitting the topics by category...
r40328 for topic in helptable:
names, header, doc = topic[0:3]
Gregory Szorc
help: support loading sub-topics...
r27379 if name in names:
break
else:
raise error.UnknownCommand(name)
Dan Villiom Podlaski Christiansen
help: move the majority of the help command to the help module...
r18746
Dan Villiom Podlaski Christiansen
help: use a full header for topic titles...
r18748 rst = [minirst.section(header)]
Dan Villiom Podlaski Christiansen
help: move the majority of the help command to the help module...
r18746 # description
if not doc:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 rst.append(b" %s\n" % _(b"(no help text available)"))
Augie Fackler
help: restore use of callable() since it was readded in Python 3.2
r21796 if callable(doc):
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 rst += [b" %s\n" % l for l in doc(ui).splitlines()]
Dan Villiom Podlaski Christiansen
help: move the majority of the help command to the help module...
r18746
if not ui.verbose:
Augie Fackler
formatting: blacken the codebase...
r43346 omitted = _(
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 b'(some details hidden, use --verbose'
b' to show complete help)'
Augie Fackler
formatting: blacken the codebase...
r43346 )
Dan Villiom Podlaski Christiansen
help: move the majority of the help command to the help module...
r18746 indicateomitted(rst, omitted)
try:
cmdutil.findcmd(name, commands.table)
Augie Fackler
formatting: blacken the codebase...
r43346 rst.append(
Martin von Zweigbergk
cleanup: join string literals that are already on one line...
r43387 _(b"\nuse 'hg help -c %s' to see help for the %s command\n")
Augie Fackler
formatting: blacken the codebase...
r43346 % (name, name)
)
Dan Villiom Podlaski Christiansen
help: move the majority of the help command to the help module...
r18746 except error.UnknownCommand:
pass
return rst
Gregory Szorc
help: pass sub-topic into help query functions...
r27378 def helpext(name, subtopic=None):
Dan Villiom Podlaski Christiansen
help: move the majority of the help command to the help module...
r18746 try:
mod = extensions.find(name)
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 doc = gettext(pycompat.getdoc(mod)) or _(b'no help text available')
Dan Villiom Podlaski Christiansen
help: move the majority of the help command to the help module...
r18746 except KeyError:
mod = None
doc = extensions.disabledext(name)
if not doc:
raise error.UnknownCommand(name)
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 if b'\n' not in doc:
head, tail = doc, b""
Dan Villiom Podlaski Christiansen
help: move the majority of the help command to the help module...
r18746 else:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 head, tail = doc.split(b'\n', 1)
rst = [_(b'%s extension - %s\n\n') % (name.rpartition(b'.')[-1], head)]
Dan Villiom Podlaski Christiansen
help: move the majority of the help command to the help module...
r18746 if tail:
rst.extend(tail.splitlines(True))
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 rst.append(b'\n')
Dan Villiom Podlaski Christiansen
help: move the majority of the help command to the help module...
r18746
if not ui.verbose:
Augie Fackler
formatting: blacken the codebase...
r43346 omitted = _(
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 b'(some details hidden, use --verbose'
b' to show complete help)'
Augie Fackler
formatting: blacken the codebase...
r43346 )
Dan Villiom Podlaski Christiansen
help: move the majority of the help command to the help module...
r18746 indicateomitted(rst, omitted)
if mod:
try:
ct = mod.cmdtable
except AttributeError:
ct = {}
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 modcmds = {c.partition(b'|')[0] for c in ct}
Dan Villiom Podlaski Christiansen
help: move the majority of the help command to the help module...
r18746 rst.extend(helplist(modcmds.__contains__))
else:
Augie Fackler
formatting: blacken the codebase...
r43346 rst.append(
_(
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 b"(use 'hg help extensions' for information on enabling"
b" extensions)\n"
Augie Fackler
formatting: blacken the codebase...
r43346 )
)
Dan Villiom Podlaski Christiansen
help: move the majority of the help command to the help module...
r18746 return rst
Gregory Szorc
help: pass sub-topic into help query functions...
r27378 def helpextcmd(name, subtopic=None):
Augie Fackler
formatting: blacken the codebase...
r43346 cmd, ext, doc = extensions.disabledcmd(
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 ui, name, ui.configbool(b'ui', b'strict')
Augie Fackler
formatting: blacken the codebase...
r43346 )
Yuya Nishihara
help: load module doc of disabled extension in extensions.disabledcmd()...
r37996 doc = doc.splitlines()[0]
Dan Villiom Podlaski Christiansen
help: move the majority of the help command to the help module...
r18746
Augie Fackler
formatting: blacken the codebase...
r43346 rst = listexts(
Martin von Zweigbergk
cleanup: join string literals that are already on one line...
r43387 _(b"'%s' is provided by the following extension:") % cmd,
Augie Fackler
formatting: blacken the codebase...
r43346 {ext: doc},
indent=4,
showdeprecated=True,
)
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 rst.append(b'\n')
Augie Fackler
formatting: blacken the codebase...
r43346 rst.append(
_(
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 b"(use 'hg help extensions' for information on enabling "
b"extensions)\n"
Augie Fackler
formatting: blacken the codebase...
r43346 )
)
Dan Villiom Podlaski Christiansen
help: move the majority of the help command to the help module...
r18746 return rst
rst = []
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 kw = opts.get(b'keyword')
timeless
help: fix help -c/help -e/help -k...
r27325 if kw or name is None and any(opts[o] for o in opts):
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 matches = topicmatch(ui, commands, name or b'')
timeless@mozdev.org
help: fix help argument parsing and documentation...
r26238 helpareas = []
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 if opts.get(b'extension'):
helpareas += [(b'extensions', _(b'Extensions'))]
if opts.get(b'command'):
helpareas += [(b'commands', _(b'Commands'))]
timeless@mozdev.org
help: fix help argument parsing and documentation...
r26238 if not helpareas:
Augie Fackler
formatting: blacken the codebase...
r43346 helpareas = [
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 (b'topics', _(b'Topics')),
(b'commands', _(b'Commands')),
(b'extensions', _(b'Extensions')),
(b'extensioncommands', _(b'Extension Commands')),
Augie Fackler
formatting: blacken the codebase...
r43346 ]
timeless@mozdev.org
help: fix help argument parsing and documentation...
r26238 for t, title in helpareas:
Dan Villiom Podlaski Christiansen
help: move the majority of the help command to the help module...
r18746 if matches[t]:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 rst.append(b'%s:\n\n' % title)
Dan Villiom Podlaski Christiansen
help: move the majority of the help command to the help module...
r18746 rst.extend(minirst.maketable(sorted(matches[t]), 1))
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 rst.append(b'\n')
Pierre-Yves David
help: provide a more helpful message when no keyword are matched...
r21288 if not rst:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 msg = _(b'no matches')
hint = _(b"try 'hg help' for a list of topics")
Pierre-Yves David
error: get Abort from 'error' instead of 'util'...
r26587 raise error.Abort(msg, hint=hint)
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 elif name and name != b'shortlist':
timeless@mozdev.org
help: fix help argument parsing and documentation...
r26238 queries = []
Dan Villiom Podlaski Christiansen
help: move the majority of the help command to the help module...
r18746 if unknowncmd:
timeless@mozdev.org
help: fix help argument parsing and documentation...
r26238 queries += [helpextcmd]
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 if opts.get(b'extension'):
timeless@mozdev.org
help: fix help argument parsing and documentation...
r26238 queries += [helpext]
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 if opts.get(b'command'):
timeless@mozdev.org
help: fix help argument parsing and documentation...
r26238 queries += [helpcmd]
if not queries:
Dan Villiom Podlaski Christiansen
help: move the majority of the help command to the help module...
r18746 queries = (helptopic, helpcmd, helpext, helpextcmd)
for f in queries:
try:
Gregory Szorc
help: pass sub-topic into help query functions...
r27378 rst = f(name, subtopic)
Dan Villiom Podlaski Christiansen
help: move the majority of the help command to the help module...
r18746 break
Pierre-Yves David
help: suggest keyword search when no topic is found...
r21289 except error.UnknownCommand:
pass
else:
if unknowncmd:
raise error.UnknownCommand(name)
else:
Nathan Goldbaum
help: include subtopic in error message if passed...
r42586 if fullname:
formatname = fullname
else:
formatname = name
if subtopic:
hintname = subtopic
else:
hintname = name
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 msg = _(b'no such help topic: %s') % formatname
hint = _(b"try 'hg help --keyword %s'") % hintname
Pierre-Yves David
error: get Abort from 'error' instead of 'util'...
r26587 raise error.Abort(msg, hint=hint)
Dan Villiom Podlaski Christiansen
help: move the majority of the help command to the help module...
r18746 else:
# program name
if not ui.quiet:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 rst = [_(b"Mercurial Distributed SCM\n"), b'\n']
Augie Fackler
help: convert dict to strkwargs
r32547 rst.extend(helplist(None, **pycompat.strkwargs(opts)))
Dan Villiom Podlaski Christiansen
help: move the majority of the help command to the help module...
r18746
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 return b''.join(rst)
Augie Fackler
help: move rst formatting of help documents into help.py...
r31059
Augie Fackler
formatting: blacken the codebase...
r43346
def formattedhelp(
ui, commands, fullname, keep=None, unknowncmd=False, full=True, **opts
):
Augie Fackler
help: move rst formatting of help documents into help.py...
r31059 """get help for a given topic (as a dotted name) as rendered rst
Either returns the rendered help text or raises an exception.
"""
if keep is None:
keep = []
Augie Fackler
help: avoid mutating passed-in `keep` list in `formattedhelp`
r31265 else:
Augie Fackler
formatting: blacken the codebase...
r43346 keep = list(keep) # make a copy so we can mutate this later
Yuya Nishihara
help: rewrite parsing of help topic to not drop section name with dots...
r39375
# <fullname> := <name>[.<subtopic][.<section>]
name = subtopic = section = None
if fullname is not None:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 nameparts = fullname.split(b'.')
Yuya Nishihara
help: rewrite parsing of help topic to not drop section name with dots...
r39375 name = nameparts.pop(0)
if nameparts and name in subtopics:
subtopic = nameparts.pop(0)
if nameparts:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 section = encoding.lower(b'.'.join(nameparts))
Yuya Nishihara
help: rewrite parsing of help topic to not drop section name with dots...
r39375
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 textwidth = ui.configint(b'ui', b'textwidth')
Augie Fackler
help: move rst formatting of help documents into help.py...
r31059 termwidth = ui.termwidth() - 2
if textwidth <= 0 or termwidth < textwidth:
textwidth = termwidth
Augie Fackler
formatting: blacken the codebase...
r43346 text = help_(
ui,
commands,
name,
fullname=fullname,
subtopic=subtopic,
unknowncmd=unknowncmd,
full=full,
**opts
)
Augie Fackler
help: move rst formatting of help documents into help.py...
r31059
Yuya Nishihara
help: inline minirst.format()...
r39344 blocks, pruned = minirst.parse(text, keep=keep)
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 if b'verbose' in pruned:
keep.append(b'omitted')
Augie Fackler
help: move rst formatting of help documents into help.py...
r31059 else:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 keep.append(b'notomitted')
Yuya Nishihara
help: inline minirst.format()...
r39344 blocks, pruned = minirst.parse(text, keep=keep)
if section:
blocks = minirst.filtersections(blocks, section)
Yuya Nishihara
help: reorder section filtering flow to not format help text twice
r39345
# We could have been given a weird ".foo" section without a name
# to look for, or we could have simply failed to found "foo.bar"
# because bar isn't a section of foo
if section and not (blocks and name):
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 raise error.Abort(_(b"help section not found: %s") % fullname)
Yuya Nishihara
help: reorder section filtering flow to not format help text twice
r39345
Yuya Nishihara
help: inline minirst.format()...
r39344 return minirst.formatplain(blocks, textwidth)