mgeier / sphinx-last-updated-by-git

:watch: Get the "last updated" time for each Sphinx page from Git
BSD 2-Clause "Simplified" License
44 stars 9 forks source link

Not working as expected for older projects using the PyData theme #54

Closed agriyakhetarpal closed 1 year ago

agriyakhetarpal commented 1 year ago

I think other themes might be affected too, such as the PyData theme – I have not been able to make this work, neither locally nor on readthedocs (https://github.com/pybamm-team/PyBaMM/pull/3089). @mgeier could you please help investigate this? Here is a link to the PR build and the build logs. I did bump up the Sphinx version to >= 6 in docs/requirements.txt (it was >=1.5 earlier).

However, I can see that other projects have been able to make this extension work with the same theme, maybe this is an issue with our configuration? It is almost similar to others' configurations – so I don't see any conflicts. Or, is it because they are newer projects unlike ours (i.e., post-October 2020) and we have to request the aforementioned feature flag(s) in this thread from readthedocs?

Originally posted by @agriyakhetarpal in https://github.com/mgeier/sphinx-last-updated-by-git/issues/1#issuecomment-1616701207

agriyakhetarpal commented 1 year ago

Minimal reproducible example

# in docs/conf.py

extensions = [
...
"sphinx_last_updated_by_git",
]

html_theme = "pydata_sphinx_theme"

# set by default by either the theme or by Sphinx, not sure if helps
html_last_updated_fmt = "%b %d, %Y"

Here is a link to the full conf.py file for more configuration values. The project was hosted on readthedocs before October 2020.

I can confirm that I added sphinx-last-updated-by-git to docs/requirements.txt and other places where required.

Sphinx version: 6.2.1

Relevant logs

The PR build and the build logs for readthedocs are in the issue comment above. I do not see any logs, warnings, or errors relevant to sphinx-last-updated-by-git when I build the documentation locally.

Command-line information via pip:

$ pip show sphinx-last-updated-by-git                                                      
Name: sphinx-last-updated-by-git
Version: 0.3.5
Summary: Get the "last updated" time for each Sphinx page from Git
Home-page: https://github.com/mgeier/sphinx-last-updated-by-git/
Author: Matthias Geier
Author-email: Matthias.Geier@gmail.com
License: BSD-2-Clause
Location: .nox/docs/lib/python3.11/site-packages
Requires: sphinx
Required-by: 

Let me know if I need to post any more information or logs, @mgeier. Thanks a lot!

Edit: I have tried forcing sphinx_rtd_theme>=0.5 in https://github.com/pybamm-team/PyBaMM/pull/3089/commits/b78f27c8d3e5c7d299862a3057c6cec60d932348 but to no avail, and I have updated the build logs. It seems that requesting readthedocs for disabling the compatibility feature should be the way to solve it

agriyakhetarpal commented 1 year ago

I seem to have fixed it by manually adding the "last-updated" value to the footer options of the theme. Thanks for your time, I shall be closing this as the issue was resolved.

mgeier commented 1 year ago

Great to hear that it works now!

If somebody else stumbles upon this, the "last updated" information can be enabled in the PyData theme by using something like this in conf.py:

html_theme_options = {
    "footer_start": [
        "copyright",
        "sphinx-version",
        "last-updated",
    ],
}

Alternatively, "footer_end" can be used.

For more options, see https://pydata-sphinx-theme.readthedocs.io/en/stable/user_guide/layout.html#layout-footer


There was also an unrelated problem about "shallow clones", where many warnings like this were shown:

WARNING: Git clone too shallow

This can be fixed by updating the .readthedocs.yml file (see #55):

version: 2
build:
  os: "ubuntu-20.04"
  tools:
    python: "3"
  jobs:
    post_checkout:
      - git fetch --unshallow || true