-
Notifications
You must be signed in to change notification settings - Fork 13.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a cfail mode for doc comments #24565
Comments
👍 This would be great for documenting syntax extensions and such. |
I would like to work on this, if someone could mentor me, since this is my first ever contribution to a language / a project this big :) |
Happy to see your enthusiasm! I'm not familiar with this code, but @cmr and @alexcrichton , they should be able to give you some pointers. This might not be very easy, mind you, and it might require lots of changes to compiletest-rs. Note that compiletest-rs has been taken out of the tree unofficially here, so that implementation might give some pointers. (compiletest is the test runner for the stuff you find in |
@Manishearth Thank you for your super quick reply! I see. I guess it's probably a better idea if I start with some I was looking at |
Per my conversation with @aminb on IRC this change will be to rustdoc, which is responsible for all doc testing. |
Yeah; but I bet it will require some ctest changes too to hook them all up. |
Running cfail tests is currently all managed through the in-tree
Hope that helps! |
cc @gankro because of IRL OH |
So apparently rustdoc eats all leading % lines. We could in principle add rustdoc feature flags like % my title
% feature(cfail)
blha blah balh ablj |
Triage: no change. |
Update: Currently, rustdoc can handle doctests tagged with It's not quite what the issue is asking for (you can't match the error text), but it's somewhat there. |
@QuietMisdreavus: It's working on stable as well too normally. Unless I missed something? |
@GuillaumeGomez It should be nightly-only rust/src/librustdoc/html/markdown.rs Lines 912 to 917 in 59ccba9
|
Indeed, changing this: #43949. |
It's now in stable. I suppose we can close it. :) |
The basic "this test should not compile" is there, but the OP also asked for something like what |
Many times the docs mention an error message in non-compiling Rust code to illustrate a concept. For example, the move semantics chapter illustrates how moves can cause errors.
However, it's possible that the error message may update in the future, or that the code (which is marked as
rust,ignore
and doesn't get fed to the doctests) will fall prey to a different error. Both (especially the latter) can be confusing to a newbie.I propose we add a "cfail" mode to code blocks, which runs the code as a compile-fail test (via compiletest), and will fail the doctest if the error doesn't match. Something like this:
We could choose to make the inline error hidden, though it might actually be helpful and could be kept visible.
The text was updated successfully, but these errors were encountered: