{# Main content area #} {% block docs_main %}
diff --git a/tests/test_build.py b/tests/test_build.py index 1a2a623aa..60c95e308 100644 --- a/tests/test_build.py +++ b/tests/test_build.py @@ -1164,3 +1164,12 @@ def test_render_secondary_sidebar_dict_multiple_glob_matches( assert not sphinx_build.html_tree("section1/index.html").select("div.sourcelink") assert sphinx_build.html_tree("section2/index.html").select("div.sourcelink") assert sphinx_build.html_tree("section2/page1.html").select("div.sourcelink") + + +def test_role_main_for_search_highlights(sphinx_build_factory): + """Sphinx searchtools.js looks for [role="main"], so make sure it's there. + + This is a regression test. See #1676. + """ + sphinx_build = sphinx_build_factory("base").build() + assert sphinx_build.html_tree("index.html").select_one('[role="main"]') From 3e44d1ca9062f5d66a46523f3a0d5a89ccfd43f7 Mon Sep 17 00:00:00 2001 From: Charles Date: Wed, 24 Jan 2024 13:26:45 +0700 Subject: [PATCH 43/50] Apply default_mode to the html data-theme attribute (#1663) --- src/pydata_sphinx_theme/theme/pydata_sphinx_theme/layout.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pydata_sphinx_theme/theme/pydata_sphinx_theme/layout.html b/src/pydata_sphinx_theme/theme/pydata_sphinx_theme/layout.html index 9b3e6466e..43935cb65 100644 --- a/src/pydata_sphinx_theme/theme/pydata_sphinx_theme/layout.html +++ b/src/pydata_sphinx_theme/theme/pydata_sphinx_theme/layout.html @@ -14,7 +14,7 @@ {# https://github.com/pydata/pydata-sphinx-theme/pull/1045 #} {{ _webpack.head_pre_assets() }} {{ _webpack.head_pre_icons() }} From c04f042024dbe21b214511e62067cfde513e2720 Mon Sep 17 00:00:00 2001 From: David Stansby Date: Wed, 24 Jan 2024 16:00:11 +0000 Subject: [PATCH 44/50] Don't try to populate version switcher w/ relative path on local static site (#1660) * Don't try to populate version switcher on static sites * Fix comment spelling * Update src/pydata_sphinx_theme/assets/scripts/pydata-sphinx-theme.js --------- Co-authored-by: Daniel McCloy --- .../assets/scripts/pydata-sphinx-theme.js | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/pydata_sphinx_theme/assets/scripts/pydata-sphinx-theme.js b/src/pydata_sphinx_theme/assets/scripts/pydata-sphinx-theme.js index b0e65ab1d..64b8269da 100644 --- a/src/pydata_sphinx_theme/assets/scripts/pydata-sphinx-theme.js +++ b/src/pydata_sphinx_theme/assets/scripts/pydata-sphinx-theme.js @@ -347,6 +347,14 @@ async function fetchVersionSwitcherJSON(url) { var result = new URL(url); } catch (err) { if (err instanceof TypeError) { + if (!window.location.origin) { + // window.location.origin is null for local static sites + // (ie. window.location.protocol == 'file:') + // + // TODO: Fix this to return the static version switcher by working out + // how to get the correct path to the switcher JSON file on local static builds + return null; + } // assume we got a relative path, and fix accordingly. But first, we need to // use `fetch()` to follow redirects so we get the correct final base URL const origin = await fetch(window.location.origin, { method: "HEAD" }); @@ -556,9 +564,13 @@ if (hasVersionsJSON && (hasSwitcherMenu || wantsWarningBanner)) { const data = await fetchVersionSwitcherJSON( DOCUMENTATION_OPTIONS.theme_switcher_json_url ); - populateVersionSwitcher(data, versionSwitcherBtns); - if (wantsWarningBanner) { - showVersionWarningBanner(data); + // TODO: remove the `if(data)` once the `return null` is fixed within fetchVersionSwitcherJSON. + // We don't really want the switcher and warning bar to silently not work. + if (data) { + populateVersionSwitcher(data, versionSwitcherBtns); + if (wantsWarningBanner) { + showVersionWarningBanner(data); + } } } From 11af3fcfdcac4f58dfaee97d0da458cb9bbb6933 Mon Sep 17 00:00:00 2001 From: Daniel McCloy Date: Sun, 28 Jan 2024 15:51:16 -0600 Subject: [PATCH 45/50] handle null result from queryselector (#1683) fix queryselector --- src/pydata_sphinx_theme/assets/scripts/pydata-sphinx-theme.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/pydata_sphinx_theme/assets/scripts/pydata-sphinx-theme.js b/src/pydata_sphinx_theme/assets/scripts/pydata-sphinx-theme.js index 64b8269da..bf0056151 100644 --- a/src/pydata_sphinx_theme/assets/scripts/pydata-sphinx-theme.js +++ b/src/pydata_sphinx_theme/assets/scripts/pydata-sphinx-theme.js @@ -581,7 +581,9 @@ function fixMoreLinksInMobileSidebar() { const dropdown = document.querySelector( ".bd-sidebar-primary [id^=pst-nav-more-links]" ); - dropdown.classList.add("show"); + if (dropdown !== null) { + dropdown.classList.add("show"); + } } /******************************************************************************* From b0467859460cbe6d6602f07829174217b4bb119b Mon Sep 17 00:00:00 2001 From: Yao Xiao <108576690+Charlie-XIAO@users.noreply.github.com> Date: Thu, 1 Feb 2024 05:21:17 +0800 Subject: [PATCH 46/50] ENH make search result heading a bit away from the search input box (#1690) ENH make search result heading a bit away from the search box --- src/pydata_sphinx_theme/assets/styles/pages/_search.scss | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pydata_sphinx_theme/assets/styles/pages/_search.scss b/src/pydata_sphinx_theme/assets/styles/pages/_search.scss index b11b7b3c5..fe25ba556 100644 --- a/src/pydata_sphinx_theme/assets/styles/pages/_search.scss +++ b/src/pydata_sphinx_theme/assets/styles/pages/_search.scss @@ -10,7 +10,7 @@ div#search-results { > h2 { font-size: var(--pst-font-size-icon); - margin-top: 0; + margin-top: 1rem; } p.search-summary { From 4c7572b7c0e805a7585d5916ffbd2de5e6f90ac7 Mon Sep 17 00:00:00 2001 From: Yao Xiao <108576690+Charlie-XIAO@users.noreply.github.com> Date: Fri, 2 Feb 2024 04:10:25 +0800 Subject: [PATCH 47/50] ENH animation for the top banner (#1693) * ENH animation for the top banner * unset forcefully set styles to let css take over; animation also added for version warning banner * make transition a bit longer * resolve conversations * retrigger CI * Update src/pydata_sphinx_theme/assets/scripts/pydata-sphinx-theme.js --------- Co-authored-by: Daniel McCloy --- .../assets/scripts/pydata-sphinx-theme.js | 25 +++++++++++++++++- .../assets/styles/sections/_announcement.scss | 26 +++++++------------ .../sections/announcement.html | 23 +++++++++++++++- 3 files changed, 55 insertions(+), 19 deletions(-) diff --git a/src/pydata_sphinx_theme/assets/scripts/pydata-sphinx-theme.js b/src/pydata_sphinx_theme/assets/scripts/pydata-sphinx-theme.js index bf0056151..0dcc6ae42 100644 --- a/src/pydata_sphinx_theme/assets/scripts/pydata-sphinx-theme.js +++ b/src/pydata_sphinx_theme/assets/scripts/pydata-sphinx-theme.js @@ -484,7 +484,8 @@ function showVersionWarningBanner(data) { const bold = document.createElement("strong"); const button = document.createElement("a"); // these classes exist since pydata-sphinx-theme v0.10.0 - outer.classList = "bd-header-version-warning container-fluid"; + // the init class is used for animation + outer.classList = "bd-header-version-warning container-fluid init"; middle.classList = "bd-header-announcement__content"; inner.classList = "sidebar-message"; button.classList = @@ -516,6 +517,28 @@ function showVersionWarningBanner(data) { inner.appendChild(button); const skipLink = document.getElementById("pst-skip-link"); skipLink.after(outer); + // At least 3rem height + const autoHeight = Math.max( + outer.offsetHeight, + 3 * parseFloat(getComputedStyle(document.documentElement).fontSize) + ); + // Set height and vertical padding to 0 to prepare the height transition + outer.style.setProperty("height", 0); + outer.style.setProperty("padding-top", 0); + outer.style.setProperty("padding-bottom", 0); + outer.classList.remove("init"); + // Set height to the computed height with a small timeout to activate the transition + setTimeout(() => { + outer.style.setProperty("height", `${autoHeight}px`); + // Wait for a bit more than 300ms (the transition duration) then remove the + // forcefully set styles and let CSS take over + setTimeout(() => { + outer.style.removeProperty("padding-top"); + outer.style.removeProperty("padding-bottom"); + outer.style.removeProperty("height"); + outer.style.setProperty("min-height", "3rem"); + }, 320); + }, 10); } /******************************************************************************* diff --git a/src/pydata_sphinx_theme/assets/styles/sections/_announcement.scss b/src/pydata_sphinx_theme/assets/styles/sections/_announcement.scss index 843c4be7f..883087398 100644 --- a/src/pydata_sphinx_theme/assets/styles/sections/_announcement.scss +++ b/src/pydata_sphinx_theme/assets/styles/sections/_announcement.scss @@ -1,12 +1,13 @@ .bd-header-version-warning, .bd-header-announcement { - min-height: 3rem; width: 100%; display: flex; position: relative; align-items: center; justify-content: center; text-align: center; + transition: height 300ms ease-in-out; + overflow-y: hidden; padding: 0.5rem 12.5%; // Horizontal padding so the width is 75% // One breakpoint less than $breakpoint-sidebar-primary. See variables/_layout.scss for more info. @include media-breakpoint-down(lg) { @@ -14,21 +15,16 @@ padding: 0.5rem 2%; } + &.init { + position: fixed; + visibility: hidden; + } + p { font-weight: bold; margin: 0; } - &:after { - position: absolute; - width: 100%; - height: 100%; - left: 0; - top: 0; - content: ""; - z-index: -1; // So it doesn't hover over the content - } - &:empty { display: none; } @@ -41,13 +37,9 @@ // Bg color is now defined in the theme color palette - using our secondary color .bd-header-announcement { - &:after { - background-color: var(--pst-color-secondary-bg); - } + background-color: var(--pst-color-secondary-bg); } .bd-header-version-warning { - &:after { - background-color: var(--pst-color-danger-bg); - } + background-color: var(--pst-color-danger-bg); } diff --git a/src/pydata_sphinx_theme/theme/pydata_sphinx_theme/sections/announcement.html b/src/pydata_sphinx_theme/theme/pydata_sphinx_theme/sections/announcement.html index b9335f5f2..dbe094fca 100644 --- a/src/pydata_sphinx_theme/theme/pydata_sphinx_theme/sections/announcement.html +++ b/src/pydata_sphinx_theme/theme/pydata_sphinx_theme/sections/announcement.html @@ -1,4 +1,4 @@ -{% set header_classes = ["bd-header-announcement", "container-fluid"] %} +{% set header_classes = ["bd-header-announcement", "container-fluid", "init"] %} {% set is_remote=theme_announcement.startswith("http") %} {# If we are remote, add a script to make an HTTP request for the value on page load #} {%- if is_remote %} @@ -10,6 +10,27 @@ div = document.querySelector(".bd-header-announcement"); div.classList.add(...{{ header_classes | tojson }}); div.innerHTML = `
${data}
`; + // At least 3rem height + const autoHeight = Math.min( + div.offsetHeight, + 3 * parseFloat(getComputedStyle(document.documentElement).fontSize)); + // Set height and vertical padding to 0 to prepare the height transition + div.style.setProperty("height", 0); + div.style.setProperty("padding-top", 0); + div.style.setProperty("padding-bottom", 0); + div.classList.remove("init"); + // Set height to the computed height with a small timeout to activate the transition + setTimeout(() => { + div.style.setProperty("height", `${autoHeight}px`); + // Wait for a bit more than 300ms (the transition duration) then remove the + // forcefully set styles and let CSS take over + setTimeout(() => { + div.style.removeProperty("padding-top"); + div.style.removeProperty("padding-bottom"); + div.style.removeProperty("height"); + div.style.setProperty("min-height", "3rem"); + }, 320); + }, 10); }) .catch(error => { console.log("[PST]: Failed to load announcement at: {{ theme_announcement }}"); From 4e00c655a049381b45cfb33cde753e9a91a30369 Mon Sep 17 00:00:00 2001 From: Rambaud Pierrick <12rambau@users.noreply.github.com> Date: Sat, 3 Feb 2024 16:26:46 +0000 Subject: [PATCH 48/50] docs: typo in a link in the release instructions (#1704) --- RELEASE.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RELEASE.md b/RELEASE.md index 1abdf5fff..9062404bd 100644 --- a/RELEASE.md +++ b/RELEASE.md @@ -21,7 +21,7 @@ These steps should be taken in order to create a new release![^release-refs] **Make the release** -- [ ] [Start a new GitHub release](https://github.com/pandas-dev/pydata-sphinx-theme/releases/new) +- [ ] [Start a new GitHub release](https://github.com/pydata/pydata-sphinx-theme/releases/new) - Call the release the current version, e.g. `v0.2.0` - In the **`Choose a Tag:`** dropdown, type in the release name (e.g., `v0.2.0`) and click "Create new tag" - In the **`Target:`** dropdown, pin it to the release commit that you've just pushed. From 11a1d6ec51f372e4f13ccfdfcc4b2a05ac08d4cb Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 5 Feb 2024 14:26:40 +0100 Subject: [PATCH 49/50] Build(deps): Bump codecov/codecov-action from 3 to 4 (#1706) Bumps [codecov/codecov-action](https://github.com/codecov/codecov-action) from 3 to 4. - [Release notes](https://github.com/codecov/codecov-action/releases) - [Changelog](https://github.com/codecov/codecov-action/blob/main/CHANGELOG.md) - [Commits](https://github.com/codecov/codecov-action/compare/v3...v4) --- updated-dependencies: - dependency-name: codecov/codecov-action dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 8e9eaa1d2..7ecec6594 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -94,7 +94,7 @@ jobs: run: pytest -m "not a11y" --color=yes --cov --cov-report=xml - name: Upload to Codecov if: matrix.python-version == '3.12' && matrix.os == 'ubuntu-latest' - uses: codecov/codecov-action@v3 + uses: codecov/codecov-action@v4 with: token: ${{ secrets.CODECOV_TOKEN }} fail_ci_if_error: true From 17dba55d035ef61ff0ef67eecac0d62149dff470 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 5 Feb 2024 14:27:19 +0100 Subject: [PATCH 50/50] Build(deps): Bump treosh/lighthouse-ci-action from 10 to 11 (#1705) Bumps [treosh/lighthouse-ci-action](https://github.com/treosh/lighthouse-ci-action) from 10 to 11. - [Release notes](https://github.com/treosh/lighthouse-ci-action/releases) - [Commits](https://github.com/treosh/lighthouse-ci-action/compare/v10...v11) --- updated-dependencies: - dependency-name: treosh/lighthouse-ci-action dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 7ecec6594..65cf7bd07 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -194,7 +194,7 @@ jobs: sphinx-build audit/site audit/_build # The lighthouse audit runs directly on the HTML files, no serving needed - name: Audit with Lighthouse - uses: treosh/lighthouse-ci-action@v10 + uses: treosh/lighthouse-ci-action@v11 with: configPath: ".github/workflows/lighthouserc.json" temporaryPublicStorage: true