Patchwork [2,of,2] help: populate template functions via docstrings

login
register
mail settings
Submitter Gregory Szorc
Date April 2, 2015, 3:28 a.m.
Message ID <5178cb5f891d43571dcd.1427945321@gps-mbp.local>
Download mbox | patch
Permalink /patch/8444/
State Accepted
Headers show

Comments

Gregory Szorc - April 2, 2015, 3:28 a.m.
# HG changeset patch
# User Gregory Szorc <gregory.szorc@gmail.com>
# Date 1427945038 25200
#      Wed Apr 01 20:23:58 2015 -0700
# Node ID 5178cb5f891d43571dcd169ba9dd546a4a976a8d
# Parent  450d5d8893a0481fc430cfa0a74c58a9c1cd1a2d
help: populate template functions via docstrings

We do this for revsets, template keywrods, and template filters. Now we
do it for template functions as well.
Matt Mackall - April 2, 2015, 8:58 p.m.
On Wed, 2015-04-01 at 20:28 -0700, Gregory Szorc wrote:
> # HG changeset patch
> # User Gregory Szorc <gregory.szorc@gmail.com>
> # Date 1427945038 25200
> #      Wed Apr 01 20:23:58 2015 -0700
> # Node ID 5178cb5f891d43571dcd169ba9dd546a4a976a8d
> # Parent  450d5d8893a0481fc430cfa0a74c58a9c1cd1a2d
> help: populate template functions via docstrings

Thanks, these are queued for default.

Patch

diff --git a/mercurial/help.py b/mercurial/help.py
--- a/mercurial/help.py
+++ b/mercurial/help.py
@@ -8,8 +8,9 @@ 
 from i18n import gettext, _
 import itertools, os, textwrap
 import error
 import extensions, revset, fileset, templatekw, templatefilters, filemerge
+import templater
 import encoding, util, minirst
 import cmdutil
 import hgweb.webcommands as webcommands
 
@@ -208,8 +209,9 @@  addtopicsymbols('merge-tools', '.. inter
                 filemerge.internalsdoc)
 addtopicsymbols('revsets', '.. predicatesmarker', revset.symbols)
 addtopicsymbols('templates', '.. keywordsmarker', templatekw.dockeywords)
 addtopicsymbols('templates', '.. filtersmarker', templatefilters.filters)
+addtopicsymbols('templates', '.. functionsmarker', templater.funcs)
 addtopicsymbols('hgweb', '.. webcommandsmarker', webcommands.commands,
                 dedent=True)
 
 def help_(ui, name, unknowncmd=False, full=True, **opts):
diff --git a/mercurial/help/templates.txt b/mercurial/help/templates.txt
--- a/mercurial/help/templates.txt
+++ b/mercurial/help/templates.txt
@@ -40,41 +40,9 @@  Note that a filter is nothing more than 
 ``expr|filter`` is equivalent to ``filter(expr)``.
 
 In addition to filters, there are some basic built-in functions:
 
-- date(date[, fmt])
-
-- diff([includepattern [, excludepattern]])
-
-- fill(text[, width])
-
-- get(dict, key)
-
-- if(expr, then[, else])
-
-- ifcontains(expr, expr, then[, else])
-
-- ifeq(expr, expr, then[, else])
-
-- join(list, sep)
-
-- label(label, expr)
-
-- pad(text, width[, fillchar, right])
-
-- revset(query[, formatargs])
-
-- rstdoc(text, style)
-
-- shortest(node)
-
-- startswith(string, text)
-
-- strip(text[, chars])
-
-- sub(pat, repl, expr)
-
-- word(number, text[, separator])
+.. functionsmarker
 
 Also, for any expression that returns a list, there is a list operator:
 
 - expr % "{template}"