From c2447c0837629117f03d7f2494f451f4585c8b89 Mon Sep 17 00:00:00 2001 From: "Konstantin Kirik (snegovick)" Date: Tue, 9 Dec 2025 00:14:36 +0300 Subject: Add mksectionindex.py script to create man section html index, integrate this script into man to html pipeline --- man/index.html | 2 +- man/lib/mksectionindex.py | 36 ++++++++++++++++++++++++++++++++++++ man/lib/tohtml.sh | 6 ++++-- 3 files changed, 41 insertions(+), 3 deletions(-) create mode 100644 man/lib/mksectionindex.py diff --git a/man/index.html b/man/index.html index cbc595f2..9cd04982 100644 --- a/man/index.html +++ b/man/index.html @@ -14,7 +14,7 @@ code.Nm, .Fl, .Cm, .Ic, code.In, .Fd, .Fn, .Cd { font-weight: bold; font-family: inherit; } - INTRO(1) + Sections index
Section (1) (this section) for the commonly-used commands.
diff --git a/man/lib/mksectionindex.py b/man/lib/mksectionindex.py
new file mode 100644
index 00000000..480011fe
--- /dev/null
+++ b/man/lib/mksectionindex.py
@@ -0,0 +1,36 @@
+import os
+import sys
+
+if __name__ == "__main__":
+    prefix = sys.argv[1]
+    section = sys.argv[2]
+    index_file = """
+
+
+
+
+"""
+
+    index_file += f"Section {section} index"
+    index_file += f"""
+
+
+    

Section {section} index

+
+"""
+
+    for f in os.listdir():
+        index_file += f"{f}\n"
+
+    index_file += "
" + print(index_file) diff --git a/man/lib/tohtml.sh b/man/lib/tohtml.sh index b3081a58..6b10e535 100644 --- a/man/lib/tohtml.sh +++ b/man/lib/tohtml.sh @@ -24,11 +24,13 @@ for d in $(ls); do echo "Remove ${f}" rm $f else - cat ${f} | mandoc -Thtml | python3 ${cwd}/mklinks.py -p /man/ -o ${cwd}/output/$d/$f.html - #cat ${f} | mandoc -Thtml > ${cwd}/output/$d/$f.html + cat ${f} | mandoc -Thtml | python3 ${cwd}/lib/mklinks.py -p /man/ -o ${cwd}/output/$d/$f.html echo "Processed ${d}/${f}" fi done + rm ${cwd}/output/$d/INDEX.html + python3 ${cwd}/lib/mksectionindex.py /man/ ${d} > ${cwd}/output/$d/index.html popd fi done +cp ${cwd}/index.html output -- cgit v1.2.3