From 06b70f16140e715d37de533f0aa199ea524720c2 Mon Sep 17 00:00:00 2001 From: Brian Coca Date: Tue, 20 Mar 2018 18:20:30 -0400 Subject: [PATCH] Revert "Add a few Jinja2 tests to simplify template (#37514)" This reverts commit b8e07f0d6efe27b7c7ecaa992700353e38c88984. --- docs/bin/plugin_formatter.py | 11 +---------- docs/templates/plugin.rst.j2 | 16 +++++++++------- 2 files changed, 10 insertions(+), 17 deletions(-) diff --git a/docs/bin/plugin_formatter.py b/docs/bin/plugin_formatter.py index ff381a3676..12a034f62e 100755 --- a/docs/bin/plugin_formatter.py +++ b/docs/bin/plugin_formatter.py @@ -29,7 +29,7 @@ import os import re import sys import warnings -from collections import defaultdict, Sequence +from collections import defaultdict from distutils.version import LooseVersion from pprint import PrettyPrinter @@ -132,12 +132,6 @@ def rst_xline(width, char="="): return char * width -# NOTE: The existing Jinja2 'sequence' tests matches strings and dictionaries -def test_list(value): - ''' Return true if objects is a list or tupple ''' - return isinstance(value, Sequence) - - def write_data(text, output_dir, outputname, module=None): ''' dumps module output to a file or the screen, as requested ''' @@ -310,9 +304,6 @@ def jinja2_environment(template_dir, typ, plugin_type): env.filters['html_ify'] = html_ify env.filters['fmt'] = rst_fmt env.filters['xline'] = rst_xline - - env.tests['list'] = test_list - templates['plugin'] = env.get_template('plugin.rst.j2') if plugin_type == 'module': diff --git a/docs/templates/plugin.rst.j2 b/docs/templates/plugin.rst.j2 index c146389a98..35bf13e41b 100644 --- a/docs/templates/plugin.rst.j2 +++ b/docs/templates/plugin.rst.j2 @@ -108,10 +108,12 @@ Parameters
{# Turn boolean values in 'yes' and 'no' values #} - {% if value.default is sameas true %} - {% set _x = value.update({'default': 'yes'}) %} - {% elif value.default is sameas false %} - {% set _x = value.update({'default': 'no'}) %} + {% if value.default is defined %} + {% if value.default == true %} + {% set _x = value.update({'default': 'yes'}) %} + {% elif value.default == false %} + {% set _x = value.update({'default': 'no'}) %} + {% endif %} {% endif %} {% if value.type == 'bool' %} {% set _x = value.update({'choices': ['no', 'yes']}) %} @@ -121,12 +123,12 @@ Parameters