Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

collection_prep_add_docs: Search for plugins/doc_fragments in the working directory #67

Open
mariolenz opened this issue Oct 4, 2021 · 1 comment

Comments

@mariolenz
Copy link
Contributor

It looks like collection_prep_add_docs -p . looks for plugins/doc_fragments in the collection search path, not in the current directory (see community.vmware#1062 ff).

I think that not searching for plugins/doc_fragments in the directory defined with -p breaks the principle of least astonishment.

@phospi
Copy link

phospi commented Feb 10, 2022

Ran into this issue the other day. I do expect collection prep to look for fragments in the same base path as modules from the collection, too.

The easy workaround for this is run a collection installation before running collection_prep:

ansible-galaxy collection build --force
export COLL=$(ls ansible-collection*) && pipenv run ansible-galaxy collection install $COLL --force

I want to add the actual error message. The error message indicates that the issue is not easy to fix as the doc generation is integrated from the ansible python module site-packages/ansible/utils/plugin_docs.py. I did not check if plugin_docs is able to take a custom path as input.

Traceback (most recent call last):
  File "/root/.local/share/virtualenvs/Ansible.Collection-4Fc_I88C/bin/collection_prep_add_docs", line 8, in <module>
    sys.exit(main())
  File "/root/.local/share/virtualenvs/Ansible.Collection-4Fc_I88C/lib/python3.8/site-packages/collection_prep/cmd/add_docs.py", line 549, in main
    content = process(collection=collection, path=path)
  File "/root/.local/share/virtualenvs/Ansible.Collection-4Fc_I88C/lib/python3.8/site-packages/collection_prep/cmd/add_docs.py", line 333, in process
    ) = plugin_docs.get_docstring(fullpath, fragment_loader)
  File "/root/.local/share/virtualenvs/Ansible.Collection-4Fc_I88C/lib/python3.8/site-packages/ansible/utils/plugin_docs.py", line 217, in get_docstring
    add_fragments(data['doc'], filename, fragment_loader=fragment_loader, is_module=is_module)
  File "/root/.local/share/virtualenvs/Ansible.Collection-4Fc_I88C/lib/python3.8/site-packages/ansible/utils/plugin_docs.py", line 201, in add_fragments
    raise AnsibleError('unknown doc_fragment(s) in file {0}: {1}'.format(filename, to_native(', '.join(unknown_fragments))))
ansible.errors.AnsibleError: unknown doc_fragment(s) in file /opt/git_azure/Ansible.Collection/plugins/modules/my_module_item.py: ansible.collection.module_fragment

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants