authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2024-06-16 20:03:14-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2024-06-17 00:10:35-07:00
log651225c2d4d86c661dba134eee2e3af421bf04b0
tree35d4908e2e67384b5d2026d2c44358c99807e4ad
parentfda2458f6ac9c4f5ddc7d0fb70ab6194ce1adc47

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.

5 files changed, 26 insertions(+), 20 deletions(-)

build.zig+18
......@@ -31,10 +31,18 @@ pub fn build(b: *std.Build) !void {
3131 const skip_install_langref = b.option(bool, "no-langref", "skip copying of langref to the installation prefix") orelse skip_install_lib_files;
3232 const std_docs = b.option(bool, "std-docs", "include standard library autodocs") orelse false;
3333 const no_bin = b.option(bool, "no-bin", "skip emitting compiler binary") orelse false;
34 const enable_tidy = b.option(bool, "enable-tidy", "Check langref output HTML validity") orelse false;
3435
3536 const langref_file = generateLangRef(b);
3637 const install_langref = b.addInstallFileWithDir(langref_file, .prefix, "doc/langref.html");
38 const check_langref = tidyCheck(b, langref_file);
39 const check_autodocs = tidyCheck(b, b.path("lib/docs/index.html"));
40 if (enable_tidy) {
41 test_step.dependOn(check_langref);
42 test_step.dependOn(check_autodocs);
43 }
3744 if (!skip_install_langref) {
45 if (enable_tidy) install_langref.step.dependOn(check_langref);
3846 b.getInstallStep().dependOn(&install_langref.step);
3947 }
4048
......@@ -51,6 +59,7 @@ pub fn build(b: *std.Build) !void {
5159 .install_subdir = "doc/std",
5260 });
5361 if (std_docs) {
62 if (enable_tidy) install_std_docs.step.dependOn(check_autodocs);
5463 b.getInstallStep().dependOn(&install_std_docs.step);
5564 }
5665
......@@ -1308,3 +1317,12 @@ fn generateLangRef(b: *std.Build) std.Build.LazyPath {
13081317 docgen_cmd.addFileArg(b.path("doc/langref.html.in"));
13091318 return docgen_cmd.addOutputFileArg("langref.html");
13101319}
1320
1321fn tidyCheck(b: *std.Build, html_file: std.Build.LazyPath) *std.Build.Step {
1322 const run_tidy = b.addSystemCommand(&.{
1323 "tidy", "--drop-empty-elements", "no", "-qe",
1324 });
1325 run_tidy.addFileArg(html_file);
1326 run_tidy.expectExitCode(0);
1327 return &run_tidy.step;
1328}
ci/aarch64-linux-debug.sh+2-5
......@@ -61,11 +61,8 @@ stage3-debug/bin/zig build test docs \
6161 -Dstatic-llvm \
6262 -Dtarget=native-native-musl \
6363 --search-prefix "$PREFIX" \
64 --zig-lib-dir "$PWD/../lib"
65
66# Look for HTML errors.
67# TODO: move this to a build.zig flag (-Denable-tidy)
68tidy --drop-empty-elements no -qe "../zig-out/doc/langref.html"
64 --zig-lib-dir "$PWD/../lib" \
65 -Denable-tidy
6966
7067# Ensure that updating the wasm binary from this commit will result in a viable build.
7168stage3-debug/bin/zig build update-zig1
ci/aarch64-linux-release.sh+2-5
......@@ -61,11 +61,8 @@ stage3-release/bin/zig build test docs \
6161 -Dstatic-llvm \
6262 -Dtarget=native-native-musl \
6363 --search-prefix "$PREFIX" \
64 --zig-lib-dir "$PWD/../lib"
65
66# Look for HTML errors.
67# TODO: move this to a build.zig flag (-Denable-tidy)
68tidy --drop-empty-elements no -qe "../zig-out/doc/langref.html"
64 --zig-lib-dir "$PWD/../lib" \
65 -Denable-tidy
6966
7067# Ensure that updating the wasm binary from this commit will result in a viable build.
7168stage3-release/bin/zig build update-zig1
ci/x86_64-linux-debug.sh+2-5
......@@ -69,11 +69,8 @@ stage3-debug/bin/zig build test docs \
6969 -Dstatic-llvm \
7070 -Dtarget=native-native-musl \
7171 --search-prefix "$PREFIX" \
72 --zig-lib-dir "$PWD/../lib"
73
74# Look for HTML errors.
75# TODO: move this to a build.zig flag (-Denable-tidy)
76tidy --drop-empty-elements no -qe "../zig-out/doc/langref.html"
72 --zig-lib-dir "$PWD/../lib" \
73 -Denable-tidy
7774
7875# Ensure that updating the wasm binary from this commit will result in a viable build.
7976stage3-debug/bin/zig build update-zig1
ci/x86_64-linux-release.sh+2-5
......@@ -69,11 +69,8 @@ stage3-release/bin/zig build test docs \
6969 -Dstatic-llvm \
7070 -Dtarget=native-native-musl \
7171 --search-prefix "$PREFIX" \
72 --zig-lib-dir "$PWD/../lib"
73
74# Look for HTML errors.
75# TODO: move this to a build.zig flag (-Denable-tidy)
76tidy --drop-empty-elements no -qe "../zig-out/doc/langref.html"
72 --zig-lib-dir "$PWD/../lib" \
73 -Denable-tidy
7774
7875# Ensure that stage3 and stage4 are byte-for-byte identical.
7976stage3-release/bin/zig build \