Stream: rustdoc

Topic: Use different syntax highlighting for doc test


view this post on Zulip XAMPPRocky (Jun 22 2021 at 06:46):

Hey, is there a way to have rustdoc highlight using a different language syntax while still considering it a doc test? That might seem odd, but the use case I have is that we want to show configuration examples which are also validated when running cargo test.

See the following example, this will only show TOML in the generated documentation, but it will be highlighted as Rust code.

//! ```rust
//! # let data = r#"
//! key = "value"
//! [dependencies.serde]
//! optional = true
//! # ";
//! # toml::from_str::<Config>(data).unwrap();
//! ```

view this post on Zulip GuillaumeGomez (Jun 22 2021 at 08:20):

So, the basic answer is no. One thing which was suggested though was for the users to use a JS syntax highlighter on their own so they can modify the code blocks as they see fit.


Last updated: Oct 11 2021 at 22:34 UTC