Bring back sorted variables check

This commit is contained in:
Julio Castillo
2022-10-20 16:15:41 +02:00
parent 4d067fe2cd
commit 8366933f4d
2 changed files with 21 additions and 5 deletions

View File

@@ -47,13 +47,28 @@ def _check_dir(dir_name, exclude_files=None, files=False, show_extra=False):
state = State.SKIP
else:
try:
new_doc = tfdoc.create_doc(readme_path.parent, files, show_extra,
exclude_files, readme)
new_doc, _, variables, outputs = tfdoc.create_doc(
readme_path.parent, files, show_extra, exclude_files, readme)
variables = [v.name for v in variables]
except SystemExit:
state = state.SKIP
else:
if new_doc == result['doc']:
state = State.OK
elif variables != sorted(variables):
state = state.FAIL
diff = "\n".join([
f'----- {mod_name} variables -----',
f'variables should be in this order: ',
', '.join(sorted(variables)),
])
elif outputs != sorted(outputs):
state = state.FAIL
diff = "\n".join([
f'----- {mod_name} outputs -----',
f'outputs should be in this order: ',
', '.join(sorted(outputs)),
])
else:
state = State.FAIL
header = f'----- {mod_name} diff -----\n'
@@ -73,7 +88,7 @@ def main(dirs, exclude_file=None, files=False, show_diffs=False,
'Cycle through modules and ensure READMEs are up-to-date.'
print(f'files: {files}, extra: {show_extra}, diffs: {show_diffs}\n')
errors = []
state_labels = {State.FAIL: '', State.OK: '', State.SKIP: '?'}
state_labels = {State.FAIL: '', State.OK: '', State.SKIP: ' '}
for dir_name in dirs:
print(f'----- {dir_name} -----')
for mod_name, state, diff in _check_dir(dir_name, exclude_file, files,

View File

@@ -358,7 +358,8 @@ def create_doc(module_path, files=False, show_extra=False, exclude_files=None,
mod_outputs = list(parse_outputs(module_path, exclude_files))
except (IOError, OSError) as e:
raise SystemExit(e)
return format_doc(mod_outputs, mod_variables, mod_files, show_extra)
doc = format_doc(mod_outputs, mod_variables, mod_files, show_extra)
return (doc, mod_files, mod_variables, mod_outputs)
def get_readme(readme_path):
@@ -400,7 +401,7 @@ def main(module_path=None, exclude_file=None, files=False, replace=True,
'Program entry point.'
readme_path = os.path.join(module_path, 'README.md')
readme = get_readme(readme_path)
doc = create_doc(module_path, files, show_extra, exclude_file, readme)
doc, *_ = create_doc(module_path, files, show_extra, exclude_file, readme)
if replace:
replace_doc(readme_path, doc, readme)
else: