Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [RFC PATCH] docs/website: Add Makefile to pre-generate the website
@ 2024-02-06 14:40 Ismael Luceno
  2024-02-06 15:08 ` Yann E. MORIN
  0 siblings, 1 reply; 4+ messages in thread
From: Ismael Luceno @ 2024-02-06 14:40 UTC (permalink / raw)
  To: buildroot; +Cc: Ismael Luceno

Supports the current includes plus smu [0] lightweight markup.

[0] https://github.com/Gottox/smu
Signed-off-by: Ismael Luceno <ismael@iodev.co.uk>
---
 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

diff --git a/docs/website/Makefile b/docs/website/Makefile
new file mode 100644
index 000000000000..b0a56919c0e7
--- /dev/null
+++ b/docs/website/Makefile
@@ -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) && \
+	smu < $< | ${AWK} -f incfile.awk | tidy -q -m > "$$tmpfile" && \
+	mv "$$tmpfile" $@
diff --git a/docs/website/incfile.awk b/docs/website/incfile.awk
new file mode 100644
index 000000000000..350a88e7b956
--- /dev/null
+++ b/docs/website/incfile.awk
@@ -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)
+}
-- 
2.43.0

_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-02-06 16:30 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-02-06 14:40 [Buildroot] [RFC PATCH] docs/website: Add Makefile to pre-generate the website Ismael Luceno
2024-02-06 15:08 ` Yann E. MORIN
2024-02-06 15:21   ` Ismael Luceno
2024-02-06 16:30     ` Yann E. MORIN

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox