]> git.corax.cc Git - corax/commitdiff
doc/man: Add script for crosslinking of generated HTML documentation doc
authorMatthias Kruk <m@m10k.eu>
Tue, 1 Sep 2020 11:33:42 +0000 (20:33 +0900)
committerMatthias Kruk <m@m10k.eu>
Tue, 1 Sep 2020 11:41:39 +0000 (20:41 +0900)
doc/man/Makefile
doc/man/linkify.sh [new file with mode: 0755]

index 0790b408d1a064a2f4eff32bf5c14331ef2d23fa..0f8a14114e8d8aadb28d88346c853456a67de4d5 100644 (file)
@@ -1,12 +1,21 @@
-HTMLFILES = paging.html
-PHONY =
+HTMLFILES = memory.10.html
+PHONY = clean
 
 all: $(HTMLFILES)
 
 clean:
-       rm -f $(HTMLFILES)
+       rm -f $(HTMLFILES) *.png
 
 .PHONY: $(PHONY)
 
-%.html: %.9
-       groff -mandoc -Thtml $< > $@
+%.0.html: %.0
+       groff -mandoc -tbl -Thtml $< > $@
+       ./linkify.sh $@
+
+%.9.html: %.9
+       groff -mandoc -tbl -Thtml $< > $@
+       ./linkify.sh $@
+
+%.10.html: %.10
+       groff -mandoc -tbl -Thtml $< > $@
+       ./linkify.sh $@
diff --git a/doc/man/linkify.sh b/doc/man/linkify.sh
new file mode 100755 (executable)
index 0000000..59c15b9
--- /dev/null
@@ -0,0 +1,26 @@
+#!/bin/bash
+
+# collect the name of all pages
+pages=()
+
+while read -r page; do
+       pages+=("$(basename "$page")")
+done < <(find . -name "*.0" -or -name "*.9" -or -name "*.10" -type f)
+
+# Iterate over all pages, inserting links to those pages that actually exist. I used a simple
+# regex for this at first, but this would also insert links for pages that don't exist, which
+# is not what we want since there is stuff like "hoge(0)" and references to not-yet-existing
+# articles.
+
+for ((i=1; i<="$#"; i++)); do
+       manpage="${!i}"
+
+       for page in "${pages[@]}"; do
+               pn=$(echo "$page" | cut -d '.' -f 1)
+               ps=$(echo "$page" | cut -d '.' -f 2)
+
+               sed -i -e "s|<b>$pn</b>($ps)|<a href=\"$pn.$ps.html\"><b>$pn</b>($ps)</a>|g" "$manpage"
+       done
+done
+
+exit 0