From: Matthias Kruk Date: Tue, 1 Sep 2020 11:33:42 +0000 (+0900) Subject: doc/man: Add script for crosslinking of generated HTML documentation X-Git-Url: https://git.corax.cc/?a=commitdiff_plain;h=refs%2Fheads%2Fdoc;p=corax doc/man: Add script for crosslinking of generated HTML documentation --- diff --git a/doc/man/Makefile b/doc/man/Makefile index 0790b40..0f8a141 100644 --- a/doc/man/Makefile +++ b/doc/man/Makefile @@ -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 index 0000000..59c15b9 --- /dev/null +++ b/doc/man/linkify.sh @@ -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|$pn($ps)|$pn($ps)|g" "$manpage" + done +done + +exit 0