Skip to content

Commit e6e25bc

Browse files
authored
Avoid repeating input argument when it is mentioned as positional. (#10)
1 parent 557c331 commit e6e25bc

File tree

3 files changed

+14
-5
lines changed

3 files changed

+14
-5
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
bugfixes:
2+
- "Make sure that ``_input`` does not show up twice for test or filter arguments when the plugin mentions it in ``positional`` (https://github.com/ansible-community/antsibull-docs/pull/10)."

src/antsibull_docs/data/docsite/plugin.rst.j2

+3-3
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ This describes the input of the test, the value before ``is @{plugin_name}@`` or
202202

203203
{% endif %}
204204

205-
{% if doc['positional'] and plugin_type in ['lookup', 'filter', 'test'] %}
205+
{% if doc['positional'] and plugin_type in ['lookup', 'filter', 'test'] and doc['positional'] != ['_input'] %}
206206
{% set options_to_skip = options_to_skip + doc['positional'] %}
207207

208208
.. Positional
@@ -217,9 +217,9 @@ This describes positional parameters of the test. These are the values ``positio
217217
{% endif %}
218218

219219
{% if use_html_blobs %}
220-
@{ parameters_html(doc['options'] | extract_options_from_list(doc['positional']), suboption_key='suboptions') }@
220+
@{ parameters_html(doc['options'] | extract_options_from_list(doc['positional'], options_to_ignore=['_input']), suboption_key='suboptions') }@
221221
{% else %}
222-
@{ parameters_rst(doc['options'] | extract_options_from_list(doc['positional']), suboption_key='suboptions') }@
222+
@{ parameters_rst(doc['options'] | extract_options_from_list(doc['positional'], options_to_ignore=['_input']), suboption_key='suboptions') }@
223223
{% endif %}
224224

225225
{% endif %}

src/antsibull_docs/jinja2/filters.py

+9-2
Original file line numberDiff line numberDiff line change
@@ -197,9 +197,16 @@ def massage_author_name(value):
197197

198198

199199
def extract_options_from_list(options: t.Dict[str, t.Any],
200-
options_to_extract: t.List[str]) -> t.List[t.Tuple[str, t.Any]]:
200+
options_to_extract: t.List[str],
201+
options_to_ignore: t.Optional[t.List[str]] = None
202+
) -> t.List[t.Tuple[str, t.Any]]:
201203
''' return list of tuples (option, option_data) with option from options_to_extract '''
202-
return [(option, options[option]) for option in options_to_extract if option in options]
204+
if options_to_ignore is None:
205+
options_to_ignore = []
206+
return [
207+
(option, options[option]) for option in options_to_extract
208+
if option in options and option not in options_to_ignore
209+
]
203210

204211

205212
def remove_options_from_list(options: t.Dict[str, t.Any],

0 commit comments

Comments
 (0)