Include images in rustdoc output

Hi rustaceans!

Images in documentation can be really useful to provide some insight on algorithms or modules organisation.

It is already possible to insert a link to an image in documentation comment

/// ![Alt version](url://for/this/image.png)

But using this method, we only get to include images already available in some place of Internet.

Is it a way to make rustdoc copy some files to the target/doc folder, so that it is easy to include specific images in the documentation? The same could go for other static files, like specific CSS or JS.

Is it possible yet? If not, do you think it is worth it?

5 Likes

Bump on this. Would be nice to have.

Is there an issue for this on github? (for static files in general?)

For simplot docs. I use doctests to generate and output the images in the target/doc folder. Then just use a relative link to display the image.

That way cargo test and cargo doc gives me documentation with images.

1 Like

Is there an issue for this on github? (for static files in general?)

I don't think so.

For simplot2 docs. I use doctests to generate and output4 the images in the target/doc folder. Then just use a relative link1 to display the image.

That's a nice hack! I think I'll try it for my needs.

Yeah that is a nice hack but it would be nice if there was a more "supported" way to include images as well.

Added issue over here https://github.com/rust-lang/rust/issues/32104

3 Likes