diff options
| author | bors <bors@rust-lang.org> | 2019-11-18 19:03:21 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2019-11-18 19:03:21 +0000 |
| commit | 3e525e3f6d9e85d54fa4c49b52df85aa0c990100 (patch) | |
| tree | f33e407c05a06de415002ba3e778c585b7be71ac /src/doc | |
| parent | a0d40f8bdfcc3c28355467973f97fd4c45ac5876 (diff) | |
| parent | 45b83c9164c2462503c2cd381a4b1b85f75fa107 (diff) | |
| download | rust-3e525e3f6d9e85d54fa4c49b52df85aa0c990100.tar.gz rust-3e525e3f6d9e85d54fa4c49b52df85aa0c990100.zip | |
Auto merge of #54733 - GuillaumeGomez:stabilize-rustdoc-theme, r=ollie27,Dylan-DPC
Stabilize rustdoc theme options Closes #54730 This PR stabilizes the `--themes` (now `--theme`) and `--theme-checker` (now `--check-theme`) options, for allowing users to add custom themes to their documentation. Rustdoc includes two themes by default: `light` and `dark`. Using the `--theme` option, you can give rustdoc a CSS file to include as an extra theme for that render. Themes are named after the CSS file used, so using `--theme /path/to/your/custom-theme.css` will add a theme called `custom-theme` to the documentation. Even though the CLI flag to add a theme is getting stabilized, there's no guarantee that a theme file will always have the same effect on documentation generated with future versions of rustdoc. To aid in ensuring that a theme will work, the flag `--check-theme` is also available, which compares the CSS rules defined by a custom theme against the ones used in the `light` theme. If the `light` theme defines a CSS rule that the custom theme does not, rustdoc will report an error. (Rustdoc also performs this check for themes given to `--theme`, but only reports a warning when a difference is found.)
Diffstat (limited to 'src/doc')
| -rw-r--r-- | src/doc/rustdoc/src/command-line-arguments.md | 33 | ||||
| -rw-r--r-- | src/doc/rustdoc/src/unstable-features.md | 24 |
2 files changed, 32 insertions, 25 deletions
diff --git a/src/doc/rustdoc/src/command-line-arguments.md b/src/doc/rustdoc/src/command-line-arguments.md index b21defaedc3..2e32ce31eca 100644 --- a/src/doc/rustdoc/src/command-line-arguments.md +++ b/src/doc/rustdoc/src/command-line-arguments.md @@ -355,7 +355,38 @@ $ rustdoc src/lib.rs --edition 2018 $ rustdoc --test src/lib.rs --edition 2018 ``` -This flag allows rustdoc to treat your rust code as the given edition. It will compile doctests with +This flag allows `rustdoc` to treat your rust code as the given edition. It will compile doctests with the given edition as well. As with `rustc`, the default edition that `rustdoc` will use is `2015` (the first edition). +## `--theme`: add a theme to the documentation output + +Using this flag looks like this: + +```bash +$ rustdoc src/lib.rs --theme /path/to/your/custom-theme.css +``` + +`rustdoc`'s default output includes two themes: `light` (the default) and +`dark`. This flag allows you to add custom themes to the output. Giving a CSS +file to this flag adds it to your documentation as an additional theme choice. +The theme's name is determined by its filename; a theme file named +`custom-theme.css` will add a theme named `custom-theme` to the documentation. + +## `--check-theme`: verify custom themes against the default theme + +Using this flag looks like this: + +```bash +$ rustdoc --check-theme /path/to/your/custom-theme.css +``` + +While `rustdoc`'s HTML output is more-or-less consistent between versions, there +is no guarantee that a theme file will have the same effect. The `--theme` flag +will still allow you to add the theme to your documentation, but to ensure that +your theme works as expected, you can use this flag to verify that it implements +the same CSS rules as the official `light` theme. + +`--check-theme` is a separate mode in `rustdoc`. When `rustdoc` sees the +`--check-theme` flag, it discards all other flags and only performs the CSS rule +comparison operation. diff --git a/src/doc/rustdoc/src/unstable-features.md b/src/doc/rustdoc/src/unstable-features.md index f8be04a1087..a48526d39fd 100644 --- a/src/doc/rustdoc/src/unstable-features.md +++ b/src/doc/rustdoc/src/unstable-features.md @@ -294,30 +294,6 @@ some consideration for their stability, and names that end in a number). Giving `rustdoc` will disable this sorting and instead make it print the items in the order they appear in the source. -### `--themes`: provide additional themes - -Using this flag looks like this: - -```bash -$ rustdoc src/lib.rs -Z unstable-options --themes theme.css -``` - -Giving this flag to `rustdoc` will make it copy your theme into the generated crate docs and enable -it in the theme selector. Note that `rustdoc` will reject your theme file if it doesn't style -everything the "light" theme does. See `--theme-checker` below for details. - -### `--theme-checker`: verify theme CSS for validity - -Using this flag looks like this: - -```bash -$ rustdoc -Z unstable-options --theme-checker theme.css -``` - -Before including your theme in crate docs, `rustdoc` will compare all the CSS rules it contains -against the "light" theme included by default. Using this flag will allow you to see which rules are -missing if `rustdoc` rejects your theme. - ### `--resource-suffix`: modifying the name of CSS/JavaScript in crate docs Using this flag looks like this: |
