summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKonstantin Kirik (snegovick) <snegovick@uprojects.org>2025-12-08 08:50:38 +0300
committerKonstantin Kirik (snegovick) <snegovick@uprojects.org>2025-12-08 08:50:38 +0300
commit97e1ee5918222272056d6747735e39933f79011c (patch)
treef6899798869007dfc6ad37dfe792819ac6ba405f
parentefb56b311a59529196831da51ebbf21c20be665d (diff)
Add scripts and index page for html man pages
-rw-r--r--man/index.html31
-rw-r--r--man/lib/mklinks.py48
-rw-r--r--man/lib/tohtml.sh34
3 files changed, 113 insertions, 0 deletions
diff --git a/man/index.html b/man/index.html
new file mode 100644
index 00000000..cbc595f2
--- /dev/null
+++ b/man/index.html
@@ -0,0 +1,31 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <meta charset="utf-8"/>
+ <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
+ <style>
+ table.head, table.foot { width: 100%; }
+ td.head-rtitle, td.foot-os { text-align: right; }
+ td.head-vol { text-align: center; }
+ .Nd, .Bf, .Op { display: inline; }
+ .Pa, .Ad { font-style: italic; }
+ .Ms { font-weight: bold; }
+ .Bl-diag > dt { font-weight: bold; }
+ code.Nm, .Fl, .Cm, .Ic, code.In, .Fd, .Fn, .Cd { font-weight: bold;
+ font-family: inherit; }
+ </style>
+ <title>INTRO(1)</title>
+</head>
+<body>
+<pre><a href="1">Section (1)</a> (this section) for the commonly-used commands.
+<a href="2">Section (2)</a> for Limbo modules, including Inferno's system calls.
+<a href="3">Section (3)</a> for kernel devices (accessed by `bind').
+<a href="4">Section (4)</a> for file services (accessed by `mount').
+<a href="5">Section (5)</a> for the Styx file service protocol.
+<a href="6">Section (6)</a> for file formats and system conventions.
+<a href="7">Section (7)</a> for databases and database access modules.
+<a href="8">Section (8)</a> for administrative modules and system services.
+<a href="9">Section (9)</a> for the reference for Inferno's Tk variant, Limbo/Tk.
+<a href="10">Section (10)</a> for the build environment and device driver implementation.</pre>
+</body>
+</html>
diff --git a/man/lib/mklinks.py b/man/lib/mklinks.py
new file mode 100644
index 00000000..b2b22a54
--- /dev/null
+++ b/man/lib/mklinks.py
@@ -0,0 +1,48 @@
+import sys
+import re
+import argparse
+
+path_prefix = ""
+
+def repl_normal(m):
+ if m.group('name').lower() == 'section':
+ return f"<a href=\"{path_prefix}{m.group('section')}\">{m.group('name')} ({m.group('section')})</a>"
+ else:
+ if m.group('section') not in ['lib', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10']:
+ pass
+ else:
+ return f"<a href=\"{path_prefix}{m.group('section')}/{m.group('name')}.html\">{m.group('name')} ({m.group('section')})</a>"
+ return f"{m.group('name')} ({m.group('section')})"
+
+if __name__ == "__main__":
+ parser = argparse.ArgumentParser(
+ prog='mklinks',
+ description='Makes links obviously',
+ epilog='God bless you')
+ parser.add_argument('-i', '--input')
+ parser.add_argument('-o', '--output')
+ parser.add_argument('-p', '--path-prefix')
+ args = parser.parse_args()
+
+ path_prefix = ""
+ if args.path_prefix is not None:
+ path_prefix = args.path_prefix
+
+ link_re = re.compile(r"(?P<name>[a-zA-Z0-9\-\_]+) \((?P<section>[0-9a-z]+)\)")
+ link_i_re = re.compile(r"<i>(?P<name>[a-zA-Z0-9\-\_]+)</i>\((?P<section>[0-9a-z]+)\)")
+ f = None
+ if args.input is None:
+ f = sys.stdin
+ else:
+ f = open(args.input, 'r')
+
+ text = f.read()
+ f.close()
+
+ text = link_re.sub(repl_normal, text)
+ text = link_i_re.sub(repl_normal, text)
+ if args.output is not None:
+ with open(args.output, 'w') as out:
+ out.write(text)
+ else:
+ print(text)
diff --git a/man/lib/tohtml.sh b/man/lib/tohtml.sh
new file mode 100644
index 00000000..b3081a58
--- /dev/null
+++ b/man/lib/tohtml.sh
@@ -0,0 +1,34 @@
+#!/bin/bash
+if [ -e output ]; then
+ rm output -rf
+fi
+
+cwd=$(pwd)
+echo "CWD: ${cwd}"
+mkdir output
+for d in $(ls); do
+ if [ -d $d ]; then
+ if [ x"$d" = x"output" ]; then
+ continue
+ fi
+ if [ x"$d" = x"lib" ]; then
+ continue
+ fi
+ echo "mkdir output/${d}"
+ mkdir output/${d}
+ pushd $d
+ for f in $(ls); do
+ name=$(basename -- "$f")
+ ext="${name##*.}"
+ if [ x"${ext}" = x"html" ]; then
+ 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
+ echo "Processed ${d}/${f}"
+ fi
+ done
+ popd
+ fi
+done