Patchwork [1,of,4] templater: rewrite docstring of templater.__init__()

login
register
mail settings
Submitter Yuya Nishihara
Date Dec. 22, 2017, 2:08 p.m.
Message ID <a311f085ddf3e7d64d74.1513951707@mimosa>
Download mbox | patch
Permalink /patch/26396/
State Accepted
Headers show

Comments

Yuya Nishihara - Dec. 22, 2017, 2:08 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1513944737 -32400
#      Fri Dec 22 21:12:17 2017 +0900
# Node ID a311f085ddf3e7d64d741a0e6f98c8f461d22fb1
# Parent  bb6a80fc969a2c5da80cbb7f29de7ca576c4e251
templater: rewrite docstring of templater.__init__()

More importantly, this patch adds what the cache is.
Gregory Szorc - Dec. 22, 2017, 6:41 p.m.
On Fri, Dec 22, 2017 at 6:08 AM, Yuya Nishihara <yuya@tcha.org> wrote:

> # HG changeset patch
> # User Yuya Nishihara <yuya@tcha.org>
> # Date 1513944737 -32400
> #      Fri Dec 22 21:12:17 2017 +0900
> # Node ID a311f085ddf3e7d64d741a0e6f98c8f461d22fb1
> # Parent  bb6a80fc969a2c5da80cbb7f29de7ca576c4e251
> templater: rewrite docstring of templater.__init__()
>

Queued 1-3.


>
> More importantly, this patch adds what the cache is.
>
> diff --git a/mercurial/templater.py b/mercurial/templater.py
> --- a/mercurial/templater.py
> +++ b/mercurial/templater.py
> @@ -1434,13 +1434,19 @@ class templater(object):
>
>      def __init__(self, filters=None, defaults=None, resources=None,
>                   cache=None, aliases=(), minchunk=1024, maxchunk=65536):
> -        '''set up template engine.
> -        filters is dict of functions. each transforms a value into
> another.
> -        defaults is dict of default map definitions.
> -        resources is dict of internal data (e.g. cache), which are
> inaccessible
> -        from user template.
> -        aliases is list of alias (name, replacement) pairs.
> -        '''
> +        """Create template engine optionally with preloaded template
> fragments
> +
> +        - ``filters``: a dict of functions to transform a value into
> another.
> +        - ``defaults``: a dict of symbol values/functions; may be
> overridden
> +          by a ``mapping`` dict.
> +        - ``resources``: a dict of internal data (e.g. cache),
> inaccessible
> +          from user template; may be overridden by a ``mapping`` dict.
> +        - ``cache``: a dict of preloaded template fragments.
> +        - ``aliases``: a list of alias (name, replacement) pairs.
> +
> +        self.cache may be updated later to register additional template
> +        fragments.
> +        """
>          if filters is None:
>              filters = {}
>          if defaults is None:
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
>

Patch

diff --git a/mercurial/templater.py b/mercurial/templater.py
--- a/mercurial/templater.py
+++ b/mercurial/templater.py
@@ -1434,13 +1434,19 @@  class templater(object):
 
     def __init__(self, filters=None, defaults=None, resources=None,
                  cache=None, aliases=(), minchunk=1024, maxchunk=65536):
-        '''set up template engine.
-        filters is dict of functions. each transforms a value into another.
-        defaults is dict of default map definitions.
-        resources is dict of internal data (e.g. cache), which are inaccessible
-        from user template.
-        aliases is list of alias (name, replacement) pairs.
-        '''
+        """Create template engine optionally with preloaded template fragments
+
+        - ``filters``: a dict of functions to transform a value into another.
+        - ``defaults``: a dict of symbol values/functions; may be overridden
+          by a ``mapping`` dict.
+        - ``resources``: a dict of internal data (e.g. cache), inaccessible
+          from user template; may be overridden by a ``mapping`` dict.
+        - ``cache``: a dict of preloaded template fragments.
+        - ``aliases``: a list of alias (name, replacement) pairs.
+
+        self.cache may be updated later to register additional template
+        fragments.
+        """
         if filters is None:
             filters = {}
         if defaults is None: