1
0
Fork 0

updated the docify function

Dieser Commit ist enthalten in:
Sebastian Tobie 2023-04-23 10:21:14 +02:00
Ursprung c72de48b62
Commit a02d261fe3
1 geänderte Dateien mit 3 neuen und 5 gelöschten Zeilen

Datei anzeigen

@ -5,9 +5,9 @@ from typing import Any, Callable, ClassVar, Dict, NoReturn, Optional, Type, Type
import ansible.module_utils.basic as basic import ansible.module_utils.basic as basic
try: try:
from ansible_collections.sebastian.systemd.plugins.module_utils.generic import Types, _sdict from ansible_collections.sebastian.systemd.plugins.module_utils.generic import AnsibleParameter, Types
except ImportError: except ImportError:
from plugins.module_utils.generic import Types, _sdict from plugins.module_utils.generic import AnsibleParameter, Types
__all__ = ( __all__ = (
@ -21,12 +21,10 @@ __all__ = (
T = TypeVar("T") T = TypeVar("T")
def docify(input: Union[dict, _sdict]) -> dict: def docify(input: Union[dict, AnsibleParameter]) -> dict:
options = dict() options = dict()
for name, help in input.items(): for name, help in input.items():
options[name] = dict(type=help["type"]) options[name] = dict(type=help["type"])
if hasattr(help, "_help") and help._help is not None:
options[name]["description"] = help._help
if "description" in help and isinstance(help["description"], str): if "description" in help and isinstance(help["description"], str):
options[name]["description"] = options[name]["description"].split("\n") options[name]["description"] = options[name]["description"].split("\n")
if "required" in help and help["required"]: if "required" in help and help["required"]: