Documentation: show non-string non-iterable defaults for choices (#40… (#42075)

* Documentation: show non-string non-iterable defaults for choices (#40212)

* Also marking non-string defaults.

* Adding list filter from #37517 to plugin_formatter.

* Simplifying list test.

* Redistribute imports

(cherry picked from commit 0752dc12b7)

* for 2.6 compatibility, removes dependency on collections.py, take two

* fix blank line error
pull/42883/head
Alicia Cozine 6 years ago committed by Matt Clay
parent 498aca834e
commit b0dae4f90e

@ -29,7 +29,7 @@ import os
import re
import sys
import warnings
from collections import defaultdict
from collections import defaultdict, Sequence
from distutils.version import LooseVersion
from pprint import PrettyPrinter
@ -154,6 +154,12 @@ def rst_xline(width, char="="):
return char * width
def test_list(value):
''' Return true if the object is a list or tuple '''
return isinstance(value, Sequence) and not isinstance(value, string_types)
def write_data(text, output_dir, outputname, module=None):
''' dumps module output to a file or the screen, as requested '''
@ -334,6 +340,7 @@ 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':

@ -143,7 +143,7 @@ Parameters
{% elif choice is sameas false %}
{% set choice = 'no' %}
{% endif %}
{% if (value.default is string and value.default == choice) or (value.default is iterable and value.default is not string and choice in value.default) %}
{% if (value.default is not list and value.default == choice) or (value.default is list and choice in value.default) %}
<li><div style="color: blue"><b>@{ choice | escape }@</b>&nbsp;&larr;</div></li>
{% else %}
<li>@{ choice | escape }@</li>

Loading…
Cancel
Save