##// END OF EJS Templates
help: use new function for getting first line of string...
Martin von Zweigbergk -
r49888:7bd5f862 default
parent child Browse files
Show More
@@ -37,6 +37,7 b' 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 = {
@@ -289,9 +290,8 b' def topicmatch(ui, commands, kw):'
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
@@ -305,7 +305,7 b' def topicmatch(ui, commands, kw):'
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:
@@ -317,7 +317,7 b' def topicmatch(ui, commands, kw):'
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):
@@ -607,7 +607,7 b' def makeitemsdoc(ui, topic, doc, marker,'
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'>>>'):
@@ -677,7 +677,7 b' def _getcategorizedhelpcmds(ui, cmdtable'
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
@@ -1043,7 +1043,7 b' def help_('
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,
General Comments 0
You need to be logged in to leave comments. Login now