docs/website: Add Makefile to pre-generate the website
RFC PATCH v2 1/1 docs/website: Add Makefile to pre-generate the website
Supports the current includes plus smu [0] lightweight markup.
[0] https://github.com/Gottox/smu
--- docs/website/Makefile | 33 +++++++++++++++++++++++++++++++++ docs/website/incfile.awk | 23 +++++++++++++++++++++++ 2 files changed, 56 insertions(+) create mode 100644 docs/website/Makefile create mode 100644 docs/website/incfile.awk
docs/website/Makefile new file +33 -0
@@ -0,0 +1,33 @@ +.PHONY: all +all: + +# Avoid implicit rules +MAKEFLAGS += -r + +AWK ?= mawk + +SRCDIR := ${CURDIR} +DEPLOYDIR := ${CURDIR}/out + +src-pages != find ${SRCDIR} -maxdepth 1 -name \*.html -o -name \*.smu +dst-pages := ${src-pages:${SRCDIR}/%=${DEPLOYDIR}/%} +dst-pages := ${dst-pages:.smu=.html} + +all: ${dst-pages} + +conf-files := ${MAKEFILE_LIST} +conf-files += $(wildcard ${HOME}/.tidyrc) +conf-files += ${SRCDIR}/incfile.awk + +${DEPLOYDIR}/%.html: ${SRCDIR}/%.html ${conf-files} + mkdir -p "${@D}" + tmpfile=$$(mktemp) && \ + ${AWK} -f incfile.awk $< > "$$tmpfile" && \ + { tidy -q -m -i "$$tmpfile"; :; } && \ + mv "$$tmpfile" $@ + +${DEPLOYDIR}/%.html: ${SRCDIR}/%.smu ${conf-files} + mkdir -p "${@D}" + tmpfile=$$(mktemp) && \ + ${AWK} -f incfile.awk $< | smu | tidy -q -m > "$$tmpfile" && \ + mv "$$tmpfile" $@
docs/website/incfile.awk new file +23 -0
@@ -0,0 +1,23 @@ +BEGIN { + FS="\"" +} + +{ + do { + if (match($0, /^<!--#include file="([^"]*)" *-->$/)) { + file_stack[++file_cur] = $2 + } else { + print + } + if (file_cur) { + e = getline < file_stack[file_cur] + if (!e) { + --file_cur + } else if (e == -1) { + printf "%s: read error\n", \ + file_stack[file_cur] \ + > "/dev/stderr" + } + } + } while (file_cur) +}
Signature · 6 lines
2.43.0 _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
Quoted 4 lines · Ismael Luceno
Supports the current includes plus smu [0] lightweight markup.
[0] https://github.com/Gottox/smu
Signed-off-by Ismael Luceno <[email protected]>
Changes from v1:
- Processes includes before passing through smu
- Still imperfect because smu mangles many html tags
To do:
- Maybe special-case html header and footer for smu files.
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
Ismael, All,
I'll do the rest of my review in this new iteration! ;-)
On 2024-02-06 15:53 +0100, Ismael Luceno spake thusly:
[--SNIP--]
docs/website/Makefile line 32
Quoted 4 lines
+${DEPLOYDIR}/%.html: ${SRCDIR}/%.smu ${conf-files}
docs/website/Makefile new file +3
-0+ mkdir -p "${@D}" + tmpfile=$$(mktemp) && \ + ${AWK} -f incfile.awk $< | smu | tidy -q -m > "$$tmpfile" && \
Don't use pipes, otherwise we can't catch the failure of any intermediate command. For example, if we can get the awk script to properly fail in case of error, using pipes will not allow the Makefile to catch issues.
Regards,
Yann E. MORIN.
Signature · 10 lines
.-----------------.--------------------.------------------.--------------------. | Yann E. MORIN | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: | | +33 662 376 056 | Software Designer | \ / CAMPAIGN | ___ | | +33 561 099 427 `------------.-------: X AGAINST | \e/ There is no | | http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL | v conspiracy. | '------------------------------^-------^------------------^--------------------' _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot