[rustdoc] Wrap code blocks in <code> tag This PR modifies Rustdoc output so that fenced code snippets, items and whole file source codes are wrapped in `<pre><code>` instead of just `<pre>`. This should improve the semantic meaning of the generated content. I'm not sure what to do about `render_attributes_in_pre` and `render_attributes_in_code`. These functions were clearly expected to be used for things inside `<pre>` or `<code>`, and since I added `<code>` in this PR, some of them will be used in a different context than before. However, it seems to me that even before they were not consistent. For example, `item_constant` used `render_attributes_in_code` for its attributes, however there was no `<code>` used for constants before this PR... Should I create some `rustdoc-gui` tests? For example to check that all `<pre>` tags have a `<code>` child? Fixes: https://github.com/rust-lang/rust/issues/88020 |
||
|---|---|---|
| .. | ||
| src | ||
| auto-hide-trait-implementations.goml | ||
| ayu-code-tag-colors.goml | ||
| basic-code.goml | ||
| basic.goml | ||
| check_info_sign_position.goml | ||
| code-blocks-overflow.goml | ||
| code-sidebar-toggle.goml | ||
| code-tags.goml | ||
| default-settings.goml | ||
| docblock-table-overflow.goml | ||
| escape-key.goml | ||
| font-weight.goml | ||
| hash-item-expansion.goml | ||
| headers-color.goml | ||
| impl-default-expansion.goml | ||
| implementors.goml | ||
| item-info-width.goml | ||
| item-summary-table.goml | ||
| label-next-to-symbol.goml | ||
| list_code_block.goml | ||
| module-items-font.goml | ||
| README.md | ||
| search-filter.goml | ||
| search-input-mobile.goml | ||
| search-result-color.goml | ||
| search-result-colors.goml | ||
| search-result-description.goml | ||
| search-result-display.goml | ||
| search-result-go-to-first.goml | ||
| search-result-keyword.goml | ||
| search-tab-selection-if-current-is-empty.goml | ||
| shortcuts.goml | ||
| sidebar-mobile.goml | ||
| sidebar.goml | ||
| source-code-page.goml | ||
| theme-change.goml | ||
| toggle-docs-mobile.goml | ||
| toggle-docs.goml | ||
| toggled-open-implementations.goml | ||
| trait-sidebar-item-order.goml | ||
| type-declation-overflow.goml | ||
The tests present here are used to test the generated HTML from rustdoc. The goal is to prevent unsound/unexpected GUI changes.
This is using the browser-ui-test framework to do so. It works as follows:
It wraps puppeteer to send commands to a web browser in order to navigate and test what's being currently displayed in the web page.
You can find more information and its documentation in its repository.
If you need to have more information on the tests run, you can use --test-args:
$ ./x.py test src/test/rustdoc-gui --stage 1 --jobs 8 --test-args --debug
There are three options supported:
--debug: allows to see puppeteer commands.--no-headless: disable headless mode so you can see what's going on.--show-text: by default, text isn't rendered because of issues with fonts, it enables it back.