I’m having trouble making a collection pass ansible-test.
I would like to use Adjacent documentation.
At the moment my troubles are located with the EXAMPLES block.
This examples creates a fail error that seems to be caused by incorrect yaml but I fail to understand why. Could you add in the documentation for the adjacent documentation an example that contains several examples?
@bcoca I’m not sure about how to test it using ansible-doc, is there a way to launch ansible-doc in linting mode to find potential errors in adjacent yaml documentation?
$ ./venv/bin/ansible-doc -F -vvv
ERROR! Unexpected Exception, this is probably a bug: sequence item 0: expected str instance, NoneType found
the full traceback was:
Traceback (most recent call last):
File "/Users/rleone/workspace/ansible_collections/scaleway/scaleway/venv/lib/python3.13/site-packages/ansible/cli/__init__.py", line 646, in cli_executor
exit_code = cli.run()
File "/Users/rleone/workspace/ansible_collections/scaleway/scaleway/venv/lib/python3.13/site-packages/ansible/cli/doc.py", line 935, in run
docs = self._list_plugins(plugin_type, content)
File "/Users/rleone/workspace/ansible_collections/scaleway/scaleway/venv/lib/python3.13/site-packages/ansible/cli/doc.py", line 796, in _list_plugins
self.plugins.update(list_plugins(plugin_type, coll_filter))
~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/rleone/workspace/ansible_collections/scaleway/scaleway/venv/lib/python3.13/site-packages/ansible/plugins/list.py", line 198, in list_plugins
plugins.update(list_collection_plugins(ptype, plugin_collections))
~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/rleone/workspace/ansible_collections/scaleway/scaleway/venv/lib/python3.13/site-packages/ansible/plugins/list.py", line 150, in list_collection_plugins
plugins.update(_list_plugins_from_paths(ptype, dirs, collection))
~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/rleone/workspace/ansible_collections/scaleway/scaleway/venv/lib/python3.13/site-packages/ansible/plugins/list.py", line 102, in _list_plugins_from_paths
plugin_name = get_composite_name(collection, plugin, os.path.dirname(to_native(full_path)), depth)
File "/Users/rleone/workspace/ansible_collections/scaleway/scaleway/venv/lib/python3.13/site-packages/ansible/plugins/list.py", line 42, in get_composite_name
return '.'.join(composite)
~~~~~~~~^^^^^^^^^^^
TypeError: sequence item 0: expected str instance, NoneType found
As of now, and I think it’s just an oversight because there are some bugs that prevent it from working, EXAMPLES can only be a string.
So instead of EXAMPLES: you would need to use EXAMPLES: |.
There is no issue logged yet, but I’ve pinged the appropriate people.
The 2 issues I see are:
ansible-doc loads the sidecar file with the AnsibleLoader which creates custom types, but then attempts to dump the EXAMPLES with yaml.dumps without the Loader
validate-modules assumes that EXAMPLES is always a string, and attempts to execute yaml.loads on it.