in tools/check_links.py [0:0]
def main(dirs, external, show_summary=True, scan_files=False):
'Checks links in Markdown files contained in dirs.'
errors = []
if scan_files:
dirs = [pathlib.Path(x).parent for x in dirs]
for dir_name in dirs:
if show_summary:
print(f'----- {dir_name} -----')
for doc in check_docs(dir_name, external):
state = '✓' if all(l.valid for l in doc.links) else '✗'
if show_summary:
print(f'[{state}] {doc.relpath} ({len(doc.links)})')
if state == '✗':
error = [f'{dir_name}/{doc.relpath}']
for l in doc.links:
if not l.valid:
error.append(f' - {l.dest}')
if show_summary:
print(f' {l.dest}')
errors.append('\n'.join(error))
if errors:
raise SystemExit('Errors found:\n{}'.format('\n'.join(errors)))