a84b3a4e72
This change fixes bugs in the manpage generator that existed since it was first added. It exposes CLI `ARGUMENTS` value to manpage templates. Before this change, the code contained a typo, causing the `for`-loop iterate over individual characters of the `'ARGUMENTS'` string rather than iterating over a tuple. A missing comma was at fault. The updated code gets rid of the `for`-loop and conditionals since it seems to have been a premature complexity increase and no other things than `'ARGUMENTS'` were ever added into the broken iterable. The functional change is that `arguments` is now always present in the Jinja2 context, unlike being missing sometimes because of the previous design (not that it was ever present, because of the bug! sigh...) The Jinja2 templates perform an `{% if arguments %}` check, letting the template engine silently ignore the missing variable. The clause was always falsy, meaning that the arguments section was not included in the manpages for at least the last 6 years. With this fix, it will be. This patch also deduplicates calling `opt_doc_list` @ generate_man. It was called late in the execution, more times than necessary. This patch makes sure it happens once by putting it at the top of the scope. It fixes rendering library and inventory in manpages. The corresponding Jinja2 templates have blocks wrapped with conditionals like `{% if inventory %}` and `{% if library %}` but said variables were never injected into the context, nor were they even deduced on the Python side of the generator. This means that the conditional clauses were always falsy, never showing the portions of the manpages. The Python script has hints for how the `inventory` variable was to be calculated, which is confirmed through the Git paleontology efforts. The block of code that references to the `inventory` bit was incorrectly checking a variable with a list of nested objects for the presence of a string which was never going to work. This patch fixes this check by verifying the CLI flag against the correct variable containing a list of options and exposes it to the Jinja2 templates. It also exposes the `library` variable in a similar way. The block displaying other binaries in Sphinx CLI docs has been synchronized with the manpage template. Previously, the current binary was displayed also. This patch gets rid of the unwanted trailing comma there too. Finally, the CLI executables list in the manpage template now reuses the same variable as the RST template that doesn't need any post-processing in Jinja2. Before, it was already used in the RST template so this patch aligns both templates to use the same logic as they got out-of-sync over time. PR #80450. |
2 years ago | |
---|---|---|
.. | ||
azp | 2 years ago | |
backport | 5 years ago | |
build_library | 2 years ago | |
tests | 2 years ago | |
ticket_stubs | 3 years ago | |
README.md | 2 years ago | |
ansible-profile | 5 years ago | |
build-ansible.py | 2 years ago | |
create-bulk-issues.py | 2 years ago | |
deprecated_issue_template.md | 6 years ago | |
env-setup | 3 years ago | |
env-setup.fish | 3 years ago | |
fix_test_syntax.py | 4 years ago | |
get_library.py | 4 years ago | |
report.py | 4 years ago | |
return_skeleton_generator.py | 2 years ago | |
test-module | 5 years ago | |
test-module.py | 2 years ago | |
update-sanity-requirements.py | 2 years ago |
README.md
'Hacking' directory tools
env-setup
The 'env-setup' script modifies your environment to allow you to run ansible from a git checkout using python >= 3.8.
First, set up your environment to run from the checkout:
$ source ./hacking/env-setup
You will need some basic prerequisites installed. If you do not already have them and do not wish to install them from your operating system package manager, you can install them from pip
$ easy_install pip # if pip is not already available
$ pip install -r requirements.txt
From there, follow ansible instructions on docs.ansible.com as normal.
test-module.py
'test-module.py' is a simple program that allows module developers (or testers) to run a module outside of the ansible program, locally, on the current machine.
Example:
$ ./hacking/test-module.py -m lib/ansible/modules/command.py -a "echo hi"
This is a good way to insert a breakpoint into a module, for instance.
For more complex arguments such as the following yaml:
parent:
child:
- item: first
val: foo
- item: second
val: boo
Use:
$ ./hacking/test-module.py -m module \
-a '{"parent": {"child": [{"item": "first", "val": "foo"}, {"item": "second", "val": "bar"}]}}'
return_skeleton_generator.py
return_skeleton_generator.py helps in generating the RETURNS section of a module. It takes JSON output of a module provided either as a file argument or via stdin.
fix_test_syntax.py
A script to assist in the conversion for tests using filter syntax to proper jinja test syntax. This script has been used to convert all of the Ansible integration tests to the correct format for the 2.5 release. There are a few limitations documented, and all changes made by this script should be evaluated for correctness before executing the modified playbooks.