<feed xmlns='http://www.w3.org/2005/Atom'>
<title>rust/tests/rustdoc-ui/issues/issue-91713.stdout, branch master</title>
<subtitle>https://github.com/rust-lang/rust
</subtitle>
<id>http://git.dreamy.place/mirrors/rust/atom?h=master</id>
<link rel='self' href='http://git.dreamy.place/mirrors/rust/atom?h=master'/>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/'/>
<updated>2025-09-29T16:08:51+00:00</updated>
<entry>
<title>Move doc cfg propagation pass before items stripping passes</title>
<updated>2025-09-29T16:08:51+00:00</updated>
<author>
<name>Guillaume Gomez</name>
<email>guillaume1.gomez@gmail.com</email>
</author>
<published>2025-09-29T12:27:21+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=06a6dcd4d276826a7600302c08a0d448e23c1d33'/>
<id>urn:sha1:06a6dcd4d276826a7600302c08a0d448e23c1d33</id>
<content type='text'>
</content>
</entry>
<entry>
<title>Rework `#[doc(cfg(..))]` checks as distinct pass in rustdoc</title>
<updated>2025-05-29T19:50:14+00:00</updated>
<author>
<name>Urgau</name>
<email>urgau@numericable.fr</email>
</author>
<published>2025-05-29T19:50:14+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=9d0845a78209ba78798d9c93fabda967167d7da2'/>
<id>urn:sha1:9d0845a78209ba78798d9c93fabda967167d7da2</id>
<content type='text'>
</content>
</entry>
<entry>
<title>rustdoc: rewrite stability inheritance as a pass</title>
<updated>2024-09-30T21:58:18+00:00</updated>
<author>
<name>Lukas Markeffsky</name>
<email>@</email>
</author>
<published>2024-09-30T01:20:17+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=cd31b3acb3c963aff8d226030ac02379d741f3bd'/>
<id>urn:sha1:cd31b3acb3c963aff8d226030ac02379d741f3bd</id>
<content type='text'>
</content>
</entry>
<entry>
<title>Auto merge of #124577 - GuillaumeGomez:stabilize-custom_code_classes_in_docs, r=rustdoc</title>
<updated>2024-06-01T10:18:01+00:00</updated>
<author>
<name>bors</name>
<email>bors@rust-lang.org</email>
</author>
<published>2024-06-01T10:18:01+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=05965ae238403d8c141170b411245a62aa046240'/>
<id>urn:sha1:05965ae238403d8c141170b411245a62aa046240</id>
<content type='text'>
Stabilize `custom_code_classes_in_docs` feature

Fixes #79483.

This feature has been around for quite some time now, I think it's fine to stabilize it now.

## Summary

## What is the feature about?

In short, this PR changes two things, both related to codeblocks in doc comments in Rust documentation:

 * Allow to disable generation of `language-*` CSS classes with the `custom` attribute.
 * Add your own CSS classes to a code block so that you can use other tools to highlight them.

#### The `custom` attribute

Let's start with the new `custom` attribute: it will disable the generation of the `language-*` CSS class on the generated HTML code block. For example:

```rust
/// ```custom,c
/// int main(void) {
///     return 0;
/// }
/// ```
```

The generated HTML code block will not have `class="language-c"` because the `custom` attribute has been set. The `custom` attribute becomes especially useful with the other thing added by this feature: adding your own CSS classes.

#### Adding your own CSS classes

The second part of this feature is to allow users to add CSS classes themselves so that they can then add a JS library which will do it (like `highlight.js` or `prism.js`), allowing to support highlighting for other languages than Rust without increasing burden on rustdoc. To disable the automatic `language-*` CSS class generation, you need to use the `custom` attribute as well.

This allow users to write the following:

```rust
/// Some code block with `{class=language-c}` as the language string.
///
/// ```custom,{class=language-c}
/// int main(void) {
///     return 0;
/// }
/// ```
fn main() {}
```

This will notably produce the following HTML:

```html
&lt;pre class="language-c"&gt;
int main(void) {
    return 0;
}&lt;/pre&gt;
```

Instead of:

```html
&lt;pre class="rust rust-example-rendered"&gt;
&lt;span class="ident"&gt;int&lt;/span&gt; &lt;span class="ident"&gt;main&lt;/span&gt;(&lt;span class="ident"&gt;void&lt;/span&gt;) {
    &lt;span class="kw"&gt;return&lt;/span&gt; &lt;span class="number"&gt;0&lt;/span&gt;;
}
&lt;/pre&gt;
```

To be noted, we could have written `{.language-c}` to achieve the same result. `.` and `class=` have the same effect.

One last syntax point: content between parens (`(like this)`) is now considered as comment and is not taken into account at all.

In addition to this, I added an `unknown` field into `LangString` (the parsed code block "attribute") because of cases like this:

```rust
/// ```custom,class:language-c
/// main;
/// ```
pub fn foo() {}
```

Without this `unknown` field, it would generate in the DOM: `&lt;pre class="language-class:language-c language-c"&gt;`, which is quite bad. So instead, it now stores all unknown tags into the `unknown` field and use the first one as "language". So in this case, since there is no unknown tag, it'll simply generate `&lt;pre class="language-c"&gt;`. I added tests to cover this.

EDIT(camelid): This description is out-of-date. Using `custom,class:language-c` will generate the output `&lt;pre class="language-class:language-c"&gt;` as would be expected; it treats `class:language-c` as just the name of a language (similar to the langstring `c` or `js` or what have you) since it does not use the designed class syntax.

Finally, I added a parser for the codeblock attributes to make it much easier to maintain. It'll be pretty easy to extend.

As to why this syntax for adding attributes was picked: it's [Pandoc's syntax](https://pandoc.org/MANUAL.html#extension-fenced_code_attributes). Even if it seems clunkier in some cases, it's extensible, and most third-party Markdown renderers are smart enough to ignore Pandoc's brace-delimited attributes (from [this comment](https://github.com/rust-lang/rust/pull/110800#issuecomment-1522044456)).

r? `@notriddle`
</content>
</entry>
<entry>
<title>Always hide private fields in aliased type</title>
<updated>2024-05-11T11:11:46+00:00</updated>
<author>
<name>Urgau</name>
<email>urgau@numericable.fr</email>
</author>
<published>2024-05-09T17:58:10+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=e89a2cc8957c1e3f3f8ba7190d7c993a15955999'/>
<id>urn:sha1:e89a2cc8957c1e3f3f8ba7190d7c993a15955999</id>
<content type='text'>
</content>
</entry>
<entry>
<title>Stabilize `custom_code_classes_in_docs` feature</title>
<updated>2024-05-01T14:45:27+00:00</updated>
<author>
<name>Guillaume Gomez</name>
<email>guillaume.gomez@huawei.com</email>
</author>
<published>2024-05-01T13:24:32+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=2f6abd190da3dba44058253cbbfdb900906ef1b6'/>
<id>urn:sha1:2f6abd190da3dba44058253cbbfdb900906ef1b6</id>
<content type='text'>
</content>
</entry>
<entry>
<title>Add tests for `custom_code_classes_in_docs` feature</title>
<updated>2023-09-15T19:32:28+00:00</updated>
<author>
<name>Guillaume Gomez</name>
<email>guillaume.gomez@huawei.com</email>
</author>
<published>2023-04-25T13:04:46+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=f5561842e3dfc9adc8da4ba12b95514da4d99f00'/>
<id>urn:sha1:f5561842e3dfc9adc8da4ba12b95514da4d99f00</id>
<content type='text'>
</content>
</entry>
<entry>
<title>Move some rustdoc-ui tests to subdirectories</title>
<updated>2023-04-29T16:36:19+00:00</updated>
<author>
<name>jyn</name>
<email>github@jyn.dev</email>
</author>
<published>2023-04-29T09:08:33+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=5fa975142f98939222e12e8ca1338185cc7feb1c'/>
<id>urn:sha1:5fa975142f98939222e12e8ca1338185cc7feb1c</id>
<content type='text'>
</content>
</entry>
</feed>
