From 844b1ccf9c148f1dfb16249c7666e6ed79629938 Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Sun, 28 Apr 2019 12:24:51 -0400 Subject: [PATCH 3/3] Makefile: add new app-text/tidy-html5 sanity check. This new PHONY "make tidy" target runs the tidy-html5 program, using a new .tidyrc file, to ensure that the HTML we have generated is free from certain problems. In particular, it should complain if bug 626032 ever resurfaces and there are duplicate identifiers in some document. Closes: https://bugs.gentoo.org/626032 Signed-off-by: Michael Orlitzky --- .tidyrc | 10 ++++++++++ Makefile | 13 ++++++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 .tidyrc diff --git a/.tidyrc b/.tidyrc new file mode 100644 index 0000000..393d9a4 --- /dev/null +++ b/.tidyrc @@ -0,0 +1,10 @@ +# The order matters here! If you "mute" a warning before making it "quiet," +# tidy will start talking about how it's going to ignore some warnings. + +# Don't complain about dropped empty elements, because our Tyrian +# template contains a bunch. Maybe they can be eliminated; but in +# the meantime it's not productive to whine about them. +drop-empty-elements: no + +# Show only warnings and errors. +quiet: yes diff --git a/Makefile b/Makefile index 17be902..5ade8f6 100644 --- a/Makefile +++ b/Makefile @@ -49,7 +49,18 @@ validate: prereq @xmllint --noout --dtdvalid devbook.dtd $(XMLS) \ && echo "xmllint validation successful" +# Run app-text/tidy-html5 on the output to detect mistakes. +# We have to loop through them because otherwise tidy won't +# tell you which file contains a mistake. +tidy: $(HTMLS) + @for f in $(HTMLS); do \ + output="$$(tidy -errors -config .tidyrc $${f} 2>&1)"; \ + test -z "$${output}" || { echo "$${output}"; \ + echo "^ Failed on $${f}"; \ + exit 1; }; \ + done; + clean: rm -f $(HTMLS) $(IMAGES) _documents.js documents.js -.PHONY: all prereq validate clean +.PHONY: all prereq validate tidy clean -- 2.24.1