Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into trallard/update-ci
Browse files Browse the repository at this point in the history
  • Loading branch information
trallard committed May 8, 2024
2 parents 904ffeb + a31db4c commit 963b51a
Show file tree
Hide file tree
Showing 47 changed files with 242 additions and 93 deletions.
23 changes: 23 additions & 0 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Post coverage comment

on:
workflow_run:
workflows: ["continuous-integration"]
types:
- completed

jobs:
test:
name: Run tests & display coverage
runs-on: ubuntu-latest
if: github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.conclusion == 'success'
permissions:
pull-requests: write
contents: write # needed to edit the comment vs opening multiple ones
actions: read
steps:
- name: Post comment
uses: py-cov-action/python-coverage-comment-action@v3
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_PR_RUN_ID: ${{ github.event.workflow_run.id }}
9 changes: 7 additions & 2 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ env:

permissions:
contents: read
id-token: write # needed for PyPI upload

jobs:
# calls our tests workflow
Expand Down Expand Up @@ -46,13 +45,19 @@ jobs:
release-pypi:
runs-on: ubuntu-latest
needs: [build-package]
permissions:
id-token: write # needed for PyPI upload
steps:
- name: "Download PST built package 📦"
uses: actions/download-artifact@v4
with:
name: PST-package
name: Packages
path: dist

- name: "Unzip artifact"
run: |
tar xf dist/*.tar.gz --strip-components=1
- name: "Publish PST package to PyPI 🚀"
uses: pypa/gh-action-pypi-publish@release/v1
# only publish if this is a published release by pydata
Expand Down
40 changes: 39 additions & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,18 @@ jobs:
nox -s compile
- name: Run tests
run: pytest -m "not a11y" --color=yes --cov --cov-report=xml
env:
COVERAGE_FILE: ".coverage.${{ matrix.python-version }}.${{ matrix.os }}.${{ matrix.sphinx-version }}"
- name: Store coverage file
uses: actions/upload-artifact@v4
with:
name: coverage-${{ matrix.python-version }}-${{ matrix.os }}-${{ matrix.sphinx-version }}
path: .coverage.${{ matrix.python-version }}.${{ matrix.os }}.${{ matrix.sphinx-version }}
- name: Upload to Codecov
if: matrix.python-version == '3.12' && matrix.os == 'ubuntu-latest' && matrix.sphinx-version == 'dev'
uses: codecov/codecov-action@v4
with:
fail_ci_if_error: true
verbose: true
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

Expand All @@ -120,6 +126,38 @@ jobs:
nox -s a11y
continue-on-error: true

coverage:
name: Collect Coverage
runs-on: ubuntu-latest
needs: run-pytest
# run both on previous step success and failure
if: "!cancelled()"
permissions:
pull-requests: write
contents: write
steps:
- uses: actions/checkout@v4

- uses: actions/download-artifact@v4
id: download
with:
pattern: coverage-*
merge-multiple: true

- name: Coverage comment
id: coverage_comment
uses: py-cov-action/python-coverage-comment-action@v3
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
MERGE_COVERAGE_FILES: true

- name: Store Pull Request comment to be posted
uses: actions/upload-artifact@v4
if: steps.coverage_comment.outputs.COMMENT_FILE_WRITTEN == 'true'
with:
name: python-coverage-comment-action
path: python-coverage-comment-action.txt

# Build our site on the 3 major OSes and check for Sphinx warnings
build-site:
needs: [lint]
Expand Down
14 changes: 7 additions & 7 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ default_language_version:

repos:
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v2.7.1
rev: v4.0.0-alpha.8
hooks:
- id: prettier
# Exclude the HTML, since it doesn't understand Jinja2
Expand All @@ -22,23 +22,23 @@ repos:
exclude: .+\.html|webpack\.config\.js|tests/test_a11y/

- repo: https://github.com/psf/black
rev: 22.12.0
rev: 24.4.2
hooks:
- id: black

- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: "v0.0.215"
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: "v0.4.3"
hooks:
- id: ruff

- repo: https://github.com/asottile/pyupgrade
rev: v3.3.1
rev: v3.15.2
hooks:
- id: pyupgrade
args: [--py37-plus]

- repo: https://github.com/Riverside-Healthcare/djLint
rev: v1.19.7
rev: v1.34.1
hooks:
- id: djlint-jinja
types_or: ["html"]
Expand All @@ -49,6 +49,6 @@ repos:
- id: doc8

- repo: "https://github.com/kynan/nbstripout"
rev: "0.5.0"
rev: "0.7.1"
hooks:
- id: nbstripout
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
[![conda-forge version badge](https://img.shields.io/conda/vn/conda-forge/pydata-sphinx-theme.svg?logo=anaconda&logoColor=white&color=orange)](https://anaconda.org/conda-forge/pydata-sphinx-theme)
[![GitHub Workflow test status badge](https://img.shields.io/github/actions/workflow/status/pydata/pydata-sphinx-theme/tests.yml?logo=github&logoColor=white)](https://github.com/pydata/pydata-sphinx-theme/actions/workflows/tests.yml)
[![Read the Docs build status badge](https://img.shields.io/readthedocs/pydata-sphinx-theme/latest?logo=readthedocs&logoColor=white)](https://readthedocs.org/projects/pydata-sphinx-theme/builds/)
[![Codecov test coverage percentage badge](https://img.shields.io/codecov/c/github/pydata/pydata-sphinx-theme?logo=codecov&logoColor=white)](https://codecov.io/gh/pydata/pydata-sphinx-theme)

A clean, three-column, Bootstrap-based Sphinx theme by and for the [PyData community](https://pydata.org).

Expand Down
1 change: 1 addition & 0 deletions docs/_extension/component_directive.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
This list will display some informations about the component and a link to the
GitHub file.
"""

import re
from pathlib import Path
from typing import Any, Dict, List
Expand Down
5 changes: 3 additions & 2 deletions docs/_extension/gallery_directive.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@
It currently exists for maintainers of the pydata-sphinx-theme,
but might be abstracted into a standalone package if it proves useful.
"""

from pathlib import Path
from typing import Any, Dict, List
from typing import Any, ClassVar, Dict, List

from docutils import nodes
from docutils.parsers.rst import directives
Expand Down Expand Up @@ -58,7 +59,7 @@ class GalleryGridDirective(SphinxDirective):
required_arguments = 0
optional_arguments = 1
final_argument_whitespace = True
option_spec = {
option_spec: ClassVar[dict[str, Any]] = {
# A class to be added to the resulting container
"grid-columns": directives.unchanged,
"class-container": directives.unchanged,
Expand Down
2 changes: 1 addition & 1 deletion docs/_static/custom-icon.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/_static/pydata-icon.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ FontAwesome.library.add(
"e002", // unicode codepoint - private use area
"M12.1,17.8v5.8l-5-2.9v-5.8L12.1,17.8z M12.1,12v5.8l-5-2.9V9.1L12.1,12z M17,9.1L12.1,12v5.8l4.9-2.9V9.1z M12.1,6.2L7,9.1l5,2.9L17,9.1L12.1,6.2z M17,9.1V3.3l-4.9-2.8v5.8L17,9.1z",
],
})
}),
);
1 change: 1 addition & 0 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
nox -s docs -- -r
"""

import os
import shutil as sh
import tempfile
Expand Down
12 changes: 7 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -88,19 +88,20 @@ a11y = ["pytest-playwright"]
ignore = ["D001"] # we follow a 1 line = 1 paragraph style

[tool.ruff]
ignore-init-module-imports = true
fix = true
select = ["E", "F", "W", "I", "D", "RUF"]

[tool.ruff.lint]
ignore = [
"E501", # line too long | Black take care of it
"D107", # Missing docstring in `__init__` | set the docstring in the class

]
ignore-init-module-imports = true
select = ["E", "F", "W", "I", "D", "RUF"]

[tool.ruff.flake8-quotes]
[tool.ruff.lint.flake8-quotes]
docstring-quotes = "double"

[tool.ruff.pydocstyle]
[tool.ruff.lint.pydocstyle]
convention = "google"

[tool.djlint]
Expand All @@ -119,6 +120,7 @@ markers = "a11y: mark a test as an accessibility test"
[tool.coverage.run]
source = ["pydata_sphinx_theme"]
branch = true
relative_files = true

[tool.coverage.report]
fail_under = 60
Expand Down
2 changes: 1 addition & 1 deletion src/pydata_sphinx_theme/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

from . import edit_this_page, logo, pygment, short_link, toctree, translator, utils

__version__ = "0.15.3dev0"
__version__ = "0.15.3rc1"


def update_config(app):
Expand Down
2 changes: 1 addition & 1 deletion src/pydata_sphinx_theme/assets/scripts/bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import "../styles/bootstrap.scss";
*/
function TriggerTooltip() {
var tooltipTriggerList = [].slice.call(
document.querySelectorAll('[data-bs-toggle="tooltip"]')
document.querySelectorAll('[data-bs-toggle="tooltip"]'),
);
tooltipTriggerList.map(function (tooltipTriggerEl) {
return new bootstrap.Tooltip(tooltipTriggerEl, {
Expand Down
24 changes: 12 additions & 12 deletions src/pydata_sphinx_theme/assets/scripts/pydata-sphinx-theme.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ function scrollToActive() {
// Inspired on source of revealjs.com
let storedScrollTop = parseInt(
sessionStorage.getItem("sidebar-scroll-top"),
10
10,
);

if (!isNaN(storedScrollTop)) {
Expand Down Expand Up @@ -194,7 +194,7 @@ var findSearchInput = () => {
} else {
// must be at least one persistent form, use the first persistent one
form = document.querySelector(
"div:not(.search-button__search-container) > form.bd-search"
"div:not(.search-button__search-container) > form.bd-search",
);
}
return form.querySelector("input");
Expand Down Expand Up @@ -255,7 +255,7 @@ var addEventListenerForSearchKeyboard = () => {
toggleSearchField();
}
},
true
true,
);
};

Expand All @@ -278,7 +278,7 @@ var changeSearchShortcutKey = () => {
let shortcuts = document.querySelectorAll(".search-button__kbd-shortcut");
if (useCommandKey) {
shortcuts.forEach(
(f) => (f.querySelector("kbd.kbd-shortcut__modifier").innerText = "⌘")
(f) => (f.querySelector("kbd.kbd-shortcut__modifier").innerText = "⌘"),
);
}
};
Expand Down Expand Up @@ -404,7 +404,7 @@ function populateVersionSwitcher(data, versionSwitcherBtns) {
const anchor = document.createElement("a");
anchor.setAttribute(
"class",
"dropdown-item list-group-item list-group-item-action py-1"
"dropdown-item list-group-item list-group-item-action py-1",
);
anchor.setAttribute("href", `${entry.url}${currentFilePath}`);
anchor.setAttribute("role", "option");
Expand Down Expand Up @@ -464,7 +464,7 @@ function showVersionWarningBanner(data) {
if (preferredEntries.length !== 1) {
const howMany = preferredEntries.length == 0 ? "No" : "Multiple";
console.log(
`[PST] ${howMany} versions marked "preferred" found in versions JSON, ignoring.`
`[PST] ${howMany} versions marked "preferred" found in versions JSON, ignoring.`,
);
return;
}
Expand Down Expand Up @@ -520,7 +520,7 @@ function showVersionWarningBanner(data) {
// At least 3rem height
const autoHeight = Math.max(
outer.offsetHeight,
3 * parseFloat(getComputedStyle(document.documentElement).fontSize)
3 * parseFloat(getComputedStyle(document.documentElement).fontSize),
);
// Set height and vertical padding to 0 to prepare the height transition
outer.style.setProperty("height", 0);
Expand Down Expand Up @@ -575,17 +575,17 @@ function initRTDObserver() {
// fetch the JSON version data (only once), then use it to populate the version
// switcher and maybe show the version warning bar
var versionSwitcherBtns = document.querySelectorAll(
".version-switcher__button"
".version-switcher__button",
);
const hasSwitcherMenu = versionSwitcherBtns.length > 0;
const hasVersionsJSON = DOCUMENTATION_OPTIONS.hasOwnProperty(
"theme_switcher_json_url"
"theme_switcher_json_url",
);
const wantsWarningBanner = DOCUMENTATION_OPTIONS.show_version_warning_banner;

if (hasVersionsJSON && (hasSwitcherMenu || wantsWarningBanner)) {
const data = await fetchVersionSwitcherJSON(
DOCUMENTATION_OPTIONS.theme_switcher_json_url
DOCUMENTATION_OPTIONS.theme_switcher_json_url,
);
// 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.
Expand All @@ -602,7 +602,7 @@ if (hasVersionsJSON && (hasSwitcherMenu || wantsWarningBanner)) {
*/
function fixMoreLinksInMobileSidebar() {
const dropdown = document.querySelector(
".bd-sidebar-primary [id^=pst-nav-more-links]"
".bd-sidebar-primary [id^=pst-nav-more-links]",
);
if (dropdown !== null) {
dropdown.classList.add("show");
Expand All @@ -620,7 +620,7 @@ function setupMobileSidebarKeyboardHandlers() {
// allows the mobile sidebars to be hidden or revealed via CSS.
const primaryToggle = document.getElementById("pst-primary-sidebar-checkbox");
const secondaryToggle = document.getElementById(
"pst-secondary-sidebar-checkbox"
"pst-secondary-sidebar-checkbox",
);
const primarySidebar = document.querySelector(".bd-sidebar-primary");
const secondarySidebar = document.querySelector(".bd-sidebar-secondary");
Expand Down
11 changes: 5 additions & 6 deletions src/pydata_sphinx_theme/assets/styles/abstracts/_links.scss
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,12 @@ $link-hover-decoration-thickness: unquote("max(3px, .1875rem, .12em)") !default;
}

// Simple hover style - can be used alone or in conjunction with other mixins
// Add the text underline and change in thickness on hover
// Add the text underline and change in thickness on hover.
// Intended for use with the `:hover` pseudo-class.
@mixin link-style-hover {
&:hover {
@include link-decoration;
@include link-decoration-hover;
color: var(--pst-color-link-hover);
}
@include link-decoration;
@include link-decoration-hover;
color: var(--pst-color-link-hover);
}

// Default link styles
Expand Down
3 changes: 2 additions & 1 deletion src/pydata_sphinx_theme/assets/styles/abstracts/_mixins.scss
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
* A consistent box shadow style we apply across elements.
*/
@mixin box-shadow() {
box-shadow: 0 0.2rem 0.5rem var(--pst-color-shadow),
box-shadow:
0 0.2rem 0.5rem var(--pst-color-shadow),
0 0 0.0625rem var(--pst-color-shadow) !important;
}

Expand Down
Loading

0 comments on commit 963b51a

Please sign in to comment.