diff options
| author | Guillaume Gomez <guillaume.gomez@huawei.com> | 2023-04-25 16:37:43 +0200 |
|---|---|---|
| committer | Guillaume Gomez <guillaume.gomez@huawei.com> | 2023-09-15 21:32:28 +0200 |
| commit | d829fee6b5859de516dadaaba30db758bb567268 (patch) | |
| tree | 001e3f4a0c2dd0e5f63e6b32f3e4532088490fe7 | |
| parent | f5561842e3dfc9adc8da4ba12b95514da4d99f00 (diff) | |
| download | rust-d829fee6b5859de516dadaaba30db758bb567268.tar.gz rust-d829fee6b5859de516dadaaba30db758bb567268.zip | |
Add documentation for `custom_code_classes_in_docs` feature
| -rw-r--r-- | src/doc/rustdoc/src/unstable-features.md | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/doc/rustdoc/src/unstable-features.md b/src/doc/rustdoc/src/unstable-features.md index f69156b7c05..bb62a0bc9cc 100644 --- a/src/doc/rustdoc/src/unstable-features.md +++ b/src/doc/rustdoc/src/unstable-features.md @@ -625,3 +625,32 @@ and check the values of `feature`: `foo` and `bar`. This flag enables the generation of links in the source code pages which allow the reader to jump to a type definition. + +### Custom CSS classes for code blocks + +```rust +#![feature(custom_code_classes_in_docs)] + +/// ```{class=language-c} +/// int main(void) { return 0; } +/// ``` +pub struct Bar; +``` + +The text `int main(void) { return 0; }` is rendered without highlighting in a code block +with the class `language-c`. This can be used to highlight other languages through JavaScript +libraries for example. + +To be noted that you can replace `class=` with `.` to achieve the same result: + +```rust +#![feature(custom_code_classes_in_docs)] + +/// ```{.language-c} +/// int main(void) { return 0; } +/// ``` +pub struct Bar; +``` + +To be noted, `rust` and `.rust`/`class=rust` have different effects: `rust` indicates that this is +a Rust code block whereas the two others add a "rust" CSS class on the code block. |
