equal
deleted
inserted
replaced
35 ) |
35 ) |
36 from .hgweb import webcommands |
36 from .hgweb import webcommands |
37 from .utils import ( |
37 from .utils import ( |
38 compression, |
38 compression, |
39 resourceutil, |
39 resourceutil, |
|
40 stringutil, |
40 ) |
41 ) |
41 |
42 |
42 _exclkeywords = { |
43 _exclkeywords = { |
43 b"(ADVANCED)", |
44 b"(ADVANCED)", |
44 b"(DEPRECATED)", |
45 b"(DEPRECATED)", |
287 summary = b'' |
288 summary = b'' |
288 # translate docs *before* searching there |
289 # translate docs *before* searching there |
289 func = entry[0] |
290 func = entry[0] |
290 docs = _(pycompat.getdoc(func)) or b'' |
291 docs = _(pycompat.getdoc(func)) or b'' |
291 if kw in cmd or lowercontains(summary) or lowercontains(docs): |
292 if kw in cmd or lowercontains(summary) or lowercontains(docs): |
292 doclines = docs.splitlines() |
293 if docs: |
293 if doclines: |
294 summary = stringutil.firstline(docs) |
294 summary = doclines[0] |
|
295 cmdname = cmdutil.parsealiases(cmd)[0] |
295 cmdname = cmdutil.parsealiases(cmd)[0] |
296 if filtercmd(ui, cmdname, func, kw, docs): |
296 if filtercmd(ui, cmdname, func, kw, docs): |
297 continue |
297 continue |
298 results[b'commands'].append((cmdname, summary)) |
298 results[b'commands'].append((cmdname, summary)) |
299 for name, docs in itertools.chain( |
299 for name, docs in itertools.chain( |
303 if not docs: |
303 if not docs: |
304 continue |
304 continue |
305 name = name.rpartition(b'.')[-1] |
305 name = name.rpartition(b'.')[-1] |
306 if lowercontains(name) or lowercontains(docs): |
306 if lowercontains(name) or lowercontains(docs): |
307 # extension docs are already translated |
307 # extension docs are already translated |
308 results[b'extensions'].append((name, docs.splitlines()[0])) |
308 results[b'extensions'].append((name, stringutil.firstline(docs))) |
309 try: |
309 try: |
310 mod = extensions.load(ui, name, b'') |
310 mod = extensions.load(ui, name, b'') |
311 except ImportError: |
311 except ImportError: |
312 # debug message would be printed in extensions.load() |
312 # debug message would be printed in extensions.load() |
313 continue |
313 continue |
315 if kw in cmd or (len(entry) > 2 and lowercontains(entry[2])): |
315 if kw in cmd or (len(entry) > 2 and lowercontains(entry[2])): |
316 cmdname = cmdutil.parsealiases(cmd)[0] |
316 cmdname = cmdutil.parsealiases(cmd)[0] |
317 func = entry[0] |
317 func = entry[0] |
318 cmddoc = pycompat.getdoc(func) |
318 cmddoc = pycompat.getdoc(func) |
319 if cmddoc: |
319 if cmddoc: |
320 cmddoc = gettext(cmddoc).splitlines()[0] |
320 cmddoc = stringutil.firstline(gettext(cmddoc)) |
321 else: |
321 else: |
322 cmddoc = _(b'(no help text available)') |
322 cmddoc = _(b'(no help text available)') |
323 if filtercmd(ui, cmdname, func, kw, cmddoc): |
323 if filtercmd(ui, cmdname, func, kw, cmddoc): |
324 continue |
324 continue |
325 results[b'extensioncommands'].append((cmdname, cmddoc)) |
325 results[b'extensioncommands'].append((cmdname, cmddoc)) |
605 text = gettext(text) |
605 text = gettext(text) |
606 if dedent: |
606 if dedent: |
607 # Abuse latin1 to use textwrap.dedent() on bytes. |
607 # Abuse latin1 to use textwrap.dedent() on bytes. |
608 text = textwrap.dedent(text.decode('latin1')).encode('latin1') |
608 text = textwrap.dedent(text.decode('latin1')).encode('latin1') |
609 lines = text.splitlines() |
609 lines = text.splitlines() |
610 doclines = [(lines[0])] |
610 doclines = [lines[0]] |
611 for l in lines[1:]: |
611 for l in lines[1:]: |
612 # Stop once we find some Python doctest |
612 # Stop once we find some Python doctest |
613 if l.strip().startswith(b'>>>'): |
613 if l.strip().startswith(b'>>>'): |
614 break |
614 break |
615 if dedent: |
615 if dedent: |
675 if filtercmd(ui, f, func, name, doc): |
675 if filtercmd(ui, f, func, name, doc): |
676 continue |
676 continue |
677 doc = gettext(doc) |
677 doc = gettext(doc) |
678 if not doc: |
678 if not doc: |
679 doc = _(b"(no help text available)") |
679 doc = _(b"(no help text available)") |
680 h[f] = doc.splitlines()[0].rstrip() |
680 h[f] = stringutil.firstline(doc).rstrip() |
681 |
681 |
682 cat = getattr(func, 'helpcategory', None) or ( |
682 cat = getattr(func, 'helpcategory', None) or ( |
683 registrar.command.CATEGORY_NONE |
683 registrar.command.CATEGORY_NONE |
684 ) |
684 ) |
685 cats.setdefault(cat, []).append(f) |
685 cats.setdefault(cat, []).append(f) |
1041 |
1041 |
1042 def helpextcmd(name, subtopic=None): |
1042 def helpextcmd(name, subtopic=None): |
1043 cmd, ext, doc = extensions.disabledcmd( |
1043 cmd, ext, doc = extensions.disabledcmd( |
1044 ui, name, ui.configbool(b'ui', b'strict') |
1044 ui, name, ui.configbool(b'ui', b'strict') |
1045 ) |
1045 ) |
1046 doc = doc.splitlines()[0] |
1046 doc = stringutil.firstline(doc) |
1047 |
1047 |
1048 rst = listexts( |
1048 rst = listexts( |
1049 _(b"'%s' is provided by the following extension:") % cmd, |
1049 _(b"'%s' is provided by the following extension:") % cmd, |
1050 {ext: doc}, |
1050 {ext: doc}, |
1051 indent=4, |
1051 indent=4, |