allow plugin loader to load sidecar docs

* if you have an inventory plugin (or other non-test/non-filter plugin,
  I'd assume) that has docs only provided via sidecar, then the plugin's
  config defs need to be populated by the sidecar; otherwise, you're
  forced to have a `DOCUMENTATION` attribute in the inventory plugin
  that duplicates the content of the sidecar
guppy0130 3 weeks ago
parent e3d4c20f6e
commit 35fd5de2cb
No known key found for this signature in database
GPG Key ID: B12A0C868D6866AC

@ -409,10 +409,17 @@ class PluginLoader:
if type_name in C.CONFIGURABLE_PLUGINS and not C.config.has_configuration_definition(type_name, name):
dstring = AnsibleLoader(getattr(module, 'DOCUMENTATION', ''), file_name=path).get_single_data()
# TODO: allow configurable plugins to use sidecar
# if not dstring:
# filename, cn = find_plugin_docfile( name, type_name, self, [os.path.dirname(path)], C.YAML_DOC_EXTENSIONS)
# # TODO: dstring = AnsibleLoader(, file_name=path).get_single_data()
# allow configurable plugins to use sidecar
if not dstring:
# turns `community.general.module` into just `module`
short_module_name = os.path.splitext(name)[1][1:]
for extension in C.YAML_DOC_EXTENSIONS:
possible_sidecar_file = os.path.join(os.path.dirname(path), short_module_name + extension)
if not os.path.exists(possible_sidecar_file):
continue
with open(possible_sidecar_file) as fp:
dstring = AnsibleLoader(fp).get_single_data().get("DOCUMENTATION", "")
break
if dstring:
add_fragments(dstring, path, fragment_loader=fragment_loader, is_module=(type_name == 'module'))

Loading…
Cancel
Save