aboutsummaryrefslogtreecommitdiff
path: root/build.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2024-06-16 20:03:14 -0700
committerAndrew Kelley <andrew@ziglang.org>2024-06-17 00:10:35 -0700
commit651225c2d4d86c661dba134eee2e3af421bf04b0 (patch)
tree35d4908e2e67384b5d2026d2c44358c99807e4ad /build.zig
parentfda2458f6ac9c4f5ddc7d0fb70ab6194ce1adc47 (diff)
downloadzig-651225c2d4d86c661dba134eee2e3af421bf04b0.tar.gz
zig-651225c2d4d86c661dba134eee2e3af421bf04b0.zip
add -Denable-tidy flag and use it in the CI
Eliminates a TODO from the CI scripts; makes it easier to check validity of html when working on the langref locally.
Diffstat (limited to 'build.zig')
-rw-r--r--build.zig18
1 files changed, 18 insertions, 0 deletions
diff --git a/build.zig b/build.zig
index 1cb73eb52a..55c9e9da8f 100644
--- a/build.zig
+++ b/build.zig
@@ -31,10 +31,18 @@ pub fn build(b: *std.Build) !void {
const skip_install_langref = b.option(bool, "no-langref", "skip copying of langref to the installation prefix") orelse skip_install_lib_files;
const std_docs = b.option(bool, "std-docs", "include standard library autodocs") orelse false;
const no_bin = b.option(bool, "no-bin", "skip emitting compiler binary") orelse false;
+ const enable_tidy = b.option(bool, "enable-tidy", "Check langref output HTML validity") orelse false;
const langref_file = generateLangRef(b);
const install_langref = b.addInstallFileWithDir(langref_file, .prefix, "doc/langref.html");
+ const check_langref = tidyCheck(b, langref_file);
+ const check_autodocs = tidyCheck(b, b.path("lib/docs/index.html"));
+ if (enable_tidy) {
+ test_step.dependOn(check_langref);
+ test_step.dependOn(check_autodocs);
+ }
if (!skip_install_langref) {
+ if (enable_tidy) install_langref.step.dependOn(check_langref);
b.getInstallStep().dependOn(&install_langref.step);
}
@@ -51,6 +59,7 @@ pub fn build(b: *std.Build) !void {
.install_subdir = "doc/std",
});
if (std_docs) {
+ if (enable_tidy) install_std_docs.step.dependOn(check_autodocs);
b.getInstallStep().dependOn(&install_std_docs.step);
}
@@ -1308,3 +1317,12 @@ fn generateLangRef(b: *std.Build) std.Build.LazyPath {
docgen_cmd.addFileArg(b.path("doc/langref.html.in"));
return docgen_cmd.addOutputFileArg("langref.html");
}
+
+fn tidyCheck(b: *std.Build, html_file: std.Build.LazyPath) *std.Build.Step {
+ const run_tidy = b.addSystemCommand(&.{
+ "tidy", "--drop-empty-elements", "no", "-qe",
+ });
+ run_tidy.addFileArg(html_file);
+ run_tidy.expectExitCode(0);
+ return &run_tidy.step;
+}