Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.Sign up
Tracking Issue: Add rustc-guide to toolstate #59597
(According to the plan in rust-lang-nursery/rust-toolstate#5)
@kennytm Could you tag this with Help-Wanted?
Background: We have a cool tool called
Objective: Currently the rustc-guide is not tracked by toolstate, but we want it to be. This will help us detect when the compiler changes and the guide needs to be updated. However, some infrastructure work is needed for this to work.
Feel free to ping me on this thread if you need help :)
Hi there, is anyone working on this already? @mark-i-m
Anyway, I played with this for a bit,
I'm just not sure about how to add mdbook-linkcheck as dep. And if the changes above are enough. If they are, I'm happy to open the PR! My first to rust <3
Hi @andrehjr! You are the first person to work on this :) Thanks!
That looks like a great start, but it causes the entire compiler to be built before rustc-guide is tested, which is not necessary. Also, I’m not sure if actually tests rustc-guide or just libstd.
You will probably need to manually define RustcGuide and impl Step for it. I did a bit more digging, and I think such an implementation can look similar to the one for test::ErrorIndex, which also requires calling an external tool. Except in our case, we want to call a tool called rustbook, which calls mdbook (src/tools/rustbook/).
It looks like rustbook calls mdbook programmatically, so we might need to find a way to call mdbook-linkcheck programmatically too. My guess is that we will also need to add linkcheck as a dependency of rustbook somehow... If I have time tomorrow I can try to learn more, or if you are feeling adventurous feel free to explore :)
A quick note: it looks like you can use the linkchecker as a library: https://docs.rs/mdbook-linkcheck/0.2.3/mdbook_linkcheck/fn.check_links.html
My guess is that you can get the RenderContext from the mdbook crate, which is already imported in rustbook. So it looks like it should be possible to add a “linkcheck mode” to rustbook.
Feel free to ping me if you need anything :)
Hi @mark-i-m I played with it a bit more, I think I'm on the right track. Just need some refactoring :) And ensure everything is working as expected.
I was able to call the check_links programmatically passing a RenderContext from the md_book. Also note that mdbook-linkcheck only supports mdbook > 2.
I ended up adding a new subcommand on mdbook just for linkchecks, I can tweak it into the other command if needed.
Locally, I'm getting a few intermittent 'request timeouts' for a few links every now and then. Maybe it's just my internet connection.
I did not push Cargo.lock because it added a bunch of stuff from macOS, what can I do in those cases?
Also, it seems like when you 'build' the book it runs the linkcheck automatically if it's configured on book.toml.
The way I did here, it just loads up the book using mdbook and linkchecks it (without fully building it/generating .htmls)
@andrehjr Just took a look, and it looks good
Sorry, I forgot to mention this. Could you add in the command line description for the
There may also be some rate-limiting somewhere because I see failures every once in a while both on my laptop and on CI. I think it is probably ok for now. If it gets to be an issue later, we can do some deeper debugging.
It looks like those are transitive dependencies of
Yes, that is correct. On the rustc-guide repo, that is how we get Travis to run the linkchecker. In that case, we also want to build the book itself so that we can host it, but for toolstate, just linkchecking is fine.
Cool! I updated the command line description!
There's an issue when building rustbook on travisci: