Skip to content

Commit

Permalink
Add support for 'keyword' (#329)
Browse files Browse the repository at this point in the history
* Allow 'keyword' in schema.

* Include 'keyword' in output.

* Add changelog fragment.
  • Loading branch information
felixfontein authored Jan 21, 2022
1 parent 36fc1f7 commit 8789427
Show file tree
Hide file tree
Showing 15 changed files with 133 additions and 0 deletions.
2 changes: 2 additions & 0 deletions changelogs/fragments/329-keywords.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
minor_changes:
- Support new ``keyword`` field in plugin documentations (https://github.com/ansible-community/antsibull/pull/329).
17 changes: 17 additions & 0 deletions src/antsibull/data/docsite/macros/parameters.rst.j2
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,14 @@
{% endif %}
@{ deprecates_rst(myvar['deprecated'], collection, 8) }@
{% endfor %}
{% for kw in value['keyword'] %}
- Keyword: @{ kw['name'] | rst_escape }@
{% if kw['version_added'] is still_relevant(collection=kw['version_added_collection']) %}

:ansible-option-versionadded:`added in @{kw['version_added']}@ of @{ kw['version_added_collection'] | rst_ify }@`
{% endif %}
@{ deprecates_rst(kw['deprecated'], collection, 8) }@
{% endfor %}
{% for mycli in value['cli'] %}
- CLI argument: @{ mycli['option'] | rst_escape }@
{% if mycli['version_added'] is still_relevant(collection=mycli['version_added_collection']) %}
Expand Down Expand Up @@ -279,6 +287,15 @@
@{ deprecates_html(myvar['deprecated'], collection) }@
</li>
{% endfor %}
{% for kw in value['keyword'] %}
<li>
<p>Keyword: @{ kw['name'] | escape }@</p>
{% if kw['version_added'] is still_relevant(collection=kw['version_added_collection']) %}
<p><span class="ansible-option-versionadded">added in @{kw['version_added']}@ of @{ kw['version_added_collection'] | html_ify }@</span></p>
{% endif %}
@{ deprecates_html(kw['deprecated'], collection) }@
</li>
{% endfor %}
{% for mycli in value['cli'] %}
<li>
<p>CLI argument: @{ mycli['option'] | escape }@</p>
Expand Down
8 changes: 8 additions & 0 deletions src/antsibull/schemas/docs/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,13 @@ class OptionVarsSchema(BaseModel):
version_added_collection: str = COLLECTION_NAME_F


class OptionKeywordSchema(BaseModel):
name: str
deprecated: DeprecationSchema = p.Field({})
version_added: str = 'historical'
version_added_collection: str = COLLECTION_NAME_F


class ReturnSchema(BaseModel):
"""Schema of plugin return data docs."""

Expand Down Expand Up @@ -145,6 +152,7 @@ class PluginOptionsSchema(OptionsSchema):
ini: t.List[OptionIniSchema] = []
suboptions: t.Dict[str, 'PluginOptionsSchema'] = {}
vars: t.List[OptionVarsSchema] = []
keyword: t.List[OptionKeywordSchema] = []
deprecated: DeprecationSchema = p.Field({})


Expand Down
1 change: 1 addition & 0 deletions tests/functional/schema/good_data/one_become_results.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
"version_added_collection": ""
}
],
"keyword": [],
"required": false,
"suboptions": {},
"type": "str",
Expand Down
3 changes: 3 additions & 0 deletions tests/functional/schema/good_data/one_cache_results.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
"version_added_collection": ""
}
],
"keyword": [],
"required": false,
"suboptions": {},
"type": "str",
Expand Down Expand Up @@ -78,6 +79,7 @@
"version_added_collection": ""
}
],
"keyword": [],
"required": false,
"suboptions": {},
"type": "int",
Expand Down Expand Up @@ -112,6 +114,7 @@
"version_added_collection": ""
}
],
"keyword": [],
"required": true,
"suboptions": {},
"type": "str",
Expand Down
1 change: 1 addition & 0 deletions tests/functional/schema/good_data/one_cliconf_results.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
}
],
"ini": [],
"keyword": [],
"required": false,
"suboptions": {},
"type": "bool",
Expand Down
13 changes: 13 additions & 0 deletions tests/functional/schema/good_data/one_connection_results.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
"version_added_collection": ""
}
],
"keyword": [],
"required": false,
"suboptions": {},
"type": "bool",
Expand Down Expand Up @@ -86,6 +87,7 @@
"version_added_collection": ""
}
],
"keyword": [],
"required": false,
"suboptions": {},
"type": "str",
Expand All @@ -112,6 +114,7 @@
"elements": "str",
"env": [],
"ini": [],
"keyword": [],
"required": false,
"suboptions": {},
"type": "str",
Expand All @@ -138,6 +141,7 @@
"elements": "str",
"env": [],
"ini": [],
"keyword": [],
"required": false,
"suboptions": {},
"type": "str",
Expand All @@ -164,6 +168,7 @@
"elements": "str",
"env": [],
"ini": [],
"keyword": [],
"required": false,
"suboptions": {},
"type": "str",
Expand Down Expand Up @@ -217,6 +222,7 @@
"version_added_collection": ""
}
],
"keyword": [],
"required": false,
"suboptions": {},
"type": "int",
Expand Down Expand Up @@ -258,6 +264,7 @@
"version_added_collection": ""
}
],
"keyword": [],
"required": false,
"suboptions": {},
"type": "int",
Expand Down Expand Up @@ -300,6 +307,7 @@
"version_added_collection": ""
}
],
"keyword": [],
"required": false,
"suboptions": {},
"type": "bool",
Expand Down Expand Up @@ -342,6 +350,7 @@
"version_added_collection": ""
}
],
"keyword": [],
"required": false,
"suboptions": {},
"type": "int",
Expand Down Expand Up @@ -384,6 +393,7 @@
"version_added_collection": ""
}
],
"keyword": [],
"required": false,
"suboptions": {},
"type": "str",
Expand All @@ -410,6 +420,7 @@
"elements": "str",
"env": [],
"ini": [],
"keyword": [],
"required": false,
"suboptions": {},
"type": "bool",
Expand All @@ -436,6 +447,7 @@
"elements": "str",
"env": [],
"ini": [],
"keyword": [],
"required": false,
"suboptions": {},
"type": "bool",
Expand All @@ -462,6 +474,7 @@
"elements": "str",
"env": [],
"ini": [],
"keyword": [],
"required": false,
"suboptions": {},
"type": "bool",
Expand Down
1 change: 1 addition & 0 deletions tests/functional/schema/good_data/one_httpapi_results.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"elements": "str",
"env": [],
"ini": [],
"keyword": [],
"required": false,
"suboptions": {},
"type": "str",
Expand Down
21 changes: 21 additions & 0 deletions tests/functional/schema/good_data/one_inventory_results.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
}
],
"ini": [],
"keyword": [],
"required": false,
"suboptions": {},
"type": "str",
Expand Down Expand Up @@ -87,6 +88,7 @@
}
],
"ini": [],
"keyword": [],
"required": false,
"suboptions": {},
"type": "str",
Expand Down Expand Up @@ -127,6 +129,7 @@
}
],
"ini": [],
"keyword": [],
"required": false,
"suboptions": {},
"type": "str",
Expand Down Expand Up @@ -165,6 +168,7 @@
}
],
"ini": [],
"keyword": [],
"required": false,
"suboptions": {},
"type": "str",
Expand Down Expand Up @@ -199,6 +203,7 @@
"version_added_collection": ""
}
],
"keyword": [],
"required": false,
"suboptions": {},
"type": "bool",
Expand Down Expand Up @@ -246,6 +251,7 @@
"version_added_collection": ""
}
],
"keyword": [],
"required": false,
"suboptions": {},
"type": "str",
Expand Down Expand Up @@ -293,6 +299,7 @@
"version_added_collection": ""
}
],
"keyword": [],
"required": false,
"suboptions": {},
"type": "str",
Expand Down Expand Up @@ -340,6 +347,7 @@
"version_added_collection": ""
}
],
"keyword": [],
"required": false,
"suboptions": {},
"type": "str",
Expand Down Expand Up @@ -387,6 +395,7 @@
"version_added_collection": ""
}
],
"keyword": [],
"required": false,
"suboptions": {},
"type": "int",
Expand All @@ -406,6 +415,7 @@
"elements": "str",
"env": [],
"ini": [],
"keyword": [],
"required": false,
"suboptions": {},
"type": "dict",
Expand All @@ -426,6 +436,7 @@
"elements": "str",
"env": [],
"ini": [],
"keyword": [],
"required": false,
"suboptions": {},
"type": "dict",
Expand All @@ -445,6 +456,7 @@
"elements": "str",
"env": [],
"ini": [],
"keyword": [],
"required": false,
"suboptions": {},
"type": "dict",
Expand All @@ -466,6 +478,7 @@
"elements": "str",
"env": [],
"ini": [],
"keyword": [],
"required": false,
"suboptions": {},
"type": "list",
Expand All @@ -485,6 +498,7 @@
"elements": "str",
"env": [],
"ini": [],
"keyword": [],
"required": false,
"suboptions": {},
"type": "str",
Expand All @@ -505,6 +519,7 @@
"elements": "str",
"env": [],
"ini": [],
"keyword": [],
"required": false,
"suboptions": {},
"type": "bool",
Expand All @@ -524,6 +539,7 @@
"elements": "str",
"env": [],
"ini": [],
"keyword": [],
"required": false,
"suboptions": {},
"type": "list",
Expand All @@ -545,6 +561,7 @@
"elements": "str",
"env": [],
"ini": [],
"keyword": [],
"required": true,
"suboptions": {},
"type": "str",
Expand All @@ -565,6 +582,7 @@
"elements": "str",
"env": [],
"ini": [],
"keyword": [],
"required": false,
"suboptions": {},
"type": "list",
Expand All @@ -585,6 +603,7 @@
"elements": "str",
"env": [],
"ini": [],
"keyword": [],
"required": false,
"suboptions": {},
"type": "bool",
Expand All @@ -605,6 +624,7 @@
"elements": "str",
"env": [],
"ini": [],
"keyword": [],
"required": false,
"suboptions": {},
"type": "bool",
Expand All @@ -626,6 +646,7 @@
"elements": "str",
"env": [],
"ini": [],
"keyword": [],
"required": false,
"suboptions": {},
"type": "bool",
Expand Down
Loading

0 comments on commit 8789427

Please sign in to comment.