From 0b8309565b424a6379335e77d61bcd2e7d2974a8 Mon Sep 17 00:00:00 2001 From: obrusvit Date: Wed, 7 Feb 2024 10:48:17 +0100 Subject: [PATCH] fixup! docs: impl tool to list .md missing in SUMMARY.md --- Makefile | 6 +++++- tools/check_docs_summary.py | 13 ++++++++++++- 2 files changed, 17 insertions(+), 2 deletions(-) mode change 100644 => 100755 tools/check_docs_summary.py diff --git a/Makefile b/Makefile index fe99a3b7df5..ddafaf5c97a 100644 --- a/Makefile +++ b/Makefile @@ -9,7 +9,7 @@ PY_FILES = $(shell find . -type f -name '*.py' | sed 'sO^\./OO' | grep -f ./to C_FILES = $(shell find . -type f -name '*.[ch]' | grep -f ./tools/style.c.include | grep -v -f ./tools/style.c.exclude ) -style_check: pystyle_check ruststyle_check cstyle_check changelog_check yaml_check editor_check ## run all style checks +style_check: pystyle_check ruststyle_check cstyle_check changelog_check yaml_check docs_summary_check editor_check ## run all style checks style: pystyle ruststyle cstyle ## apply all code styles (C+Rust+Py) @@ -138,6 +138,10 @@ ci_docs: ## generate CI documentation ci_docs_check: ## check that generated CI documentation is up to date ./tools/generate_ci_docs.py --check +docs_summary_check: ## check if there are unlinked documentation files + @echo [DOCS-SUMMARY-MARKDOWN-CHECK] + python3 tools/check_docs_summary.py + vendorheader: ## generate vendor header ./core/embed/vendorheader/generate.sh --quiet diff --git a/tools/check_docs_summary.py b/tools/check_docs_summary.py old mode 100644 new mode 100755 index 3b216cb1d89..9cab0bafbf4 --- a/tools/check_docs_summary.py +++ b/tools/check_docs_summary.py @@ -49,6 +49,17 @@ def difference(g1: Iterable[str], g2: Iterable[str]) -> Generator[str, None, Non yield item +def print_result(filenames: Iterable[str]) -> None: + if not filenames: + print("OK") + else: + print( + f"WARNING: these files exist in {DOCS_DIR} but are not linked in {DOCS_DIR + SUMMARY_FILENAME}" + ) + for f in filenames: + print(f"\t- {f}") + + def main(): re_md_link = re.compile(RE_MARKDOWN_LINK) @@ -61,7 +72,7 @@ def main(): DOCS_DIR + SUMMARY_FILENAME, re_md_link, 1 ) diff = difference(md_files_in_docs_dir, md_files_linked_in_summary) - print(list(diff)) + print_result(list(diff)) if __name__ == "__main__":