diff --git a/Makefile b/Makefile index 62ccf886..b377de04 100644 --- a/Makefile +++ b/Makefile @@ -197,15 +197,15 @@ checkpatch: MANDOC := -Thtml -Ios=General -Oman=%N.%S.html -Ostyle=mandoc.css wwwman: - $Qmandoc ${MANDOC} src/rgbds.7 > docs/rgbds.7.html - $Qmandoc ${MANDOC} src/gbz80.7 > docs/gbz80.7.html - $Qmandoc ${MANDOC} src/rgbds.5 > docs/rgbds.5.html - $Qmandoc ${MANDOC} src/asm/rgbasm.1 > docs/rgbasm.1.html - $Qmandoc ${MANDOC} src/asm/rgbasm.5 > docs/rgbasm.5.html - $Qmandoc ${MANDOC} src/fix/rgbfix.1 > docs/rgbfix.1.html - $Qmandoc ${MANDOC} src/link/rgblink.1 > docs/rgblink.1.html - $Qmandoc ${MANDOC} src/link/rgblink.5 > docs/rgblink.5.html - $Qmandoc ${MANDOC} src/gfx/rgbgfx.1 > docs/rgbgfx.1.html + $Qmandoc ${MANDOC} src/rgbds.7 | src/doc_postproc.awk > docs/rgbds.7.html + $Qmandoc ${MANDOC} src/gbz80.7 | src/doc_postproc.awk > docs/gbz80.7.html + $Qmandoc ${MANDOC} src/rgbds.5 | src/doc_postproc.awk > docs/rgbds.5.html + $Qmandoc ${MANDOC} src/asm/rgbasm.1 | src/doc_postproc.awk > docs/rgbasm.1.html + $Qmandoc ${MANDOC} src/asm/rgbasm.5 | src/doc_postproc.awk > docs/rgbasm.5.html + $Qmandoc ${MANDOC} src/fix/rgbfix.1 | src/doc_postproc.awk > docs/rgbfix.1.html + $Qmandoc ${MANDOC} src/link/rgblink.1 | src/doc_postproc.awk > docs/rgblink.1.html + $Qmandoc ${MANDOC} src/link/rgblink.5 | src/doc_postproc.awk > docs/rgblink.5.html + $Qmandoc ${MANDOC} src/gfx/rgbgfx.1 | src/doc_postproc.awk > docs/rgbgfx.1.html # This target is used during development in order to prevent adding new issues # to the source code. All warnings are treated as errors in order to block the diff --git a/src/doc_postproc.awk b/src/doc_postproc.awk new file mode 100755 index 00000000..265f7aab --- /dev/null +++ b/src/doc_postproc.awk @@ -0,0 +1,68 @@ +#!/usr/bin/awk -f + +BEGIN { + in_synopsis = 0 +} +// { + in_synopsis = 1 +} +/<\/table>/ { + # Resets synopsis state even when already reset, but whatever + in_synopsis = 0 +} +/-[a-zA-Z]/ { + # Add links to arg descr in synopsis section + if (in_synopsis) { + while (match($0, /-[a-zA-Z]+/)) { + # 123456789012345678 -> 18 chars + optchars = substr($0, RSTART + 18, RLENGTH - 18) + i = length(optchars) + while (i) { + end = RSTART + 18 + i + i -= 1 + len = i ? 1 : 2 + $0 = sprintf("%s%s%s", + substr($0, 0, end - len - 1), + substr($0, end - 1, 1), + substr($0, end - len, len), + substr($0, end)) + } + } + } +} + +/
/ { + # Make the description blurb inline, as with terminal output + gsub(/div/, "span") +} + +BEGIN { + pages["gbz80", 7] = 1 + pages["rgbds", 5] = 1 + pages["rgbds", 7] = 1 + pages["rgbasm", 1] = 1 + pages["rgbasm", 5] = 1 + pages["rgblink",1] = 1 + pages["rgblink",5] = 1 + pages["rgbfix", 1] = 1 + pages["rgbgfx", 1] = 1 +} +// { + # Link to other pages in the doc + for (i in pages) { + split(i, page, SUBSEP) + name = page[1] + section = page[2] + gsub(sprintf("%s\\(%d\\)", name, section), + sprintf("%s(%d)", name, section, name, section)) + } +} + +{ + # Make long opts (defined using `Fl Fl`) into a single tag + gsub(/-<\/code>/, "-") +} + +{ + print +}