Open dtolnay opened 5 years ago
Would it be good to add hooks in rustdoc instead of adding these to another crate? If possible, I would like to help on this.
I think it would be substantially easier to experiment with this on its own outside of the main rustdoc codebase.
After there is a working product and it's something people like, we could start making a case for including it in rustdoc.
I would like to give this a shot, if it hasn't already been done
In the GitBook that backs https://serde.rs, I use several GitBook plugins, a few of which I wrote myself.
For example I have a plugin that lets me insert playground links into code blocks. Here is an invocation right from the homepage: markdown (shown below) and rendered here with the "Run" link.
I would be interested in having the same capability to run snippets of logic against my pre-rendered and post-rendered rustdoc. I would like to have a Cargo subcommand:
which forwards to
cargo doc
but executes plugins before (on the Markdown) and after (on the HTML).Plugins would be listed as metadata in Cargo.toml:
Plugins would be installed as ordinary binaries like
cargo install rustdoc-plugin-playground-links
. This project also involves developing the library for writing plugins. Mirroring the GitBook system, plugin code might look something like: