mirror of https://github.com/ansible/ansible.git
validate-modules and return fragments: fix bug in markup check, fix bug in missing doc fragment check, add tests (#85638)
* Prevent crashing on invalid structure. * Also process return doc fragments. * Fix handling of missing doc fragments.pull/85811/head
parent
4c27ccf8f4
commit
4209d714db
@ -0,0 +1,2 @@
|
|||||||
|
bugfixes:
|
||||||
|
- "validate-modules sanity test - fix handling of missing doc fragments (https://github.com/ansible/ansible/pull/85638)."
|
||||||
@ -0,0 +1,19 @@
|
|||||||
|
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||||
|
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
|
|
||||||
|
class ModuleDocFragment:
|
||||||
|
DOCUMENTATION = r"""
|
||||||
|
options: {}
|
||||||
|
"""
|
||||||
|
|
||||||
|
RETURN = r"""
|
||||||
|
bar:
|
||||||
|
description:
|
||||||
|
- Some foo bar.
|
||||||
|
- P(a.b.asfd#dfsa) this is an error.
|
||||||
|
returned: success
|
||||||
|
type: int
|
||||||
|
sample: 42
|
||||||
|
"""
|
||||||
@ -0,0 +1,28 @@
|
|||||||
|
#!/usr/bin/python
|
||||||
|
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||||
|
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
|
DOCUMENTATION = """
|
||||||
|
module: doc_fragments_not_exist
|
||||||
|
short_description: Non-existing doc fragment
|
||||||
|
description: A module with a non-existing doc fragment
|
||||||
|
author:
|
||||||
|
- Ansible Core Team
|
||||||
|
extends_documentation_fragment:
|
||||||
|
- does.not.exist
|
||||||
|
"""
|
||||||
|
|
||||||
|
EXAMPLES = """#"""
|
||||||
|
|
||||||
|
RETURN = """"""
|
||||||
|
|
||||||
|
from ansible.module_utils.basic import AnsibleModule
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
AnsibleModule().exit_json()
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
main()
|
||||||
@ -0,0 +1,29 @@
|
|||||||
|
#!/usr/bin/python
|
||||||
|
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||||
|
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
|
DOCUMENTATION = """
|
||||||
|
module: return_fragments
|
||||||
|
short_description: Uses return fragments
|
||||||
|
description: A module with a return doc fragment.
|
||||||
|
author:
|
||||||
|
- Ansible Core Team
|
||||||
|
"""
|
||||||
|
|
||||||
|
EXAMPLES = """#"""
|
||||||
|
|
||||||
|
RETURN = """
|
||||||
|
extends_documentation_fragment:
|
||||||
|
- ns.col.return_doc_fragment
|
||||||
|
"""
|
||||||
|
|
||||||
|
from ansible.module_utils.basic import AnsibleModule
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
AnsibleModule().exit_json(bar=42)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
main()
|
||||||
@ -0,0 +1,29 @@
|
|||||||
|
#!/usr/bin/python
|
||||||
|
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||||
|
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
|
DOCUMENTATION = """
|
||||||
|
module: return_fragments_not_exist
|
||||||
|
short_description: Non-existing return doc fragment
|
||||||
|
description: A module with a non-existing return doc fragment.
|
||||||
|
author:
|
||||||
|
- Ansible Core Team
|
||||||
|
"""
|
||||||
|
|
||||||
|
EXAMPLES = """#"""
|
||||||
|
|
||||||
|
RETURN = """
|
||||||
|
extends_documentation_fragment:
|
||||||
|
- does.not.exist
|
||||||
|
"""
|
||||||
|
|
||||||
|
from ansible.module_utils.basic import AnsibleModule
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
AnsibleModule().exit_json(bar=42)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
main()
|
||||||
Loading…
Reference in New Issue