[PATCH 3 of 3] templatefilters: document the json filter

Yuya Nishihara yuya at tcha.org
Mon May 7 09:17:16 EDT 2018

# HG changeset patch
# User Yuya Nishihara <yuya at 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.

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):
 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:

More information about the Mercurial-devel mailing list