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

ansible-doc fails to parse plugin docs #77764

Closed
1 task done
gravesm opened this issue May 9, 2022 · 1 comment · Fixed by #77719
Closed
1 task done

ansible-doc fails to parse plugin docs #77764

gravesm opened this issue May 9, 2022 · 1 comment · Fixed by #77719
Labels
affects_2.14 bug This issue/PR relates to a bug. has_pr This issue has an associated PR. P3 Priority 3 - Approved, No Time Limitation support:core This issue/PR relates to code supported by the Ansible Engineering Team.

Comments

@gravesm
Copy link
Member

gravesm commented May 9, 2022

Summary

When I try to run ansible-doc on the milestone branch (same result on devel) it fails when the token DOCUMENTATION is used anywhere else in the plugin. I believe #74963 introduced this bug. We initially saw this on the milestone branch sanity test failures for the kubernetes.core collection. https://github.com/ansible-collections/kubernetes.core/blob/95e2add65b4ade93a7ad770a8aa0386f90a9c831/plugins/connection/kubectl.py#L212 is what trips it up. As best I can tell, the new code looks for a DOCUMENTATION token anywhere and then uses the next string token as the doc string. In this case, it's "{0}_command" a few lines down.

Issue Type

Bug Report

Component Name

ansible-doc

Ansible Version

$ ansible --version
ansible [core 2.14.0.dev0] (milestone 2cc74b04c4) last updated 2022/05/05 08:26:56 (GMT -400)
  config file = None
  configured module search path = ['/home/mgraves/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/mgraves/git/ansible/lib/ansible
  ansible collection location = /home/mgraves/git:/home/mgraves/.ansible/collections
  executable location = /home/mgraves/git/ansible/bin/ansible
  python version = 3.8.8 (default, Mar  5 2021, 11:47:01) [GCC 10.2.1 20210110] (/home/mgraves/git/ansible/venv/bin/python)
  jinja version = 3.0.3
  libyaml = True

Configuration

$ ansible-config dump --only-changed
COLLECTIONS_PATHS(env: ANSIBLE_COLLECTIONS_PATH) = ['/home/mgraves/git', '/home/mgraves/.ansible/collections']
CONFIG_FILE() = None

OS / Environment

Debian 11

Steps to Reproduce

Using the latest release of kubernetes.core (2.3.1):

$ ansible-doc -t connection kubernetes.core.kubectl
ERROR! connection kubernetes.core.kubectl missing documentation (or could not parse documentation): did not find expected <document start>
  in "<unicode string>", line 1, column 4

You can also see similar failures for a really simple plugin like:

DOCUMENTATION = r'''
    name: foo
    description:
      - foo module
'''

class Foo:
    DOCUMENTATION = None
    def __init__(self):
        foo = "bar"

Expected Results

I expected the plugin documentation to be generated.

Actual Results

ERROR! connection kubernetes.core.kubectl missing documentation (or could not parse documentation): did not find expected <document start>
  in "<unicode string>", line 1, column 4

Code of Conduct

  • I agree to follow the Ansible Code of Conduct
@ansibot
Copy link
Contributor

ansibot commented May 9, 2022

Files identified in the description:

If these files are incorrect, please update the component name section of the description or use the !component bot command.

click here for bot help

@ansibot ansibot added affects_2.14 bug This issue/PR relates to a bug. needs_triage Needs a first human triage before being processed. support:core This issue/PR relates to code supported by the Ansible Engineering Team. labels May 9, 2022
goneri added a commit to goneri/ansible-zuul-jobs that referenced this issue May 10, 2022
There was a bug introduced in the latest milestone that broke k8s.core.
We hate to just keep making ci jobs non-voting, but we also don't want
unreleased ansible code to block PRs

See: ansible/ansible#77764
@ansibot ansibot added the has_pr This issue has an associated PR. label May 10, 2022
softwarefactory-project-zuul bot pushed a commit to ansible/ansible-zuul-jobs that referenced this issue May 10, 2022
ansible-test-sanity-docker-milestone non-voting

There was a bug introduced in the latest milestone that broke k8s.core.
We hate to just keep making ci jobs non-voting, but we also don't want
unreleased ansible code to block PRs
See: ansible/ansible#77764
@s-hertel s-hertel added P3 Priority 3 - Approved, No Time Limitation and removed needs_triage Needs a first human triage before being processed. labels May 10, 2022
bcoca added a commit to bcoca/ansible that referenced this issue May 10, 2022
  avoid false positives/copies of the expected labels
  fixes ansible#77764
bcoca added a commit to bcoca/ansible that referenced this issue May 12, 2022
  allow location and building api to be more accessible
  fix issues with displaying ansible.legacy and ansible.builtin
  ensure we don't x2 process tokens (some modules reference them also) fixes ansible#77764
  move to constants vs hardcoded
  more informative errors and comments
  updated tests
bcoca added a commit to bcoca/ansible that referenced this issue May 13, 2022
  allow location and building api to be more accessible
  fix issues with displaying ansible.legacy and ansible.builtin
  ensure we don't x2 process tokens (some modules reference them also) fixes ansible#77764
  move to constants vs hardcoded
  more informative errors and comments
  updated tests
bcoca added a commit to bcoca/ansible that referenced this issue May 25, 2022
  allow location and building api to be more accessible
  fix issues with displaying ansible.legacy and ansible.builtin
  ensure we don't x2 process tokens (some modules reference them also) fixes ansible#77764
  move to constants vs hardcoded
  more informative errors and comments
  updated tests
bcoca added a commit to bcoca/ansible that referenced this issue May 31, 2022
  allow location and building api to be more accessible
  fix issues with displaying ansible.legacy and ansible.builtin
  ensure we don't x2 process tokens (some modules reference them also) fixes ansible#77764
  move to constants vs hardcoded
  more informative errors and comments
  updated tests
bcoca added a commit to bcoca/ansible that referenced this issue Jun 7, 2022
  allow location and building api to be more accessible
  fix issues with displaying ansible.legacy and ansible.builtin
  ensure we don't x2 process tokens (some modules reference them also) fixes ansible#77764
  move to constants vs hardcoded
  more informative errors and comments
  updated tests
bcoca added a commit to bcoca/ansible that referenced this issue Jun 22, 2022
  allow location and building api to be more accessible
  fix issues with displaying ansible.legacy and ansible.builtin
  ensure we don't x2 process tokens (some modules reference them also) fixes ansible#77764
  move to constants vs hardcoded
  more informative errors and comments
  updated tests
bcoca added a commit to bcoca/ansible that referenced this issue Jun 22, 2022
  allow location and building api to be more accessible
  fix issues with displaying ansible.legacy and ansible.builtin
  ensure we don't x2 process tokens (some modules reference them also) fixes ansible#77764
  move to constants vs hardcoded
  more informative errors and comments
  updated tests
bcoca added a commit to bcoca/ansible that referenced this issue Jul 19, 2022
  allow location and building api to be more accessible
  fix issues with displaying ansible.legacy and ansible.builtin
  ensure we don't x2 process tokens (some modules reference them also) fixes ansible#77764
  move to constants vs hardcoded
  more informative errors and comments
  updated tests
bcoca added a commit to bcoca/ansible that referenced this issue Jul 22, 2022
  allow location and building api to be more accessible
  fix issues with displaying ansible.legacy and ansible.builtin
  ensure we don't x2 process tokens (some modules reference them also) fixes ansible#77764
  move to constants vs hardcoded
  more informative errors and comments
  now have actual filter/test plugins, which expose the filter/test functions
  moved filter/test loading/finding logic into jinja2pluginloader, removed dupe implementations
  updated tests
bcoca added a commit to bcoca/ansible that referenced this issue Aug 30, 2022
  allow location and building api to be more accessible
  fix issues with displaying ansible.legacy and ansible.builtin
  ensure we don't x2 process tokens (some modules reference them also) fixes ansible#77764
  move to constants vs hardcoded
  more informative errors and comments
  now have actual filter/test plugins, which expose the filter/test functions
  moved filter/test loading/finding logic into jinja2pluginloader, removed dupe implementations
  updated tests
bcoca added a commit that referenced this issue Sep 1, 2022
* refactor and remove redundant code in documentation

  allow location and building api to be more accessible
  fix issues with displaying ansible.legacy and ansible.builtin
  ensure we don't x2 process tokens (some modules reference them also) fixes #77764
  move to constants vs hardcoded
  more informative errors and comments
  now have actual filter/test plugins, which expose the filter/test functions
  moved filter/test loading/finding logic into jinja2pluginloader, removed dupe implementations
  added tests for case in which we unique by basename when listing

Update lib/ansible/utils/plugin_docs.py
Co-authored-by: Sloane Hertel <19572925+s-hertel@users.noreply.github.com>
@ansible ansible locked and limited conversation to collaborators Sep 8, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
affects_2.14 bug This issue/PR relates to a bug. has_pr This issue has an associated PR. P3 Priority 3 - Approved, No Time Limitation support:core This issue/PR relates to code supported by the Ansible Engineering Team.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants