Add yamllint for plugin docs and fix issues.

This commit is contained in:
Matt Clay 2018-05-23 05:49:30 -07:00
commit 15b6837daf
13 changed files with 50 additions and 19 deletions

View file

@ -0,0 +1,19 @@
extends: default
rules:
braces: disable
brackets: disable
colons: disable
commas: disable
comments: disable
comments-indentation: disable
document-start: disable
empty-lines: disable
hyphens: disable
indentation: disable
key-duplicates: disable
line-length: disable
new-line-at-end-of-file: disable
new-lines: {type: unix}
trailing-spaces: disable
truthy: disable

View file

@ -40,6 +40,7 @@ class YamlChecker(object):
"""
yaml_conf = YamlLintConfig(file='test/sanity/yamllint/config/default.yml')
module_conf = YamlLintConfig(file='test/sanity/yamllint/config/modules.yml')
plugin_conf = YamlLintConfig(file='test/sanity/yamllint/config/plugins.yml')
for path in paths:
extension = os.path.splitext(path)[1]
@ -50,7 +51,12 @@ class YamlChecker(object):
if extension in ('.yml', '.yaml'):
self.check_yaml(yaml_conf, path, contents)
elif extension == '.py':
self.check_module(module_conf, path, contents)
if path.startswith('lib/ansible/plugins/'):
conf = plugin_conf
else:
conf = module_conf
self.check_module(conf, path, contents)
else:
raise Exception('unsupported extension: %s' % extension)
@ -137,7 +143,7 @@ class YamlChecker(object):
if not module_ast:
return {}
if path.startswith('lib/ansible/modules/'):
if path.startswith('lib/ansible/modules/') or path.startswith('lib/ansible/plugins/'):
for body_statement in module_ast.body:
if isinstance(body_statement, ast.Assign):
check_assignment(body_statement, module_doc_types)