From 651225c2d4d86c661dba134eee2e3af421bf04b0 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Sun, 16 Jun 2024 20:03:14 -0700 Subject: [PATCH 1/2] 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. --- build.zig | 18 ++++++++++++++++++ ci/aarch64-linux-debug.sh | 7 ++----- ci/aarch64-linux-release.sh | 7 ++----- ci/x86_64-linux-debug.sh | 7 ++----- ci/x86_64-linux-release.sh | 7 ++----- 5 files changed, 26 insertions(+), 20 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; +} diff --git a/ci/aarch64-linux-debug.sh b/ci/aarch64-linux-debug.sh index 785a94f502..7a7ae5e4b3 100644 --- a/ci/aarch64-linux-debug.sh +++ b/ci/aarch64-linux-debug.sh @@ -61,11 +61,8 @@ stage3-debug/bin/zig build test docs \ -Dstatic-llvm \ -Dtarget=native-native-musl \ --search-prefix "$PREFIX" \ - --zig-lib-dir "$PWD/../lib" - -# Look for HTML errors. -# TODO: move this to a build.zig flag (-Denable-tidy) -tidy --drop-empty-elements no -qe "../zig-out/doc/langref.html" + --zig-lib-dir "$PWD/../lib" \ + -Denable-tidy # Ensure that updating the wasm binary from this commit will result in a viable build. stage3-debug/bin/zig build update-zig1 diff --git a/ci/aarch64-linux-release.sh b/ci/aarch64-linux-release.sh index 64d750324e..04d4fb20b8 100644 --- a/ci/aarch64-linux-release.sh +++ b/ci/aarch64-linux-release.sh @@ -61,11 +61,8 @@ stage3-release/bin/zig build test docs \ -Dstatic-llvm \ -Dtarget=native-native-musl \ --search-prefix "$PREFIX" \ - --zig-lib-dir "$PWD/../lib" - -# Look for HTML errors. -# TODO: move this to a build.zig flag (-Denable-tidy) -tidy --drop-empty-elements no -qe "../zig-out/doc/langref.html" + --zig-lib-dir "$PWD/../lib" \ + -Denable-tidy # Ensure that updating the wasm binary from this commit will result in a viable build. stage3-release/bin/zig build update-zig1 diff --git a/ci/x86_64-linux-debug.sh b/ci/x86_64-linux-debug.sh index 28ac21334d..2ec21566e1 100755 --- a/ci/x86_64-linux-debug.sh +++ b/ci/x86_64-linux-debug.sh @@ -69,11 +69,8 @@ stage3-debug/bin/zig build test docs \ -Dstatic-llvm \ -Dtarget=native-native-musl \ --search-prefix "$PREFIX" \ - --zig-lib-dir "$PWD/../lib" - -# Look for HTML errors. -# TODO: move this to a build.zig flag (-Denable-tidy) -tidy --drop-empty-elements no -qe "../zig-out/doc/langref.html" + --zig-lib-dir "$PWD/../lib" \ + -Denable-tidy # Ensure that updating the wasm binary from this commit will result in a viable build. stage3-debug/bin/zig build update-zig1 diff --git a/ci/x86_64-linux-release.sh b/ci/x86_64-linux-release.sh index a5d5434a72..97257eb3b5 100755 --- a/ci/x86_64-linux-release.sh +++ b/ci/x86_64-linux-release.sh @@ -69,11 +69,8 @@ stage3-release/bin/zig build test docs \ -Dstatic-llvm \ -Dtarget=native-native-musl \ --search-prefix "$PREFIX" \ - --zig-lib-dir "$PWD/../lib" - -# Look for HTML errors. -# TODO: move this to a build.zig flag (-Denable-tidy) -tidy --drop-empty-elements no -qe "../zig-out/doc/langref.html" + --zig-lib-dir "$PWD/../lib" \ + -Denable-tidy # Ensure that stage3 and stage4 are byte-for-byte identical. stage3-release/bin/zig build \ From 1e9e29398a8e35917fd044f21b7cd0ab7394e5fb Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Mon, 17 Jun 2024 00:09:40 -0700 Subject: [PATCH 2/2] disable tidy validation for autodocs tidy gives a false positive: line 304 column 9 - Warning: moved