update documentation check
This commit is contained in:
@@ -27,9 +27,11 @@ BASEDIR = pathlib.Path(__file__).resolve().parents[1]
|
|||||||
State = enum.Enum('State', 'OK FAIL SKIP')
|
State = enum.Enum('State', 'OK FAIL SKIP')
|
||||||
|
|
||||||
|
|
||||||
def _check_dir(dir_name):
|
def _check_dir(dir_name, files=False, show_extra=False):
|
||||||
dir_path = BASEDIR / dir_name
|
dir_path = BASEDIR / dir_name
|
||||||
for readme_path in dir_path.glob('**/README.md'):
|
for readme_path in dir_path.glob('**/README.md'):
|
||||||
|
if '.terraform' in str(readme_path):
|
||||||
|
continue
|
||||||
readme = readme_path.read_text()
|
readme = readme_path.read_text()
|
||||||
mod_name = str(readme_path.relative_to(dir_path).parent)
|
mod_name = str(readme_path.relative_to(dir_path).parent)
|
||||||
result = tfdoc.get_doc(readme)
|
result = tfdoc.get_doc(readme)
|
||||||
@@ -37,7 +39,8 @@ def _check_dir(dir_name):
|
|||||||
state = State.SKIP
|
state = State.SKIP
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
new_doc = tfdoc.create_doc(readme_path.parent)
|
new_doc = tfdoc.create_doc(
|
||||||
|
readme_path.parent, files=files, show_extra=show_extra)
|
||||||
except SystemExit:
|
except SystemExit:
|
||||||
state = state.SKIP
|
state = state.SKIP
|
||||||
else:
|
else:
|
||||||
@@ -47,13 +50,19 @@ def _check_dir(dir_name):
|
|||||||
|
|
||||||
@click.command()
|
@click.command()
|
||||||
@click.argument('dirs', type=str, nargs=-1)
|
@click.argument('dirs', type=str, nargs=-1)
|
||||||
def main(dirs):
|
@ click.option('--show-extra/--no-show-extra', default=False)
|
||||||
|
@ click.option('--files/--no-files', default=False)
|
||||||
|
def main(dirs, files=False, show_extra=False):
|
||||||
'Cycle through modules and ensure READMEs are up-to-date.'
|
'Cycle through modules and ensure READMEs are up-to-date.'
|
||||||
|
errors = 0
|
||||||
state_labels = {State.FAIL: '✗', State.OK: '✓', State.SKIP: '?'}
|
state_labels = {State.FAIL: '✗', State.OK: '✓', State.SKIP: '?'}
|
||||||
for dir_name in dirs:
|
for dir_name in dirs:
|
||||||
print(f'----- {dir_name} -----')
|
print(f'----- {dir_name} -----')
|
||||||
for mod_name, state in _check_dir(dir_name):
|
for mod_name, state in _check_dir(dir_name):
|
||||||
|
errors += 1 if state == State.FAIL else 0
|
||||||
print(f'[{state_labels[state]}] {mod_name}')
|
print(f'[{state_labels[state]}] {mod_name}')
|
||||||
|
if errors:
|
||||||
|
raise SystemExit('Errors found.')
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|||||||
45
tools/tfutils.py
Executable file
45
tools/tfutils.py
Executable file
@@ -0,0 +1,45 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
|
# Copyright 2021 Google LLC
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
|
||||||
|
import pathlib
|
||||||
|
|
||||||
|
import click
|
||||||
|
|
||||||
|
|
||||||
|
def main(**kw):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
@click.group()
|
||||||
|
@click.option('--dry-run', is_flag=True, default=False)
|
||||||
|
def cli(**kwargs):
|
||||||
|
basedir = pathlib.Path(source or '.')
|
||||||
|
for f in basedir.glob('**/*.tf'):
|
||||||
|
if '.terraform' in f:
|
||||||
|
continue
|
||||||
|
print(f)
|
||||||
|
|
||||||
|
|
||||||
|
@cli.command()
|
||||||
|
@click.argument('source', nargs=-1)
|
||||||
|
@click.option('--from-static/--to-static', default=True)
|
||||||
|
def mod_source(source=None, from_static=True):
|
||||||
|
print('mod_source')
|
||||||
|
print(source, from_static)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
cli()
|
||||||
Reference in New Issue
Block a user