diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2024-06-16 20:03:14 -0700 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2024-06-17 00:10:35 -0700 |
| commit | 651225c2d4d86c661dba134eee2e3af421bf04b0 (patch) | |
| tree | 35d4908e2e67384b5d2026d2c44358c99807e4ad /build.zig | |
| parent | fda2458f6ac9c4f5ddc7d0fb70ab6194ce1adc47 (diff) | |
| download | zig-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.zig | 18 |
1 files changed, 18 insertions, 0 deletions
@@ -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; +} |
