-
Notifications
You must be signed in to change notification settings - Fork 829
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Upcoming deprecation (+ breakage in your case) regarding custom templates for mkdocstrings #4453
Comments
I added a check that will log a warning when base templates are overridden, so at least your docs won't silently "break". |
Oh, just noticed you've pinned mkdocstrings-python anyway, so no need for a PR now. I'll close this issue but keep in it mind when you want to upgrade 😄 |
Don't forget to star the repository! Follow @textualizeio for Textual updates. |
Thanks for the heads up! |
Of course! Here's the PR in mkdocstrings-python, for reference: mkdocstrings/python#155 |
Hello 🙂
I've been working on the Python handler of mkdocstrings, renaming templates from
*.html
to*.html.jinja
as a quality of life improvement (syntax highlighting by default).The change is backward compatible: previous users who were overriding templates can continue overriding
*.html
templates instead of*.html.jinja
ones. They'll see an INFO log in MkDocs' output stating that this is deprecated and that the message will be a warning after some time, failing strict builds.However, and I'm glad I thought about testing your project (because I remembered you had some custom templates), this would be a breaking change in your case, because you're overriding the base templates themselves, which was probably not intended.
To explain what will go wrong here, mkdocstrings allows overriding templates with custom ones, by extending the base templates (using blocks) or by completely replacing them (not using the
extends
Jinja tag or not using blocks).You can see there are two template layers here, one under
material
, these are your custom templates, and one undermaterial/_base
, these are mkdocstrings base templates, which shouldn't be overridden (that's one of the reason it's called_base
with an underscore).With the upcoming change, mkdocstrings behavior will be:
material/function.html
template. If it exists, log a deprecation message (info) and use it. If not:material/function.html.jinja
template._base/function.html
, log a deprecation message (info)._base/function.html.jinja
, don't log anything.function.html.jinja
template is used, which extends_base/function.html.jinja
.Since you don't override any
function.html
orfunction.html.jinja
directly undermaterial
, the defaultfunction.html.jinja
will be used, and it will extend_base/function.html.jinja
, not_base/function.html
, which you override. Therefore the template you override will become unused, and your customizations won't apply.The solution here is simply to move your templates up by one level, into
material
, and removing thematerial/_base
then empty folder 🙂I can send a PR if you'd like.
The text was updated successfully, but these errors were encountered: