How do I modify `rustdoc` (the tool ran by `cargo doc`)

Note: I am still really new to rust, uncomfortable with the tools used internally by cargo, and the code of rustc in general.

I was trying to implement the RFC that I started to work on. I need to modify how documentation comments are parsed by cargo doc, as well as what is tested by cargo test. I was expecting to have to modify a few lines in rustc, build it with cargo build, then search for the generated binaries and somehow invoke them with cargo doc and cargo test inside a test crate that use the new syntax in the documentation comments that I implemented.

So the first step I did was to the guide to rustc development, especially the chapter on how to build and run.

Witch stage do I need? I only have 43 GB free on my SSD, and I wasn't expecting it to be not enough, but apparently I can't even build the full stage 1. Is stage 0 enough? I think I only need cargo, and rustdoc, so the following should be enough, isn't it?

./x.py build -i --stage 0 src/tools/cargo src/tools/rustdoc

The next step requires to use rustup. I'm on fedora 30, and urstup doesn't seems to be packaged. How do I create my toolchain? And how do I invoque it? Given that I just need to be able to generate the html documentation of a single test file, and rust the test on that file, if it is simpler to just invoque rustc directly, I am totally fine with this. I just don't know what cargo doc nor cargo test do internally.

Do I need to know anything more?

This should probably go on internals.rust-lang.org

I wasn't sure, I will open a new post there.

If someone search it in the future: https://internals.rust-lang.org/t/how-do-i-modify-rustdoc-the-tool-ran-by-cargo-doc/12074

1 Like

@alice: I asked on internals. This question should be asked here.

You were right.

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.