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

Arg spec doc comparison fixes (#36265)

* Ensure we merge doc fragments early, for comparisons

* Perform boolean conversion from arg_spec data too

* Update valdiate-modules ignore.txt due to recent changes
This commit is contained in:
Matt Martz 2018-02-15 16:49:11 -06:00 committed by John R Barker
parent 86918db312
commit 831a9d67d7
2 changed files with 211 additions and 509 deletions

File diff suppressed because it is too large Load diff

View file

@ -1019,6 +1019,15 @@ class ModuleValidator(Validator):
if not self.analyze_arg_spec:
return
if docs is None:
docs = {}
try:
add_fragments(docs, self.object_path, fragment_loader=fragment_loader)
except Exception:
# Cannot merge fragments
return
try:
spec, args, kwargs = get_argument_spec(self.path)
except AnsibleModuleImportError as e:
@ -1061,12 +1070,15 @@ class ModuleValidator(Validator):
doc_default = docs.get('options', {}).get(arg, {}).get('default', None)
if data.get('type') == 'bool':
doc_default = maybe_convert_bool(doc_default)
if 'default' in data and data['default'] != doc_default:
arg_default = data.get('default')
if 'default' in data and data.get('type') == 'bool':
arg_default = maybe_convert_bool(data['default'])
if 'default' in data and arg_default != doc_default:
self.reporter.error(
path=self.object_path,
code=324,
msg=('Value for "default" from the argument_spec (%r) for "%s" does not match the '
'documentation (%r)' % (data['default'], arg, doc_default))
'documentation (%r)' % (arg_default, arg, doc_default))
)
doc_type = docs.get('options', {}).get(arg, {}).get('type', 'str')
@ -1087,12 +1099,6 @@ class ModuleValidator(Validator):
)
if docs:
try:
add_fragments(docs, self.object_path, fragment_loader=fragment_loader)
except Exception:
# Cannot merge fragments
return
file_common_arguments = set()
for arg, data in FILE_COMMON_ARGUMENTS.items():
file_common_arguments.add(arg)