From dfb6adbcbcc7d50b770b6d5ea82efdd8f8c32e25 Mon Sep 17 00:00:00 2001
From: omniscient <17525998+omnisci3nce@users.noreply.github.com>
Date: Sat, 5 Oct 2024 12:48:05 +1000
Subject: delete documentation workflow
---
archive/src/apidocs/gen_apidocs.py | 119 +++++++++++++++++++++++++++++++++++++
1 file changed, 119 insertions(+)
create mode 100644 archive/src/apidocs/gen_apidocs.py
(limited to 'archive/src/apidocs/gen_apidocs.py')
diff --git a/archive/src/apidocs/gen_apidocs.py b/archive/src/apidocs/gen_apidocs.py
new file mode 100644
index 0000000..d01e441
--- /dev/null
+++ b/archive/src/apidocs/gen_apidocs.py
@@ -0,0 +1,119 @@
+# Generates a static webpage for the public C-API of `celeritas-core`
+#
+# TODO:
+# - remove prefixes like 'static' and 'inline'
+# - parse docstrings from source
+
+import re
+import os
+from pathlib import Path
+
+# --- HTML Fragments
+page_start = """
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Celeritas core API
+
+
+
+"""
+
+page_header = """
+
+ CELERITAS CORE API DOCS
+
+"""
+
+page_footer = """
+
+"""
+
+page_end = """
+
+
+
+"""
+
+def emit_function_sig(signature: str) -> str:
+ return f"""
+
+ {signature}
+
+ """
+
+categories = {
+ "Core": "src/core",
+ "Render": "src/new_render",
+ "Maths": "src/maths",
+ "RAL": "src/ral",
+ "Systems": "src/systems",
+}
+
+def find_pub_functions_in_folder(folder_path):
+ functions = []
+ for filename in os.listdir(folder_path):
+ filepath = os.path.join(folder_path, filename)
+ if os.path.isfile(filepath):
+ file_funcs = find_pub_functions_in_file(filepath)
+ functions.extend(file_funcs)
+
+ return functions
+
+def find_pub_functions_in_file(file_path):
+ pattern = r'PUB\s+(\w+\s+)*(\w+)\s+(\w+)\s*\((.*?)\)'
+
+ with open(file_path, 'r') as file:
+ content = file.read()
+
+ matches = re.finditer(pattern, content, re.MULTILINE)
+
+ # Collect all the functions into an array
+ functions = []
+ for match in matches:
+ signature = match.group(0)
+ if signature.startswith("PUB "):
+ signature = signature[4:]
+ if signature.startswith("c_static_inline "):
+ signature = signature[16:]
+
+ print(signature)
+ functions.append(signature)
+
+ return functions
+
+def generate_html():
+ html_filepath = "index.html"
+
+ script_dir = Path(__file__).resolve().parent
+ grandparent_dir = script_dir.parents[1]
+
+ with open(html_filepath, 'w') as export_file:
+ export_file.write(page_start)
+ export_file.write(page_header)
+ # TODO: make the actual content
+ for category in categories.keys():
+ folder = os.path.join(grandparent_dir, categories[category])
+ category_funcs = find_pub_functions_in_folder(folder)
+ export_file.write(f"{category}
")
+ export_file.write("")
+ for func in category_funcs:
+ export_file.write(emit_function_sig(func))
+ export_file.write("
")
+ export_file.write(page_end)
+
+if __name__ == "__main__":
+ generate_html()
--
cgit v1.2.3-70-g09d2