Skip to main content

Check that I remembered to document everything

ID
b5e85c7
date
2023-12-26 22:26:37+00:00
author
Alex Chan <alex@alexwlchan.net>
parent
f1328a7
message
Check that I remembered to document everything
changed files
1 file, 24 additions

Changed files

cog_helpers.py (2084) → cog_helpers.py (2746)

diff --git a/cog_helpers.py b/cog_helpers.py
index f3b1be8..c09898c 100644
--- a/cog_helpers.py
+++ b/cog_helpers.py
@@ -42,6 +42,8 @@ def create_description_table(
     repo_name: str = "alexwlchan/scripts",
     primary_branch: str = "main",
 ) -> None:
+    documented_files = set()
+
     outl("<dl>")
 
     for i, s in enumerate(scripts, start=1):
@@ -60,6 +62,8 @@ def create_description_table(
             path = os.path.join(folder_name, name)
             assert os.path.exists(path), os.path.join(path)
 
+            documented_files.add(name)
+
             outl(
                 f'<a href="https://github.com/{repo_name}/blob/{primary_branch}/{folder_name}/{name}">',
                 indent=4,
@@ -86,3 +90,23 @@ def create_description_table(
             outl("")
 
     outl("</dl>")
+
+    # Now check there isn't anything in the folder which should have
+    # been documented, but isn't.
+    undocumented_files = set()
+
+    for f in os.listdir(folder_name):
+        if os.path.isdir(os.path.join(folder_name, f)):
+            continue
+
+        if f in {"README.md", "utf8info.Dockerfile"}:
+            continue
+
+        if f.startswith(("test_", "_")):
+            continue
+
+        if f not in documented_files:
+            undocumented_files.add(f)
+
+    if undocumented_files:
+        raise ValueError(f"Not all files in {folder_name} are documented: {undocumented_files}")