mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-05-13 20:49:11 -07:00
Docs: edits & expands module_utils & search path info in dev guide (#55931)
* Update docs/docsite/rst/dev_guide/developing_module_utilities.rst
This commit is contained in:
parent
5439eb8bd8
commit
8542459b95
5 changed files with 152 additions and 88 deletions
|
@ -67,7 +67,7 @@ Python tips
|
|||
Importing and using shared code
|
||||
===============================
|
||||
|
||||
* Use shared code whenever possible - don't reinvent the wheel. Ansible offers the ``AnsibleModule`` common Python code, plus :ref:`utilities <appendix_module_utilities>` for many common use cases and patterns.
|
||||
* Use shared code whenever possible - don't reinvent the wheel. Ansible offers the ``AnsibleModule`` common Python code, plus :ref:`utilities <developing_module_utilities>` for many common use cases and patterns. You can also create documentation fragments for docs that apply to multiple modules.
|
||||
* Import ``ansible.module_utils`` code in the same place as you import other libraries.
|
||||
* Do NOT use wildcards (*) for importing other python modules; instead, list the function(s) you are importing (for example, ``from some.other_python_module.basic import otherFunction``).
|
||||
* Import custom packages in ``try``/``except``, capture any import errors, and handle them with ``fail_json()`` in ``main()``. For example:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue