Patchwork [3,of,3] templatefilters: document the json filter

login
register
mail settings
Submitter Yuya Nishihara
Date May 7, 2018, 1:17 p.m.
Message ID <fe85fe4b7cd677ea2267.1525699036@mimosa>
Download mbox | patch
Permalink /patch/31304/
State Accepted
Headers show

Comments

Yuya Nishihara - May 7, 2018, 1:17 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1452939833 -32400
#      Sat Jan 16 19:23:53 2016 +0900
# Node ID fe85fe4b7cd677ea2267c002a8534bc079a82d51
# Parent  fdb6dfcc700e6e3c9751e7b4287bdc231acc27e9
templatefilters: document the json filter

I don't know the exact reason why it was undocumented, but that would be
because unicode is difficult for humans. Since the json filter can now get
localstr back to UTF-8 as long as it is unprocessed (i.e. {desc|json} works,
but {desc|firstline|json} doesn't), it seems good enough to advertise the
json filter.
Augie Fackler - May 11, 2018, 4:42 a.m.
On Mon, May 07, 2018 at 10:17:16PM +0900, Yuya Nishihara wrote:
> # HG changeset patch
> # User Yuya Nishihara <yuya@tcha.org>
> # Date 1452939833 -32400
> #      Sat Jan 16 19:23:53 2016 +0900
> # Node ID fe85fe4b7cd677ea2267c002a8534bc079a82d51
> # Parent  fdb6dfcc700e6e3c9751e7b4287bdc231acc27e9
> templatefilters: document the json filter

queued, thanks

Patch

diff --git a/mercurial/templatefilters.py b/mercurial/templatefilters.py
--- a/mercurial/templatefilters.py
+++ b/mercurial/templatefilters.py
@@ -238,6 +238,7 @@  def indent(text, prefix):
 
 @templatefilter('json')
 def json(obj, paranoid=True):
+    """Any object. Serializes the object to a JSON formatted text."""
     if obj is None:
         return 'null'
     elif obj is False: