1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

validate-modules --arg-spec (#21331)

* validate-modules --arg-spec

* Update developing_modules_documenting.rst

* Never mock out ansible or ansible.module_utils

* No more false positives
This commit is contained in:
John R Barker 2017-02-15 08:09:08 +00:00 committed by GitHub
parent 47141b8426
commit 53ac312382
2 changed files with 16 additions and 3 deletions

View file

@ -41,6 +41,7 @@ The following fields can be used and are all required unless specified otherwise
* As the short description is displayed by ``ansible-doc -l`` without the category grouping it needs enough detail to explain its purpose without the context of the directory structure in which it lives.
* Unlike ``description:`` this field should not have a trailing full stop.
* ``description:``
* A detailed description (generally two or more sentences).
* Must be written in full sentences, i.e. with capital letters and fullstops.
* Shouldn't mention the name module.
@ -173,6 +174,14 @@ Put your completed module file into the ``lib/ansible/modules/$CATEGORY/`` direc
run the command: ``make webdocs``. The new 'modules.html' file will be
built in the ``docs/docsite/_build/html/$MODULENAME_module.html`` directory.
To test your documentation against your ``argument_spec`` you can use ``validate-modules``. Note that this option isn't currently enabled in Shippable due to the time it takes to run.
.. code-block:: shell-session
# If you don't already, ensure you are using your local checkout
$ source hacking/env-setup
$ ./test/sanity/validate-modules/validate-modules --arg-spec --warnings lib/ansible/modules/your/modules/
.. tip::
If you're having a problem with the syntax of your YAML you can

View file

@ -71,6 +71,10 @@ def add_mocks(filename):
parts = module.split('.')
for i in range(len(parts)):
dotted = '.'.join(parts[:i+1])
# Never mock out ansible or ansible.module_utils
# we may get here if a specific module_utils file needed mocked
if dotted in ('ansible', 'ansible.module_utils',):
continue
sys.modules[dotted] = sys_mock
sys_mocks.append(dotted)