rules_rust icon indicating copy to clipboard operation
rules_rust copied to clipboard

feat: Add `capture_output` attr to `rust_doc` rule

Open ParkMyCar opened this issue 2 years ago • 4 comments

This PR adds a capture_output attr to the rust_doc rule, which if set to True will redirect the output of stderr into a file with the suffix of .rustdoc.out.

Adding this unlocks the ability for users to define a bazel test rule that asserts their docs build without warnings. This is useful because it allows you to semi-automate the process of making sure your docs are up to date.

ParkMyCar avatar Jul 26 '22 20:07 ParkMyCar

Hey @illicitonion, any chance you could review this PR too? No rush though :)

P.S. I tried to assign a reviewer but I don't seem to be able to

ParkMyCar avatar Aug 01 '22 15:08 ParkMyCar

Adding this unlocks the ability for users to define a bazel test rule that asserts their docs build without warnings. This is useful because it allows you to semi-automate the process of making sure your docs are up to date.

Does rustdoc really not have a flag to promote warnings to errors? It sounds like that's what you'd want instead of needing to parse a bunch of text in a bespoke action.

UebelAndre avatar Aug 03 '22 14:08 UebelAndre

Does rustdoc really not have a flag to promote warnings to errors? It sounds like that's what you'd want instead of needing to parse a bunch of text in a bespoke action.

It does, you can pass -Dwarnings to deny all warnings. The issue though is the rust_doc rule is not declared as a test rule, so even if your rustdoc build fails, running bazel test //rustdoc_target still passes.

I would love if there was a way to make a bazel test whose predicate is "test whether or not this other build target succeeds", but AFAICT there isn't.

ParkMyCar avatar Aug 05 '22 15:08 ParkMyCar

It does, you can pass -Dwarnings to deny all warnings. The issue though is the rust_doc rule is not declared as a test rule, so even if your rustdoc build fails, running bazel test //rustdoc_target still passes.

I would love if there was a way to make a bazel test whose predicate is "test whether or not this other build target succeeds", but AFAICT there isn't.

Don't build targets get built under bazel test //... unless you're using --build_tests_only? Also, if you want a build target to be guaranteed to run in a test, couldn't you use @bazel_skylib//rules:build_test.bzl?

UebelAndre avatar Aug 05 '22 15:08 UebelAndre