alabaster icon indicating copy to clipboard operation
alabaster copied to clipboard

Missing "Last updated on" timestamp in footer

Open rlee287 opened this issue 8 years ago • 8 comments

The conf.py generated by sphinx states the following:

# If not None, a 'Last updated on:' timestamp is inserted at every page
# bottom, using the given strftime format.
# The empty string is equivalent to '%b %d, %Y'.
html_last_updated_fmt = "%b %d, %Y"

The footer code at https://github.com/bitprophet/alabaster/blob/master/alabaster/layout.html#L44-L82 noticably lacks the {%- if last_updated %} block from https://github.com/sphinx-doc/sphinx/blob/master/sphinx/themes/basic/layout.html#L182-L198. As a result, the "Last updated on:" part is missing from the footer:

capture

This gist has the relevant code portions in one place.

rlee287 avatar Dec 29 '16 03:12 rlee287

Thanks for the report!

Feels like an oversight in the source themes...I see no Git diffs in our repo mentioning last_updated, nor do I personally recall seeing it anywhere.

Would accept a PR that adds this in (or I might do it myself if it keeps bothering me)...specifically:

  • [ ] May want to make this controlled by an opt-in Releases-level setting, so it doesn't unexpectedly appear for users not expecting it.
    • However, I quickly checked, and the {% if last_updated %} is falsey unless one's conf.py contains last_updated_fmt. So arguably this is a straight up display bug and not a "new/changed feature" that would need an opt-in.
    • Only counterpoint is that since the default Sphinx quickstart sets this to a non-empty value, users may be unaware of what it's supposed to do, and thus still be surprised when the new footer section appears on their next update.
  • [ ] At this point, with so many elements in the footer, we may want to see if we can generate more of it at the Python level, such that we can (in Python or the template) utilize .join(' | '). Right now it's a mess of "did the previous section/s get displayed? Slap a pipe before printing our own stuff".

bitprophet avatar Jan 02 '17 16:01 bitprophet

Where do you think the "Last updated on:" should be (i.e. left, right, in between other elements)?

As to the Sphinx default, I think the comments in conf.py explains this well, so the default non-empty value shouldn't be a problem.

rlee287 avatar Jan 02 '17 20:01 rlee287

I think far-right looked fine when I tried it out temporarily. Open to opinions of course.

bitprophet avatar Jan 03 '17 02:01 bitprophet

@bitprophet Is there any news about this? I'm using Alabaster for my CV website and would love to have a "last updated" footer.

Benjamin-Lee avatar Nov 01 '18 00:11 Benjamin-Lee

any update?

daoiqi avatar Dec 31 '18 15:12 daoiqi

As a quick workaround, I put this in my conf.py:

from datetime import datetime
now = datetime.now()

project = 'Benjamin Lee'
copyright = str(now.year) + ', Benjamin Lee. Updated on ' + now.strftime("%B %d, %Y")

Benjamin-Lee avatar Jan 01 '19 03:01 Benjamin-Lee

I use Sphinx sub-template https://www.sphinx-doc.org/en/master/templating.html#jinja-sphinx-templating-primer

in ./docs/_templates/layout.html to extends layout.html

{% extends "!layout.html" %}

{%- block footer %}
    <div class="footer">
        {% if show_copyright %}&copy;{{ copyright }}.{% endif %}
        {% if theme_show_powered_by|lower == 'true' %}
        {% if show_copyright %}|{% endif %}
        Powered by <a href="http://sphinx-doc.org/">Sphinx {{ sphinx_version }}</a>
        &amp; <a href="https://github.com/bitprophet/alabaster">Alabaster {{ alabaster_version }}</a>
        {% endif %}
        {%- if last_updated %}
            Last updated on {{ last_updated }}.
        {%- endif %}
        {%- if show_source and has_source and sourcename %}
        {% if show_copyright or theme_show_powered_by %}|{% endif %}
        <a href="{{ pathto('_sources/' + sourcename, true)|e }}"
            rel="nofollow">{{ _('Page source') }}</a>
        {%- endif %}
    </div>

{%- endblock %}

So, I can rewrite the custom html.

daoiqi avatar Jan 12 '19 03:01 daoiqi