D5742: histedit: add templating support to histedit's rule file generation

Yuya Nishihara yuya at tcha.org
Sat Feb 2 01:44:56 UTC 2019


Queued, thanks.

> +++ b/mercurial/help.py
> @@ -394,7 +394,17 @@
>  def addtopichook(topic, rewriter):
>      helphooks.setdefault(topic, []).append(rewriter)
>  
> -def makeitemsdoc(ui, topic, doc, marker, items, dedent=False):
> +def _templateextsyms(ui, topic, doc):
> +    for name, ext in extensions.extensions(ui):
> +        kw = getattr(ext, 'templatekeyword', None)
> +        if kw is not None:
> +            doc = addtopicsymbols(
> +                'templates', 'Filters\n=======', kw, keepmarker=True)
> +    return doc
> +
> +addtopichook('templating', _templateextsyms)
> +
> +def makeitemsdoc(ui, topic, doc, marker, items, dedent=False, keepmarker=False):
>      """Extract docstring from the items key to function mapping, build a
>      single documentation block and use it to overwrite the marker in doc.
>      """
> @@ -420,11 +430,14 @@
>                  doclines.append('  ' + l.strip())
>          entries.append('\n'.join(doclines))
>      entries = '\n\n'.join(entries)
> +    if keepmarker:
> +        entries = entries + '\n\n' + marker
>      return doc.replace(marker, entries)
>  
> -def addtopicsymbols(topic, marker, symbols, dedent=False):
> +def addtopicsymbols(topic, marker, symbols, dedent=False, keepmarker=False):
>      def add(ui, topic, doc):
> -        return makeitemsdoc(ui, topic, doc, marker, symbols, dedent=dedent)
> +        return makeitemsdoc(ui, topic, doc, marker, symbols, dedent=dedent,
> +                            keepmarker=keepmarker)

Looks like unrelated change. Dropped.

> +        summary = cmdutil.rendertemplate(
> +            ctx, ui.config('histedit', 'summary-template')) or ''
> +        summary = summary.splitlines()[0]

Still crash. `''.splitlines() == []`


More information about the Mercurial-devel mailing list