summaryrefslogtreecommitdiffhomepage
path: root/tooling/mk_htman.py
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlal@nekernel.org>2025-07-23 09:21:11 +0100
committerAmlal El Mahrouss <amlal@nekernel.org>2025-07-23 09:21:11 +0100
commit9d1576313977b15b05421d646809ec1f2c413854 (patch)
treed09866601f1aca7e670a4b055b5a8307cbdcef76 /tooling/mk_htman.py
parent6d16db11d91c5fdf302af54e8e797dcbed8c9c71 (diff)
feat: tooling: wrote a simple nekernel manual to html converter.
Signed-off-by: Amlal El Mahrouss <amlal@nekernel.org>
Diffstat (limited to 'tooling/mk_htman.py')
-rwxr-xr-xtooling/mk_htman.py34
1 files changed, 33 insertions, 1 deletions
diff --git a/tooling/mk_htman.py b/tooling/mk_htman.py
index 5488d478..e865f7c5 100755
--- a/tooling/mk_htman.py
+++ b/tooling/mk_htman.py
@@ -5,5 +5,37 @@ import sys, os
if __name__ == "__main__":
if len(sys.argv) != 2:
- print("INFO: manual.py <manual_path>")
+ print("INFO: mk_htman.py <manual_path>")
sys.exit(os.EX_CONFIG)
+
+ manual_path = sys.argv[1]
+ if not os.path.exists(manual_path):
+ print(f"ERROR: Manual path '{manual_path}' does not exist.")
+ sys.exit(os.EX_NOINPUT)
+
+ if os.path.isdir(manual_path):
+ print(f"ERROR: Manual path '{manual_path}' is a directory.")
+ sys.exit(os.EX_NOTDIR)
+
+ if not manual_path.endswith('.man'):
+ print(f"ERROR: Manual path '{manual_path}' must end with '.man'")
+ sys.exit(os.EX_DATAERR)
+
+ try:
+ with open(manual_path, 'r') as file:
+ content = file.read()
+ if not content.strip():
+ print(f"ERROR: Manual file '{manual_path}' is empty.")
+ sys.exit(os.EX_DATAERR)
+ html_content = f"<html><head><title>NeKernel Manual: {manual_path}</title></head><body><pre>{content}</pre></body></html>"
+
+ html_path = manual_path.replace('.man', '.html')
+
+ with open(html_path, 'w') as html_file:
+ html_file.write(html_content)
+ except IOError as e:
+ print(f"ERROR: Could not read manual file '{manual_path}': {e}")
+ sys.exit(os.EX_IOERR)
+
+ print(f"INFO: Wrote manual '{manual_path}' to HTML.")
+ sys.exit(os.EX_OK)