-
-
Notifications
You must be signed in to change notification settings - Fork 55
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
Make it possible for Sphinx themes, to provide their own templates for ablog to use! #125
Comments
Ways I can think of addressing this:
One thing that would genuinely be great for this functionality in general, would be namespacing ablog's templates -- moving them into an It should likely also be possible for users to override ablog's behavior in this regard, via a configuration option to force ablog to include (or not include) its custom templates. |
That all sounds good to me - so if the |
If this is something that can be done easily and without breaking anything, I am all for it. |
I don't think there's any way to be sure that things won't break -- at this point, with ABlog, Hyrum's Law applies. Any change around template handling will be a breaking change for somebody. This would affect users with custom templates; who I'd guess are also be capable of figuring out how to pin to an older version or adapting their templates -- I think the breakage will be worth the improvements. I don't know how "easy" it would be to do this -- I don't know the codebase at all! :) |
Merely moving them doesn't address the underlying issue, but it will make it much cleaner to implement support for this + make it clearer for everyone what the template is for. :)
The relevant logic in Sphinx is https://github.com/sphinx-doc/sphinx/blob/v4.4.0/sphinx/jinja2glue.py#L152-L178 and https://github.com/sphinx-doc/sphinx/blob/v4.4.0/sphinx/jinja2glue.py#L206. It uses Jinja2, and here's the relevant documentation section: https://jinja2docs.readthedocs.io/en/stable/api.html#loaders. Basically, Sphinx handles template paths as follows:
As I mentioned in OP, there's no way to define a template in |
So... I think this is achievable; albeit at the cost of breaking users who are setting up custom templates in their own documentation. I'd argue it is worthwhile -- it's a much healthier place to be, having a blog-related templates be something that Sphinx themes can provide from their end, letting themes handle the presentation and markup; given the relevant context. I think this is basically a blocker for making it easier to build something like python-poetry.org or pradyunsg.me with just Sphinx and a custom theme currently. |
Beyond that, I'd argue that ablog should move away from zero-based versioning given that one of the two concerns raised by @nabobalis here is backwards compatibility. :) (the other being implementation complexity) |
I can bump the major version. |
Suggested path forwardHow about
|
The issue is that would not work with alabaster, for which support relies on overriding the templates provided by the theme. |
hmmm ok - well then I'd still be in favor of 1-3, as an iterative improvement, along with: |
Ok I started having a go at this in #144 I don't plan to do a depreciation period or any checks, I just plan to bump to the next version and include breaking changes in the changelog (when I finish the PR). I think as far as I can understand, I moved the templates to a |
Currently, ablog unconditionally injects its own templates at the end of
templates_path
:ablog/ablog/__init__.py
Line 102 in cbec004
These templates are injected by Sphinx before the theme-provided templates:
https://github.com/sphinx-doc/sphinx/blob/v4.4.0/sphinx/jinja2glue.py#L168
This means, there is no easy way for theme authors to provide explicit support for ablog in their theme, if they don't follow the assumptions that ablog makes in its own templates (see #108).
/cc @choldgraf, since he contributed the unconditional addition + has his own blog using ablog as well. :)
The text was updated successfully, but these errors were encountered: