diff options
| author | 0xf00sec <159052166+0xf00sec@users.noreply.github.com> | 2025-08-09 20:14:37 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-08-09 20:14:37 +0000 |
| commit | cfd80c4212d449c9b33cc9d18b05da6b3d2c52bc (patch) | |
| tree | 77d15a66a6d600b72ddf69ff257a7692ed485ae5 /tools/mk_htman.py | |
| parent | d9f1a4f656ced76df3f23eeec678e1a3be1fd432 (diff) | |
| parent | 7ada9006860084ba5d72b517649d1b2d51e4484a (diff) | |
Merge branch 'nekernel-org:dev' into dev
Diffstat (limited to 'tools/mk_htman.py')
| -rw-r--r-- | tools/mk_htman.py | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/tools/mk_htman.py b/tools/mk_htman.py new file mode 100644 index 00000000..e865f7c5 --- /dev/null +++ b/tools/mk_htman.py @@ -0,0 +1,41 @@ +#! /usr/bin/env python3 +# -*- coding: utf-8 -*- + +import sys, os + +if __name__ == "__main__": + if len(sys.argv) != 2: + 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) |
