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

Drop usage of internal API when conditionally including assets #198

Merged
merged 5 commits into from
Oct 8, 2024

Conversation

kartben
Copy link
Contributor

@kartben kartben commented Aug 20, 2024

Fixes #197 by reversing the logic of how JS/CSS assets are added to pages.

Rather than adding assets to the app and using undocumented API to remove them when not needed, do the exact opposite and only add them to the local html-page-context when building a page that uses the directive.

updates:
- [github.com/pre-commit/pre-commit-hooks: v4.3.0 → v4.6.0](pre-commit/pre-commit-hooks@v4.3.0...v4.6.0)
- [github.com/mgedmin/check-manifest: 0.48 → 0.49](mgedmin/check-manifest@0.48...0.49)
- [github.com/psf/black: 22.3.0 → 24.8.0](psf/black@22.3.0...24.8.0)
- [github.com/PyCQA/pylint: v2.14.3 → v3.2.6](pylint-dev/pylint@v2.14.3...v3.2.6)
@kartben
Copy link
Contributor Author

kartben commented Aug 20, 2024

just realized I forgot to update pytests - should be green now

Copy link

@ru-fu ru-fu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My Python skills don't suffice to review the changes in detail, but they look sensible.
I've tested the updated version and everything works as expected, and the warnings are gone.

Thanks a lot!

@kartben
Copy link
Contributor Author

kartben commented Aug 21, 2024

@foster999 codecov/codecov-action@v1 is probably due for an update since v4.5.0 is the current version. Maybe this will help handle rate limit and perform retries automagically? Do you want me to add a commit taking care of this to this PR?

@foster999
Copy link
Collaborator

Thanks for this @kartben 😄

@foster999 codecov/codecov-action@v1 is probably due for an update since v4.5.0 is the current version. Maybe this will help handle rate limit and perform retries automagically? Do you want me to add a commit taking care of this to this PR?

Yes please, might as well sort this at the same time! Failing that, I'd be happy to drop the codecov step in the Actions config for now.

Could you also drop the lines in the change for backwards compatibility with old sphinx (and if needed update the setup.py) please? I've tried to move towards only officially supporting the latest major version of dependencies, as older versions of sphinx-tabs can be used with older dependencies

This part of the code has been rewritten to and from this approach a few times, so I'd also like to understand why it was changed from the approach you've written here last time. I'll try and look back when I get chance, but it would be great if you could review older revisions/PRs to this part of the code to try to understand this also please

Copy link

@simondeziel simondeziel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

@kartben
Copy link
Contributor Author

kartben commented Aug 21, 2024

Yes please, might as well sort this at the same time! Failing that, I'd be happy to drop the codecov step in the Actions config for now.

I've pushed the change so let's see

Could you also drop the lines in the change for backwards compatibility with old sphinx (and if needed update the setup.py) please? I've tried to move towards only officially supporting the latest major version of dependencies, as older versions of sphinx-tabs can be used with older dependencies

Done

This part of the code has been rewritten to and from this approach a few times, so I'd also like to understand why it was changed from the approach you've written here last time. I'll try and look back when I get chance, but it would be great if you could review older revisions/PRs to this part of the code to try to understand this also please

I tried to look back in time a little bit but I couldn't really find a time where it ever was done like I am proposing in this patch. It's true that adding to all pages has apparently been done in different ways in the past, but I couldn't find occurrences of the "only add when used" approach.

Copy link

codecov bot commented Aug 21, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.52%. Comparing base (e83dc14) to head (f8f2325).
Report is 4 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #198      +/-   ##
==========================================
+ Coverage   97.26%   98.52%   +1.26%     
==========================================
  Files           2        2              
  Lines         219      203      -16     
==========================================
- Hits          213      200      -13     
+ Misses          6        3       -3     
Flag Coverage Δ
pytests 98.52% <100.00%> (+1.26%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@foster999
Copy link
Collaborator

foster999 commented Aug 21, 2024

Thanks for adding those bits and taking a look back. I think you're right - the old method just added them regardless of use, so the method being replaced here was likely a solution to that

As others have confirmed the issue is resolved, I'll get it merged and released once everything is passing

Edit: just looks like a formatting issue from pre-commit, then we're good to go

codecov-action v1 is really old, bump to v4.

Signed-off-by: Benjamin Cabé <[email protected]>
Fixes executablebooks#197 by reversing the logic of how JS/CSS assets are added to pages.
Rather than adding assets to the app and using undocumented API to *remove* them when not needed, do the exact opposite and only add them to the local html-page-context when building a page.

Signed-off-by: Benjamin Cabé <[email protected]>
Drop the code that was used to support Sphinx version < 1.8, released 6 years ago.

Signed-off-by: Benjamin Cabé <[email protected]>
`bad-continuation` has been removed from pylint
See pylint-dev/pylint#3571

Signed-off-by: Benjamin Cabé <[email protected]>
@kartben
Copy link
Contributor Author

kartben commented Aug 21, 2024

@foster999 I think we should be back on track.
Updated pre-commit.ci to fetch more recent versions of black, pylint, etc. since one of the errors was actually a hard crash due to a too old pylint version being pulled in and not being compatible with Python 3.12
Also dropped bad-continuation as per the warning that was showing up before the crash.
pre-commit run -a now passes locally

$ pre-commit  run -a
check json...............................................................Passed
check yaml...............................................................Passed
fix end of files.........................................................Passed
trim trailing whitespace.................................................Passed
check-manifest...........................................................Passed
black....................................................................Passed
pylint...................................................................Passed

@simondeziel
Copy link

@foster999 if/when you get a chance to take another look that'd be great as the warning is polluting our build logs making it harder to spot any real issue. Thanks!

@foster999 foster999 merged commit 3e52a1e into executablebooks:master Oct 8, 2024
10 checks passed
@kartben kartben deleted the fix_197 branch October 8, 2024 13:07
@foster999
Copy link
Collaborator

Sorry for the huge delay getting round to this! Now included in version 3.4.6

@kartben
Copy link
Contributor Author

kartben commented Oct 8, 2024

Sorry for the huge delay getting round to this! Now included in version 3.4.6

Awesome, thanks! Do you have a sense of when this will be available through pypi? Thanks!

@foster999
Copy link
Collaborator

Deployment failed for that one, but it's now up on PyPI as 3.4.7 ☺️

@simondeziel
Copy link

Sorry for the huge delay getting round to this! Now included in version 3.4.6

@foster999, no worries at all, thanks for your work as maintainer and also thanks again @kartben for the PR!

stsewd added a commit to readthedocs/sphinx-hoverxref that referenced this pull request Nov 11, 2024
We are disconnecting the html-page-context event from sphinx-tabs,
which was used to delete the static files from html files
that didn't use sphinx-tabs. But in executablebooks/sphinx-tabs#198
this was changed to instead decide if the page should have the static files or not.

Since we are removing that event, sphinx-tabs never gets to inject the
static files, this breaks sphinx-tabs for projects using hoverxref.

We no longer need to disconnect that signal, since we are overriding the html assets policy to `always`,
which sphnx-tabs respects already executablebooks/sphinx-tabs#132
(more than 3 years ago).
stsewd added a commit to readthedocs/sphinx-hoverxref that referenced this pull request Nov 11, 2024
We are disconnecting the html-page-context event from sphinx-tabs,
which was used to delete the static files from html files
that didn't use sphinx-tabs. But in executablebooks/sphinx-tabs#198
this was changed to instead decide if the page should have the static files or not.

Since we are removing that event, sphinx-tabs never gets to inject the
static files, this breaks sphinx-tabs for projects using hoverxref.

We no longer need to disconnect that signal, since we are overriding the html assets policy to `always`,
which sphnx-tabs respects already executablebooks/sphinx-tabs#132
(more than 3 years ago).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

RemovedInSphinx90Warning ("The str interface for _JavaScript objects is deprecated")
5 participants