def extshelp(): rst = loaddoc('extensions')().splitlines(True) rst.extend(listexts( _('enabled extensions:'), extensions.enabled(), showdeprecated=True)) rst.extend(listexts(_('disabled extensions:'), extensions.disabled())) doc = ''.join(rst) return doc
def extshelp(): doc = loaddoc('extensions')() exts, maxlength = extensions.enabled() doc += listexts(_('enabled extensions:'), exts, maxlength) exts, maxlength = extensions.disabled() doc += listexts(_('disabled extensions:'), exts, maxlength) return doc
def topicmatch(kw): """Return help topics matching kw. Returns {'section': [(name, summary), ...], ...} where section is one of topics, commands, extensions, or extensioncommands. """ kw = encoding.lower(kw) def lowercontains(container): return kw in encoding.lower(container) # translated in helptable results = { 'topics': [], 'commands': [], 'extensions': [], 'extensioncommands': [], } for names, header, doc in helptable: # Old extensions may use a str as doc. if (sum(map(lowercontains, names)) or lowercontains(header) or (callable(doc) and lowercontains(doc()))): results['topics'].append((names[0], header)) import commands # avoid cycle for cmd, entry in commands.table.iteritems(): if len(entry) == 3: summary = entry[2] else: summary = '' # translate docs *before* searching there docs = _(getattr(entry[0], '__doc__', None)) or '' if kw in cmd or lowercontains(summary) or lowercontains(docs): doclines = docs.splitlines() if doclines: summary = doclines[0] cmdname = cmd.split('|')[0].lstrip('^') results['commands'].append((cmdname, summary)) for name, docs in itertools.chain( extensions.enabled(False).iteritems(), extensions.disabled().iteritems()): # extensions.load ignores the UI argument mod = extensions.load(None, name, '') name = name.split('.')[-1] if lowercontains(name) or lowercontains(docs): # extension docs are already translated results['extensions'].append((name, docs.splitlines()[0])) for cmd, entry in getattr(mod, 'cmdtable', {}).iteritems(): if kw in cmd or (len(entry) > 2 and lowercontains(entry[2])): cmdname = cmd.split('|')[0].lstrip('^') if entry[0].__doc__: cmddoc = gettext(entry[0].__doc__).splitlines()[0] else: cmddoc = _('(no help text available)') results['extensioncommands'].append((cmdname, cmddoc)) return results
def topicmatch(kw): """Return help topics matching kw. Returns {'section': [(name, summary), ...], ...} where section is one of topics, commands, extensions, or extensioncommands. """ kw = encoding.lower(kw) def lowercontains(container): return kw in encoding.lower(container) # translated in helptable results = {'topics': [], 'commands': [], 'extensions': [], 'extensioncommands': [], } for names, header, doc in helptable: if (sum(map(lowercontains, names)) or lowercontains(header) or lowercontains(doc())): results['topics'].append((names[0], header)) import commands # avoid cycle for cmd, entry in commands.table.iteritems(): if cmd.startswith('debug'): continue if len(entry) == 3: summary = entry[2] else: summary = '' # translate docs *before* searching there docs = _(getattr(entry[0], '__doc__', None)) or '' if kw in cmd or lowercontains(summary) or lowercontains(docs): doclines = docs.splitlines() if doclines: summary = doclines[0] cmdname = cmd.split('|')[0].lstrip('^') results['commands'].append((cmdname, summary)) for name, docs in itertools.chain( extensions.enabled(False).iteritems(), extensions.disabled().iteritems()): # extensions.load ignores the UI argument mod = extensions.load(None, name, '') name = name.split('.')[-1] if lowercontains(name) or lowercontains(docs): # extension docs are already translated results['extensions'].append((name, docs.splitlines()[0])) for cmd, entry in getattr(mod, 'cmdtable', {}).iteritems(): if kw in cmd or (len(entry) > 2 and lowercontains(entry[2])): cmdname = cmd.split('|')[0].lstrip('^') if entry[0].__doc__: cmddoc = gettext(entry[0].__doc__).splitlines()[0] else: cmddoc = _('(no help text available)') results['extensioncommands'].append((cmdname, cmddoc)) return results
def extshelp(): doc = _( r""" Mercurial has the ability to add new features through the use of extensions. Extensions may add new commands, add options to existing commands, change the default behavior of commands, or implement hooks. Extensions are not loaded by default for a variety of reasons: they can increase startup overhead; they may be meant for advanced usage only; they may provide potentially dangerous abilities (such as letting you destroy or modify history); they might not be ready for prime time; or they may alter some usual behaviors of stock Mercurial. It is thus up to the user to activate extensions as needed. To enable the "foo" extension, either shipped with Mercurial or in the Python search path, create an entry for it in your hgrc, like this: [extensions] foo = You may also specify the full path to an extension: [extensions] myfeature = ~/.hgext/myfeature.py To explicitly disable an extension enabled in an hgrc of broader scope, prepend its path with !: [extensions] # disabling extension bar residing in /path/to/extension/bar.py hgext.bar = !/path/to/extension/bar.py # ditto, but no path was supplied for extension baz hgext.baz = ! """ ) exts, maxlength = extensions.enabled() doc += listexts(_("enabled extensions:"), exts, maxlength) exts, maxlength = extensions.disabled() doc += listexts(_("disabled extensions:"), exts, maxlength) return doc
def extshelp(): doc = _(r''' Mercurial has the ability to add new features through the use of extensions. Extensions may add new commands, add options to existing commands, change the default behavior of commands, or implement hooks. Extensions are not loaded by default for a variety of reasons: they can increase startup overhead; they may be meant for advanced usage only; they may provide potentially dangerous abilities (such as letting you destroy or modify history); they might not be ready for prime time; or they may alter some usual behaviors of stock Mercurial. It is thus up to the user to activate extensions as needed. To enable the "foo" extension, either shipped with Mercurial or in the Python search path, create an entry for it in your hgrc, like this:: [extensions] foo = You may also specify the full path to an extension:: [extensions] myfeature = ~/.hgext/myfeature.py To explicitly disable an extension enabled in an hgrc of broader scope, prepend its path with !:: [extensions] # disabling extension bar residing in /path/to/extension/bar.py hgext.bar = !/path/to/extension/bar.py # ditto, but no path was supplied for extension baz hgext.baz = ! ''') exts, maxlength = extensions.enabled() doc += listexts(_('enabled extensions:'), exts, maxlength) exts, maxlength = extensions.disabled() doc += listexts(_('disabled extensions:'), exts, maxlength) return doc
def helplist(select=None): # list of commands if name == "shortlist": header = _('basic commands:\n\n') elif name == "debug": header = _('debug commands (internal and unsupported):\n\n') else: header = _('list of commands:\n\n') h = {} cmds = {} for c, e in commands.table.iteritems(): f = c.split("|", 1)[0] if select and not select(f): continue if (not select and name != 'shortlist' and e[0].__module__ != commands.__name__): continue if name == "shortlist" and not f.startswith("^"): continue f = f.lstrip("^") if not ui.debugflag and f.startswith("debug") and name != "debug": continue doc = e[0].__doc__ if doc and 'DEPRECATED' in doc and not ui.verbose: continue doc = gettext(doc) if not doc: doc = _("(no help text available)") h[f] = doc.splitlines()[0].rstrip() cmds[f] = c.lstrip("^") rst = [] if not h: if not ui.quiet: rst.append(_('no commands defined\n')) return rst if not ui.quiet: rst.append(header) fns = sorted(h) for f in fns: if ui.verbose: commacmds = cmds[f].replace("|",", ") rst.append(" :%s: %s\n" % (commacmds, h[f])) else: rst.append(' :%s: %s\n' % (f, h[f])) if not name: exts = listexts(_('enabled extensions:'), extensions.enabled()) if exts: rst.append('\n') rst.extend(exts) rst.append(_("\nadditional help topics:\n\n")) topics = [] for names, header, doc in helptable: topics.append((names[0], header)) for t, desc in topics: rst.append(" :%s: %s\n" % (t, desc)) if ui.quiet: pass elif ui.verbose: rst.append('\n%s\n' % optrst(_("global options"), commands.globalopts, ui.verbose)) if name == 'shortlist': rst.append(_('\n(use "hg help" for the full list ' 'of commands)\n')) else: if name == 'shortlist': rst.append(_('\n(use "hg help" for the full list of commands ' 'or "hg -v" for details)\n')) elif name and not full: rst.append(_('\n(use "hg help %s" to show the full help ' 'text)\n') % name) elif name and cmds and name in cmds.keys(): rst.append(_('\n(use "hg help -v -e %s" to show built-in ' 'aliases and global options)\n') % name) else: rst.append(_('\n(use "hg help -v%s" to show built-in aliases ' 'and global options)\n') % (name and " " + name or "")) return rst