How did slint create custom syntax highlight, link, and preview for their code examples?

Link: slint::docs::langref - Rust

The slint code snippets have custom syntax highlight (I doubt rustdoc recognize this language by default), an edit link, and a preview image (which does not seem to work).

I also checked langref.md on their GitHub repo but saw nothing special.

source

1 Like

As far as I know, docs.rs automatically generates documentation when a new crate is published to crates.io. How did slint devs pass --html-in-header to the command line if they don't control the command line?

The crate's Cargo.toml file contains these lines:

[package.metadata.docs.rs]
rustdoc-args = [
  "--html-in-header",
  "docs/resources/slint-docs-preview.html",
  "--html-in-header",
  "docs/resources/slint-docs-highlight.html",
]
features = ["document-features", "log"]

docs.rs documents the options supported in package.metadata.docs.rs.

2 Likes

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.