-
Notifications
You must be signed in to change notification settings - Fork 68
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
Version banner template example doesn't work because latest_version is hardcoded to 'master' #58
Comments
FWIW the example didn't work for me either, and would also be interested in having a version-based page banner :) |
For your information I think I solved this issue with this: {% extends "!page.html" %}
{% block body %}
{% if current_version and latest_version and current_version != latest_version and current_version != release and current_version.name != latest_version.release %}
<p>
<strong>
{% if current_version.is_released %}
{% if latest_version.release.replace('v', '').split('.') | map('int') | list > current_version.name.replace('v', '').split('.') | map('int') | list %}
You're reading an old version of this documentation.
If you want up-to-date information, please have a look at <a href="{{ vpathto(latest_version.name) }}">{{latest_version.name}}</a>.
{% endif %}
{% else %}
You're reading the documentation for a development version.
For the latest released version, please have a look at <a href="{{ vpathto(latest_version.name) }}">{{latest_version.name}}</a>.
{% endif %}
</strong>
</p>
{% endif %}
{{ super() }}
{% endblock %}% so with this horrible test:
|
the result is here: fine for me. |
For our own project, I did some digging into the issue. First, if you look at the documentation of @Holzhaus's own project Mixxx (for which he built sphinx-multiversion in the first place), you can see that you can actually set https://github.com/mixxxdj/manual/blob/5165e797563e46accfd2dbb10fe80fc5109c414a/source/conf.py#L106 Instead of hard coding this into the conf file, I thought it would be much more convenient to override this value using the
So I did some further digging. The smv config is added to Sphinx here (if So I added this to sphinx.py
and this to main.py
However, in main, when we loop over all the git refs, the function is called without the
I could enable setting the latest version from the cli. Maybe this also helps someone else. Oh, I also had to use the alternative regex pattern for @Holzhaus if you are willing to accept it, I will also create a PR for this. Edit: I just realised that my approach is flawed as it now always takes the default values and the overridden ones but ignores what is defined in conf.py. I will keep on trying! ^^ |
(First off, thanks for your work! My project was stuck on an old version of Sphinx due to using sphinxcontrib-versioning, and I'm almost done switching us over to sphinx-multiversion 🥳 )
Background
The template example for "version banners" is exactly what I'd like to use: when the user is viewing an unreleased version, warn them that it is in development; and if they are viewing and older released version, warn them that there's a newer version available.
Problem
However, the example doesn't work on my repo (using Sphinx 2.4.4 and sphinx-multiversion 0.2.4). The
latest_version
HTML context variable wasNone
.It seems like this context variable is based on the
smv_latest_version
config value, set to "master" by default. My repo doesn't have a "master" branch, which I guess is why the context variable isNone
.Ideally, I'd like to configure sphinx-multiversion to dynamically use the greatest released tag version as the latest version, instead of a static config value.
Mapping to sphinxcontrib-versioning's options:
smv_latest_version
seems to be the same asscv_banner_main_ref
scv_banner_greatest_tag
scv_banner_recent_tag
(for treating the most recently created tag as the latest version)scv_sort
defines the sort orderingPotential improvements
smv_latest_version
config value.smv_latest_version_is_greatest_tag
(or extend the semantics ofsmv_latest_version
to read a certain sentinel value?If you're supportive of this idea, but feel that it's low priority, I may be able to find some time at work to contribute a patch.
Thanks!
The text was updated successfully, but these errors were encountered: