commit c7fb84fe8c58f5c9b747479f6de230a9fd704535
parent 5d7d021521c00f760421c53ce1eed8f1e42f2ac8
Author: Vincent Forest <vincent.forest@meso-star.com>
Date: Mon, 25 Aug 2025 12:22:11 +0200
Make HTML content dependent on menu and index files
All HTML files are now regenerated if the menu.tsv file is updated,
while only the HTML files in the section to which an index.tsv file
belongs are regenerated when it is updated.
Diffstat:
3 files changed, 39 insertions(+), 5 deletions(-)
diff --git a/.gitignore b/.gitignore
@@ -12,3 +12,4 @@ tags
man
*.hook
.hooks
+.index
diff --git a/Makefile b/Makefile
@@ -22,13 +22,13 @@ LINT=$(HTML:.html=.lint) $(SH:.sh=.shlint)
default: build
-build clean distclean lint install: .hooks
- @$(MAKE) -f.hooks -fMakefile $@__ \
+build clean distclean lint install: hooks index
+ @$(MAKE) -f.hooks -f.index -fMakefile $@__ \
HTML="$$($(SHELL) ./list.sh html | tr '\n' ' ')" \
SH="$$( $(SHELL) ./list.sh shell | tr '\n' ' ')"
-.hooks: hooks.sh
- $(SHELL) hooks.sh > $@
+hooks index:
+ $(SHELL) $@.sh > .$@
build__: $(HTML)
@@ -46,7 +46,7 @@ install__: $(HTML) $(SIG)
################################################################################
# Generate content
################################################################################
-$(HTML): generate_header.sh
+$(HTML): generate_header.sh menu.tsv
.sh.md:
@cd -- "$$(dirname "$<")"; \
diff --git a/index.sh b/index.sh
@@ -0,0 +1,33 @@
+#!/bin/sh
+#
+# Copyright (C) 2017-2025 |Méso|Star> (contact@meso-star.com)
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+. "./meso-web.sh"
+
+set -e
+
+# Print to standard output the Makefile targets that make the section
+# index file a prerequisite for the section's HTML content.
+
+html="$(sh ./list.sh html)"
+
+sections | while read -r i; do
+ html_section="$(printf '%s\n' "${html}" \
+ | sed -n "/^${i}\//p" \
+ | tr '\n' ' ')"
+
+ printf '%s: %s/index.tsv\n' "${html_section}" "${i}"
+done