Skip to content

Invalid default-theme and preferred-dark-theme now cause an error - #3141

Merged
GuillaumeGomez merged 3 commits into
rust-lang:mainfrom
hollow-owl:invalid-default-theme
Sep 7, 2026
Merged

GuillaumeGomez merged 3 commits into
rust-lang:mainfrom
hollow-owl:invalid-default-theme

Conversation

@hollow-owl

Copy link
Copy Markdown
Contributor

This causes building to fail if default-theme or preferred-dark-theme is not one of the built-in themes.

If book.toml has an invalid default-theme:

mdbook build outputs an error saying why:

 INFO Book building has started
 INFO Running the html backend
ERROR Failed to deserialize `output.html`
        Caused by: unknown variant `does-not-exist`, expected one of `ayu`, `coal`, `light`, `navy`, `rust`
in `default-theme`

 INFO HTML book written to `/scratch/book`

Fixes #3140

@rustbot rustbot added the S-waiting-on-review Status: waiting on a review label Jun 20, 2026

@Chocorean Chocorean left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The string config for default-themes is now replaced by an enum, and deser of the config now fails on an unknown value.
The list of available themes is now injected into the view rather than hardcoded.
The documentation is updated, and a few tests are added to config.

Seems good to go!

View changes since this review

Comment thread crates/mdbook-core/src/config.rs Outdated

@GuillaumeGomez GuillaumeGomez left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small code improvement nit but otherwise looks good to me!

View changes since this review

@rustbot rustbot added S-waiting-on-author Status: The marked PR is awaiting some action (such as code changes) from the PR author. and removed S-waiting-on-review Status: waiting on a review labels Sep 2, 2026
@rustbot

rustbot commented Sep 2, 2026

Copy link
Copy Markdown
Collaborator

Reminder, once the PR becomes ready for a review, use @rustbot ready.

@hollow-owl

Copy link
Copy Markdown
Contributor Author

@rustbot ready

@rustbot rustbot added S-waiting-on-review Status: waiting on a review and removed S-waiting-on-author Status: The marked PR is awaiting some action (such as code changes) from the PR author. labels Sep 7, 2026
@GuillaumeGomez

GuillaumeGomez commented Sep 7, 2026 •

Copy link
Copy Markdown
Member

Looks good to me, thanks! One last thing remain to be added: a ui test to check the book building fails. However we don't have such a testsuite currently. Do you want to add it or are you ok with me pushing a commit in your PR adding this testsuite? We actually do have a way to check ui, shame on me for forgetting.

Comment thread tests/testsuite/theme.rs Outdated
@hollow-owl
hollow-owl force-pushed the invalid-default-theme branch from f815708 to eab9ae4 Compare September 7, 2026 16:40
@GuillaumeGomez

Copy link
Copy Markdown
Member

Looks all good to me, thanks!

@GuillaumeGomez
GuillaumeGomez added this pull request to the merge queue Sep 7, 2026
Merged via the queue into rust-lang:main with commit 4fb9ea9 Sep 7, 2026
19 checks passed
@rustbot rustbot removed the S-waiting-on-review Status: waiting on a review label Sep 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Invalid theme causes Rendering failed, but an invalid default-theme does not

4 participants