diff --git a/.github/scripts/check_doc_references.py b/.github/scripts/check_doc_references.py index a27145b..647455c 100644 --- a/.github/scripts/check_doc_references.py +++ b/.github/scripts/check_doc_references.py @@ -31,11 +31,21 @@ def get_created_md_files(): return created_files +def get_all_md_files(): + """ + Recursively collects all Markdown (.md, .mdx) files under /docusaurus/docs. + Returns: + list[Path]: A list of relative paths to all Markdown files in the docs directory. + """ + return [ + path.relative_to(REPO_ROOT) + for path in DOCS_DIR.rglob("*.md*") + if path.is_file() + ] + def is_file_referenced(file_path): """ Checks if a given file is referenced in the Git repository. - This function searches the Git repository for occurrences of the file name - and determines if the file is referenced in any other files. Args: file_path (Path): The path to the file to check. Returns: @@ -52,16 +62,15 @@ def is_file_referenced(file_path): return len(matches) > 0 def main(): - created_files = get_created_md_files() - if not created_files: - print("No new Markdown files detected.") - return - - print(f"Checking {len(created_files)} new Markdown files...") + md_files = get_created_md_files() + if not md_files: + print("No new Markdown files detected. Checking all Markdown files instead.") + md_files = get_all_md_files() + print(f"Checking {len(md_files)} Markdown files...") unreferenced = [] - for md_file in created_files: + for md_file in md_files: if not is_file_referenced(md_file): unreferenced.append(md_file) diff --git a/.github/workflows/check-references.yml b/.github/workflows/check-references.yml index 5ea193d..7e89238 100644 --- a/.github/workflows/check-references.yml +++ b/.github/workflows/check-references.yml @@ -26,4 +26,4 @@ jobs: - name: Run reference check run: | pip install --upgrade pip - python scripts/check_doc_references.py + python .github/scripts/check_doc_references.py