Skip to content

Log deprecated config options at INFO so they don't fail strict mode - #102

Merged
shenxianpeng merged 2 commits into
mainfrom
fix/deprecated-option-info
Sep 24, 2026
Merged

shenxianpeng merged 2 commits into
mainfrom
fix/deprecated-option-info

Conversation

@shenxianpeng

Copy link
Copy Markdown
Member

Using a deprecated configuration option reported a WARNING, so strict builds failed even though the option was harmless. Since 1.8.0 deprecated google_analytics, sites that still set it can no longer build in strict mode after upgrading. Deprecated options of plugins (declared with config_options.Deprecated) had the same effect.

Fix:

  • Deprecated now reports its message as a DeprecationNotice — a str subclass, so code that inspects the warnings returned by Config.validate() keeps working unchanged.
  • The notice survives the prefixes added for sub-configs and plugins (Sub-option '…': , Plugin '…' option '…': ) via a small prefix_warning() helper.
  • load_config logs notices at INFO level and doesn't count them towards strict mode.

Removed options (removed=True) are still an error, and all other config warnings (e.g. unrecognised options) still fail strict builds.

$ mkdocs build --strict   # mkdocs.yml sets google_analytics
INFO    -  Config value 'google_analytics': The configuration option google_analytics is deprecated ...
INFO    -  Documentation built in 0.05 seconds

Related Issue

No issue in this repository.

Checklist

  • New tests added for new behavior (if applicable)
  • Documentation updated (if applicable)
  • Release notes docs/about/release-notes.md updated (if applicable)

🤖 Generated with Claude Code

shenxianpeng and others added 2 commits September 24, 2026 11:49
Using a deprecated configuration option reported a WARNING, so `strict`
builds failed even though the option was harmless. Since 1.8.0 deprecated
`google_analytics`, sites that still set it could no longer build in
strict mode after upgrading. Deprecated options of plugins had the same
effect.

`Deprecated` now reports a `DeprecationNotice`, a `str` subclass that
travels through the existing config warning lists (including the prefixes
added for sub-configs and plugins). `load_config` logs these notices at
INFO level and doesn't count them towards strict mode. Removed options are
still an error, and all other config warnings still fail strict builds.

Co-Authored-By: Claude <[email protected]>
@github-actions github-actions Bot added the bug Something isn't working label Sep 24, 2026
@shenxianpeng
shenxianpeng merged commit 7c41de6 into main Sep 24, 2026
22 checks passed
@shenxianpeng
shenxianpeng deleted the fix/deprecated-option-info branch September 24, 2026 09:08
@codspeed

codspeed Bot commented Sep 24, 2026

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

✅ 28 untouched benchmarks


Comparing fix/deprecated-option-info (3eff93f) with main (bd084e4)

Open in CodSpeed

This was referenced Oct 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant