Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit d829fee

Browse files
Add documentation for custom_code_classes_in_docs feature
1 parent f556184 commit d829fee

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

src/doc/rustdoc/src/unstable-features.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -625,3 +625,32 @@ and check the values of `feature`: `foo` and `bar`.
625625

626626
This flag enables the generation of links in the source code pages which allow the reader
627627
to jump to a type definition.
628+
629+
### Custom CSS classes for code blocks
630+
631+
```rust
632+
#![feature(custom_code_classes_in_docs)]
633+
634+
/// ```{class=language-c}
635+
/// int main(void) { return 0; }
636+
/// ```
637+
pub struct Bar;
638+
```
639+
640+
The text `int main(void) { return 0; }` is rendered without highlighting in a code block
641+
with the class `language-c`. This can be used to highlight other languages through JavaScript
642+
libraries for example.
643+
644+
To be noted that you can replace `class=` with `.` to achieve the same result:
645+
646+
```rust
647+
#![feature(custom_code_classes_in_docs)]
648+
649+
/// ```{.language-c}
650+
/// int main(void) { return 0; }
651+
/// ```
652+
pub struct Bar;
653+
```
654+
655+
To be noted, `rust` and `.rust`/`class=rust` have different effects: `rust` indicates that this is
656+
a Rust code block whereas the two others add a "rust" CSS class on the code block.

0 commit comments

Comments
 (0)