-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Doctests in markdown should have a way to run in edition 2018 #52623
Comments
Maybe related depending on how it’s implemented, some crates may want to provide examples in a different edition to what they use, so being able to override the edition on an example by example basis could be useful. |
I had some ideas about this, then proceeded to open a new issue for it before realizing i left this link in my notes. 🤦♀️ Here's what i wrote up in that other issue: Right now, doctests will compile in the edition that the rest of the crate is set for. (Presumably, you can pass an edition for standalone markdown files, but i dunno whether mdbook will let you do that easily.) However, if you specifically want to show off how your crate interacts in various editions, there's no way to do that right now. It would be cool if we had a way to set an cc @rust-lang/rustdoc (when i get a moment, i'll set up some mentoring instructions...) |
(One Month Later...) Rustdoc parses out code block commands in (Since the Once you have the edition loaded, that And that's it! We'll probably want to add a test or two that exercises this, too. Rustdoc tests live in a few places, but we'll probably want to add one in For more information on the layout of rustdoc's code and how to build/run/test it, check out the rustdoc chapter of the Guide to Rustc Development. |
We'll want to stabilize this shortly so we can probably not bother too much with this. |
Aha, that makes this easier, then. It's not too much bother to add it here - the nightly check is already available - but yeah, it'll need to be stabilized soon enough. Bonus points: I would personally like to see the edition used in our tooltips, like the ones we have for |
I'd like to take a stab at this tomorrow or the day after :) |
I can add the tooltip if needed. |
@Munksgaard Still want to work on this? Since it's an edition feature i'd like to get it in soon-ish so we can get some eyes on it. |
Yes, sorry I've been silent. I've got the basic functionality working, but I've still to write some tests and get the banner up and running. I plan on getting the tests finished today, and then I hope to tackle the banner tomorrow. Should I create a PR, even though I'm not done? You can see my first commit here: Munksgaard@b94d38b |
@Munksgaard No worries. If you're working on it now, then i won't push it more. If you have trouble getting the banner together, open the PR without it and @GuillaumeGomez can put it in afterward. In fact, if you want us to take a look and provide more tips with your code, you can open the PR and put "WIP" in the title if you want us to use github's review tools. |
Opening a PR would actually make the review easier and allow us to remain more or less up-to-date. ;) |
…est, r=steveklabnik Support specifying edition in doc test Fixes rust-lang#52623 r? @QuietMisdreavus
I was working on
try{}
, which is 2018-only, so needed to disable the unstable book doctest for it since I couldn't find a way to run it in 2018: https://github.com/rust-lang/rust/pull/52602/files#diff-61f80654219faf8a22cb14554f6a9ae0R12This would presumably also be useful for the edition guide, which is currently
ignore
ing most of its doctests, which has let typos slip in (like rust-lang/edition-guide#30).The text was updated successfully, but these errors were encountered: