Skip to content

Commit

Permalink
Backport/2.7/docs default lists (#56667)
Browse files Browse the repository at this point in the history
* Improve rendering of default lists (#56041)

(cherry picked from commit 53ed1bf)

* Add compat tojson filter for jinja2 versions missing it (#56596)

(cherry picked from commit 3f4a22d)
  • Loading branch information
acozine committed May 21, 2019
1 parent 9e9db8a commit c452837
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions docs/bin/plugin_formatter.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

import datetime
import glob
import json
import optparse
import os
import re
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion docs/templates/plugin.rst.j2
Original file line number Diff line number Diff line change
Expand Up @@ -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 #}
Expand Down

0 comments on commit c452837

Please sign in to comment.