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

[Bug] aar_doc does not support arguments_spec in meta/main.yaml #66

Closed
montaropdf opened this issue Sep 9, 2024 · 10 comments
Closed

[Bug] aar_doc does not support arguments_spec in meta/main.yaml #66

montaropdf opened this issue Sep 9, 2024 · 10 comments
Labels
bug Something isn't working

Comments

@montaropdf
Copy link

Description

As I do not plan to support ansible < 2.11, I write the argument_specs section into the meta/main.yaml file of my roles. Unfortunately aar_doc does not seem to support that, as I get the following error message:
Could not find meta/argument_specs.yml

Reproduction steps

  1. Write a valid argument_specs section in the meta/main.yaml file of a role
  2. Do not create a meta/argument_specs.yml
  3. Run aar_doc ROLE_PATH markdown to create a markdown documentation

Current Behavior

The tool will generate the following message and produce no markdown output.

Could not find meta/argument_specs.yml

Expected Behavior

If the file ROLE_PATH/meta/argument_specs.yml does not exists, the tool should look into ROLE_PATH/meta/main.yaml for the argument_specs section.

Additional information

aar_doc version: 1.0.4

@montaropdf montaropdf added the bug Something isn't working label Sep 9, 2024
@rndmh3ro
Copy link
Collaborator

see #68

@montaropdf
Copy link
Author

As I think this will block any testing of the patch, I want to mention that the markdown.j2 template is hardcoded in the markdown command. Moreover, that template expect to find a subsection main in the argument_specs section, which is not mandatory as far as I know.

At least in my case, it will fails because I have no main subsection.

@rndmh3ro
Copy link
Collaborator

As I think this will block any testing of the patch, I want to mention that the markdown.j2 template is hardcoded in the markdown command.

That's not really relevant, as the final output will be parsed using the output_template-option.

Moreover, that template expect to find a subsection main in the argument_specs section, which is not mandatory as far as I know.

That is indeed a problem. I'll try to think about it.

@rndmh3ro
Copy link
Collaborator

I removed the main-entrypoint from the markdown file so this should be working for you now.

@montaropdf
Copy link
Author

I removed the main-entrypoint from the markdown file so this should be working for you now.

Great, I will test it asap.

Regarding the output_template option, in my previous tests, it doesn't seem to be used, at least with the markdown command. However, I do not rule out the fact I didn't use the option correctly.

@montaropdf
Copy link
Author

A first test shows that section argument_specs can be found in meta/main.yaml and meta/argument_specs can be missing.

I noticed, however, that the tool requires the options node of an entry-point to be present. However, some of my entry-points does not require any input variables.

@rndmh3ro
Copy link
Collaborator

I noticed, however, that the tool requires the options node of an entry-point to be present. However, some of my entry-points does not require any input variables.

Should be fixed, too! :)

Regarding the output_template option, in my previous tests, it doesn't seem to be used, at least with the markdown command. However, I do not rule out the fact I didn't use the option correctly.

Just tested it again, works for me.

@montaropdf
Copy link
Author

With your fix, the documentation is generated when the options node is missing too.

Regarding the use of templates.

I have created a configuration file with the following content:

---
output_template: |
  <!-- BEGIN_ANSIBLE_DOCS -->

  This is my role: {{ role }}

  <!-- Including files is also possible in relation to the role's directory with Jinja2's include directive -->
  {% include "defaults/main.yml" %}

  <!-- 'argument_specs' contains all the things in meta/argument_specs.yml -->
  {% for entrypoint, specs in argument_specs | items %}
  Task file name: {{ entrypoint }}.yml has {{ specs | length }} input variables!
  {% endfor %}
  <!-- END_ANSIBLE_DOCS -->

And use it with the following command:
python -m aar_doc.cli --output-file someoutput.md --config-file=/path/to/configuration/file/config.yaml /path/to/role markdown

Unfortunately, the generated file has the same content as without the configuration file.

@rndmh3ro
Copy link
Collaborator

I opened a new issue for your problem: #69

@rndmh3ro
Copy link
Collaborator

Fixed by #68

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants