summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlicia Cozine <879121+acozine@users.noreply.github.com>2019-05-21 11:48:59 -0500
committerGitHub <noreply@github.com>2019-05-21 11:48:59 -0500
commitc452837c5dc38698034f6b94c9588bcd5ed93888 (patch)
tree0ec076baa17f4c0d12bf5c93cc300793533a1058
parent9e9db8a17d65dc30adb883ea25f2a857257f426d (diff)
downloadansible-c452837c5dc38698034f6b94c9588bcd5ed93888.tar.gz
Backport/2.7/docs default lists (#56667)
* Improve rendering of default lists (#56041) (cherry picked from commit 53ed1bfc49a14b17f86af3f1a0009417ea840d72) * Add compat tojson filter for jinja2 versions missing it (#56596) (cherry picked from commit 3f4a22d8efe22484ba5b5df6bb14a9929d899a6a)
-rwxr-xr-xdocs/bin/plugin_formatter.py5
-rw-r--r--docs/templates/plugin.rst.j22
2 files changed, 6 insertions, 1 deletions
diff --git a/docs/bin/plugin_formatter.py b/docs/bin/plugin_formatter.py
index bebc33d29e..c3a36cfa8c 100755
--- a/docs/bin/plugin_formatter.py
+++ b/docs/bin/plugin_formatter.py
@@ -11,6 +11,7 @@ __metaclass__ = type
import datetime
import glob
+import json
import optparse
import os
import re
@@ -365,6 +366,10 @@ def jinja2_environment(template_dir, typ, plugin_type):
# Jinja < 2.10
env.filters['max'] = do_max
+ if 'tojson' not in env.filters:
+ # Jinja < 2.9
+ env.filters['tojson'] = json.dumps
+
templates = {}
if typ == 'rst':
env.filters['rst_ify'] = rst_ify
diff --git a/docs/templates/plugin.rst.j2 b/docs/templates/plugin.rst.j2
index c10471d5dc..6c3b13c2a0 100644
--- a/docs/templates/plugin.rst.j2
+++ b/docs/templates/plugin.rst.j2
@@ -155,7 +155,7 @@ Parameters
{% endif %}
{# Show default value, when multiple choice or no choices #}
{% if value.default is defined and value.default not in value.choices %}
- <b>Default:</b><br/><div style="color: blue">@{ value.default | escape }@</div>
+ <b>Default:</b><br/><div style="color: blue">@{ value.default | tojson | escape }@</div>
{% endif %}
</td>
{# configuration #}