Skip to content
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

fix: place the las_update value in the meta of each page #1409

Merged
merged 9 commits into from
Aug 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@
html_logo = "_static/logo.svg"
html_favicon = "_static/logo.svg"
html_sourcelink_suffix = ""
html_last_updated_fmt = "" # to reveal the build date in the pages meta

# Define the json_url for our version switcher.
json_url = "https://pydata-sphinx-theme.readthedocs.io/en/latest/_static/switcher.json"
Expand Down
22 changes: 22 additions & 0 deletions docs/user_guide/layout.rst
Original file line number Diff line number Diff line change
Expand Up @@ -567,3 +567,25 @@ could do so with the following steps:
"navbar_start": ["navbar-logo", "version"],
# ...
}

Build date
==========

By default this theme does not display the build date even when Sphinx's `html_last_updated_fmt <https://www.sphinx-doc.org/en/master/usage/configuration.html#confval-html_last_updated_fmt>`__ variable is set. If you want the build date displayed, the theme includes a :code:`last-updated` template that you can add to one of the page regions in your ``conf.py``. For example:

.. code-block:: python
:caption: conf.py

html_theme_options = {
"content_footer_items": ["last-updated"],
# other settings...
}

If you do specify ``html_last_updated_fmt`` but don't include the :code:`last-updated` template, the theme will still write the build date into a ``meta`` tag in the HTML header, which can be inspected by viewing the page source or extracted with an HTML parser. The tag will look like:

.. code-block:: html

<meta name="docbuild:last-update" content="Aug 15, 2023">

The tag's ``content`` attribute will follow the format specified in the ``html_last_updated_fmt`` configuration variable.

3 changes: 3 additions & 0 deletions src/pydata_sphinx_theme/theme/pydata_sphinx_theme/layout.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@
{%- block extrahead %}
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<meta name="docsearch:language" content="{{ language }}"/>
{%- if last_updated %}
<meta name="docbuild:last-update" content="{{ last_updated | e }}"/>
{%- endif %}
{%- endblock extrahead %}
{% block body_tag %}
{# set up with scrollspy to update the toc as we scroll #}
Expand Down
2 changes: 1 addition & 1 deletion tools/github_actions_install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ elif [[ "$SPHINX_VERSION" == "dev" ]]; then
SPHINX_INSTALL="git+https://github.com/sphinx-doc/sphinx"
if [[ "$1" == "doc" ]]; then
# Until they release a new version that undoes the max sphinx pin...
DEP_EXTRA="git+https://github.com/executablebooks/MyST-NB git+https://github.com/larsoner/sphinx-sitemap.git@path"
DEP_EXTRA="git+https://github.com/executablebooks/MyST-NB"
fi
elif [[ "$SPHINX_VERSION" == "old" ]]; then
SPHINX_INSTALL="sphinx==5.0"
Expand Down