Skip to content

Commit

Permalink
Merge pull request #794 from executablebooks/agoose77/fix-static-path…
Browse files Browse the repository at this point in the history
…-css

FIX: don't include `_static` in css_files
  • Loading branch information
agoose77 authored Dec 14, 2023
2 parents 4614e8f + 4dbbc5f commit 39d4f4b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ jobs:
# Only upload to codecov on pull requests so that we don't trigger rate limit blocks
- name: Upload to Codecov
if: matrix.os == 'ubuntu-latest' && matrix.python-version == 3.9 && github.repository == 'executablebooks/sphinx-book-theme' && github.event_name == 'pull_request'
if: matrix.os == 'ubuntu-latest' && matrix.python-version == 3.9 && matrix.sphinx == '~=7.0' && github.repository == 'executablebooks/sphinx-book-theme' && github.event_name == 'pull_request'
uses: codecov/codecov-action@v3.1.4
with:
name: ebp-sbt-pytests-py3.7
Expand Down
8 changes: 2 additions & 6 deletions src/sphinx_book_theme/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ def hash_assets_for_files(assets: list, theme_static: Path, context, app):
asset_type = "css_files" if asset_path.endswith(".css") else "script_files"
if asset_type in context:
# Define paths to the original asset file, and its linked file in Sphinx
asset_sphinx_link = f"_static/{asset_path}"
asset_source_path = theme_static / asset_path
if not asset_source_path.exists():
SPHINX_LOGGER.warning(
Expand All @@ -103,18 +102,15 @@ def hash_assets_for_files(assets: list, theme_static: Path, context, app):
for ii, other_asset in enumerate(context[asset_type]):
# TODO: eventually the contents of context['css_files'] etc should probably
# only be _CascadingStyleSheet etc. For now, assume mixed with strings.
if (
getattr(other_asset, "filename", str(other_asset))
!= asset_sphinx_link
):
if getattr(other_asset, "filename", str(other_asset)) != asset_path:
continue
# Take priority from existing asset or use default priority (500)
priority = getattr(other_asset, "priority", 500)
# Remove existing asset
del context[asset_type][ii]
# Add new asset
app.add_css_file(
asset_sphinx_link,
asset_path,
digest=_gen_hash(asset_source_path),
priority=priority,
)
Expand Down

0 comments on commit 39d4f4b

Please sign in to comment.