mirror of
https://github.com/ziglang/zig.git
synced 2025-02-02 20:21:35 +00:00
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.
This commit is contained in:
parent
fda2458f6a
commit
651225c2d4
18
build.zig
18
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 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 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 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 langref_file = generateLangRef(b);
|
||||||
const install_langref = b.addInstallFileWithDir(langref_file, .prefix, "doc/langref.html");
|
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 (!skip_install_langref) {
|
||||||
|
if (enable_tidy) install_langref.step.dependOn(check_langref);
|
||||||
b.getInstallStep().dependOn(&install_langref.step);
|
b.getInstallStep().dependOn(&install_langref.step);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -51,6 +59,7 @@ pub fn build(b: *std.Build) !void {
|
|||||||
.install_subdir = "doc/std",
|
.install_subdir = "doc/std",
|
||||||
});
|
});
|
||||||
if (std_docs) {
|
if (std_docs) {
|
||||||
|
if (enable_tidy) install_std_docs.step.dependOn(check_autodocs);
|
||||||
b.getInstallStep().dependOn(&install_std_docs.step);
|
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"));
|
docgen_cmd.addFileArg(b.path("doc/langref.html.in"));
|
||||||
return docgen_cmd.addOutputFileArg("langref.html");
|
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;
|
||||||
|
}
|
||||||
|
@ -61,11 +61,8 @@ stage3-debug/bin/zig build test docs \
|
|||||||
-Dstatic-llvm \
|
-Dstatic-llvm \
|
||||||
-Dtarget=native-native-musl \
|
-Dtarget=native-native-musl \
|
||||||
--search-prefix "$PREFIX" \
|
--search-prefix "$PREFIX" \
|
||||||
--zig-lib-dir "$PWD/../lib"
|
--zig-lib-dir "$PWD/../lib" \
|
||||||
|
-Denable-tidy
|
||||||
# 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"
|
|
||||||
|
|
||||||
# Ensure that updating the wasm binary from this commit will result in a viable build.
|
# Ensure that updating the wasm binary from this commit will result in a viable build.
|
||||||
stage3-debug/bin/zig build update-zig1
|
stage3-debug/bin/zig build update-zig1
|
||||||
|
@ -61,11 +61,8 @@ stage3-release/bin/zig build test docs \
|
|||||||
-Dstatic-llvm \
|
-Dstatic-llvm \
|
||||||
-Dtarget=native-native-musl \
|
-Dtarget=native-native-musl \
|
||||||
--search-prefix "$PREFIX" \
|
--search-prefix "$PREFIX" \
|
||||||
--zig-lib-dir "$PWD/../lib"
|
--zig-lib-dir "$PWD/../lib" \
|
||||||
|
-Denable-tidy
|
||||||
# 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"
|
|
||||||
|
|
||||||
# Ensure that updating the wasm binary from this commit will result in a viable build.
|
# Ensure that updating the wasm binary from this commit will result in a viable build.
|
||||||
stage3-release/bin/zig build update-zig1
|
stage3-release/bin/zig build update-zig1
|
||||||
|
@ -69,11 +69,8 @@ stage3-debug/bin/zig build test docs \
|
|||||||
-Dstatic-llvm \
|
-Dstatic-llvm \
|
||||||
-Dtarget=native-native-musl \
|
-Dtarget=native-native-musl \
|
||||||
--search-prefix "$PREFIX" \
|
--search-prefix "$PREFIX" \
|
||||||
--zig-lib-dir "$PWD/../lib"
|
--zig-lib-dir "$PWD/../lib" \
|
||||||
|
-Denable-tidy
|
||||||
# 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"
|
|
||||||
|
|
||||||
# Ensure that updating the wasm binary from this commit will result in a viable build.
|
# Ensure that updating the wasm binary from this commit will result in a viable build.
|
||||||
stage3-debug/bin/zig build update-zig1
|
stage3-debug/bin/zig build update-zig1
|
||||||
|
@ -69,11 +69,8 @@ stage3-release/bin/zig build test docs \
|
|||||||
-Dstatic-llvm \
|
-Dstatic-llvm \
|
||||||
-Dtarget=native-native-musl \
|
-Dtarget=native-native-musl \
|
||||||
--search-prefix "$PREFIX" \
|
--search-prefix "$PREFIX" \
|
||||||
--zig-lib-dir "$PWD/../lib"
|
--zig-lib-dir "$PWD/../lib" \
|
||||||
|
-Denable-tidy
|
||||||
# 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"
|
|
||||||
|
|
||||||
# Ensure that stage3 and stage4 are byte-for-byte identical.
|
# Ensure that stage3 and stage4 are byte-for-byte identical.
|
||||||
stage3-release/bin/zig build \
|
stage3-release/bin/zig build \
|
||||||
|
Loading…
Reference in New Issue
Block a user