Skip to content

Commit 1c3efc6

Browse files
Add new rustdoc book chapter to describe in-doc settings
1 parent 21fab43 commit 1c3efc6

File tree

5 files changed

+66
-6
lines changed

5 files changed

+66
-6
lines changed

src/doc/rustdoc/src/SUMMARY.md

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
- [What is rustdoc?](what-is-rustdoc.md)
44
- [Command-line arguments](command-line-arguments.md)
55
- [How to read rustdoc output](how-to-read-rustdoc.md)
6+
- [In-doc settings](read-documentation/in-doc-settings.md)
67
- [How to write documentation](how-to-write-documentation.md)
78
- [What to include (and exclude)](write-documentation/what-to-include.md)
89
- [The `#[doc]` attribute](write-documentation/the-doc-attribute.md)

src/doc/rustdoc/src/how-to-read-rustdoc.md

+1-6
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ Typing in the search bar instantly searches the available documentation for
6868
the string entered with a fuzzy matching algorithm that is tolerant of minor
6969
typos.
7070

71-
By default, the search results give are "In Names",
71+
By default, the search results given are "In Names",
7272
meaning that the fuzzy match is made against the names of items.
7373
Matching names are shown on the left, and the first few words of their
7474
descriptions are given on the right.
@@ -105,11 +105,6 @@ will match these queries:
105105

106106
But it *does not* match `Result<Vec, u8>` or `Result<u8<Vec>>`.
107107

108-
### Changing displayed theme
109-
110-
You can change the displayed theme by opening the settings menu (the gear
111-
icon in the upper right) and then pick a new one from there.
112-
113108
### Shortcuts
114109

115110
Pressing `S` while focused elsewhere on the page will move focus to the
Loading
Loading
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# Rustdoc in-doc settings
2+
3+
Rustdoc's HTML output includes a settings menu, and this chapter describes what
4+
each setting in this menu does.
5+
6+
It can be accessed by clicking on the gear button
7+
(<i class="fa fa-cog" aria-hidden="true"></i>) in the upper right.
8+
9+
## Changing displayed theme
10+
11+
It is possible to change the theme. If you pick the "system preference", you
12+
will be able to see two new sub-menus: "Preferred light theme" and "Preferred
13+
dark theme". It means that if your system preference is set to "light", then
14+
rustdoc will use the theme you selected in "Preferred light theme".
15+
16+
## Auto-hide item contents for large items
17+
18+
If the type definition contains more than 12 items, and this setting is enabled,
19+
it'll collapse them by default. You can see them by clicking on the `[+]` button
20+
to expand them.
21+
22+
A good example of this setting in use can be seen in the
23+
[`Iterator`](https://doc.rust-lang.org/stable/std/iter/trait.Iterator.html) doc
24+
page:
25+
26+
![Collapsed long item](../images/collapsed-long-item.png)
27+
28+
## Auto-hide item methods' documentation
29+
30+
If enabled, this setting will collapse all trait implementations blocks. It is
31+
convenient if you just want an overview of all the methods available. You can
32+
still see a method's documentation by expanding it.
33+
34+
## Auto-hide trait implementation documentation
35+
36+
If enabled, this setting will collapse all trait implementations blocks (you can
37+
see them in the "Trait Implementations" section). It is convenient if you just
38+
want an overview of all the trait implemented on a type. You can still see
39+
a trait implementation's associated items by expanding it.
40+
41+
Example:
42+
43+
![Collapsed trait implementations](../images/collapsed-trait-impls.png)
44+
45+
## Directly go to item in search if there is only one result
46+
47+
If this setting is enabled, you will directly be taken to the result page if
48+
your search only returned one element. Useful if you know exactly what you're
49+
looking for and want to be taken there directly and not waste time selecting the
50+
only search result.
51+
52+
## Show line numbers on code examples
53+
54+
If enabled, this setting will add line numbers to the code examples in the
55+
documentation. It provides a visual aide for the code reading.
56+
57+
## Disable keyboard shortcuts
58+
59+
If this setting is enabled, the keyboard shortcuts will be disabled. It's useful
60+
in case some of these shortcuts are already used by a web extension you're
61+
using.
62+
63+
To see the full list of the rustdoc keyboard shortcuts, you can open the help
64+
menu (the button with the question mark on the left of the setting menu button).

0 commit comments

Comments
 (0)