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
pull/83170/head
guppy0130 7 months ago
parent 85d9a40aac
commit 6129291b2a
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): 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() dstring = AnsibleLoader(getattr(module, 'DOCUMENTATION', ''), file_name=path).get_single_data()
# TODO: allow configurable plugins to use sidecar # allow configurable plugins to use sidecar
# if not dstring: if not dstring:
# filename, cn = find_plugin_docfile( name, type_name, self, [os.path.dirname(path)], C.YAML_DOC_EXTENSIONS) # turns `community.general.module` into just `module`
# # TODO: dstring = AnsibleLoader(, file_name=path).get_single_data() 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: if dstring:
add_fragments(dstring, path, fragment_loader=fragment_loader, is_module=(type_name == 'module')) add_fragments(dstring, path, fragment_loader=fragment_loader, is_module=(type_name == 'module'))

Loading…
Cancel
Save