diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 9ee7a2908..aea77d683 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -6,59 +6,56 @@ env: COVERAGE_THRESHOLD: 60 jobs: - lint: - runs-on: ubuntu-latest strategy: matrix: python-version: [3.8] steps: - - uses: actions/checkout@v2 - - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v1 - with: - python-version: ${{ matrix.python-version }} - - - name: Set up Node/yarn - uses: actions/setup-node@v1 - with: - node-version: '16.x' - - - name: Cache python wheels - uses: actions/cache@v2 - with: - path: ~/.cache/pip - key: | - ${{ runner.os }}-pip-${{ matrix.python-version }}-${{ hashFiles('setup.py', 'docs/requirements.txt') }} - restore-keys: | - ${{ runner.os }}-pip-${{ matrix.python-version }}- - ${{ runner.os }}-pip- - - - name: Cache node_modules - uses: actions/cache@v2 - with: - path: 'node_modules' - key: | - ${{ runner.os }}-node-modules-${{ hashFiles('yarn.lock') }} - - - name: Install dependencies - run: | - python -m pip install --upgrade pip setuptools wheel - python -m pip install --upgrade pre-commit - python -m pip install -e . - yarn --frozen-lockfile - - - name: Lint - run: | - pre-commit run --all-files + - uses: actions/checkout@v2 + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v1 + with: + python-version: ${{ matrix.python-version }} + + - name: Set up Node/yarn + uses: actions/setup-node@v1 + with: + node-version: "16.x" + + - name: Cache python wheels + uses: actions/cache@v2 + with: + path: ~/.cache/pip + key: | + ${{ runner.os }}-pip-${{ matrix.python-version }}-${{ hashFiles('setup.py', 'docs/requirements.txt') }} + restore-keys: | + ${{ runner.os }}-pip-${{ matrix.python-version }}- + ${{ runner.os }}-pip- + + - name: Cache node_modules + uses: actions/cache@v2 + with: + path: "node_modules" + key: | + ${{ runner.os }}-node-modules-${{ hashFiles('yarn.lock') }} + + - name: Install dependencies + run: | + python -m pip install --upgrade pip setuptools wheel + python -m pip install --upgrade pre-commit + python -m pip install -e . + yarn --frozen-lockfile + + - name: Lint + run: | + pre-commit run --all-files # Build docs on a number of Python versions. In the future this can be # where tests go. tests: - runs-on: ubuntu-latest strategy: matrix: @@ -68,49 +65,48 @@ jobs: dev: true steps: - - uses: actions/checkout@v2 - - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v1 - with: - python-version: ${{ matrix.python-version }} - - - name: Cache python wheels - uses: actions/cache@v2 - with: - path: ~/.cache/pip - key: | - ${{ runner.os }}-pip-${{ matrix.python-version }}-${{ hashFiles('setup.py', 'docs/requirements.txt') }} - restore-keys: | - ${{ runner.os }}-pip-${{ matrix.python-version }}- - ${{ runner.os }}-pip- - - - name: Install dependencies - run: | - python -m pip install --upgrade pip setuptools wheel - python -m pip install -e .[coverage] - - - name: Install pre-release dependencies - if: ${{ matrix.dev }} - run: pip install --upgrade --pre sphinx jinja2 - - # Build the docs - - name: Build docs to store - run: | - export PATH="$HOME/miniconda/bin:$PATH" - sphinx-build -b html docs/ docs/_build/html -W --keep-going - - # Run tests under coverage - - name: Run the tests - run: pytest --cov pydata_sphinx_theme --cov-branch --cov-report term-missing:skip-covered --cov-fail-under ${{ env.COVERAGE_THRESHOLD }} - - - name: Upload coverage - if: ${{ always() }} - run: codecov + - uses: actions/checkout@v2 + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v1 + with: + python-version: ${{ matrix.python-version }} + + - name: Cache python wheels + uses: actions/cache@v2 + with: + path: ~/.cache/pip + key: | + ${{ runner.os }}-pip-${{ matrix.python-version }}-${{ hashFiles('setup.py', 'docs/requirements.txt') }} + restore-keys: | + ${{ runner.os }}-pip-${{ matrix.python-version }}- + ${{ runner.os }}-pip- + + - name: Install dependencies + run: | + python -m pip install --upgrade pip setuptools wheel + python -m pip install -e .[coverage] + + - name: Install pre-release dependencies + if: ${{ matrix.dev }} + run: pip install --upgrade --pre sphinx jinja2 + + # Build the docs + - name: Build docs to store + run: | + export PATH="$HOME/miniconda/bin:$PATH" + sphinx-build -b html docs/ docs/_build/html -W --keep-going + + # Run tests under coverage + - name: Run the tests + run: pytest --cov pydata_sphinx_theme --cov-branch --cov-report term-missing:skip-covered --cov-fail-under ${{ env.COVERAGE_THRESHOLD }} + + - name: Upload coverage + if: ${{ always() }} + run: codecov # Run local Lighthouse audit against built site audit: - runs-on: ubuntu-latest strategy: matrix: @@ -124,98 +120,97 @@ jobs: PA11Y_BUILD: /tmp/pa11y/pa11y-${{ github.run_number }} steps: - - uses: actions/checkout@v2 - - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v1 - with: - python-version: ${{ matrix.python-version }} - - - name: Set up Node/yarn - uses: actions/setup-node@v1 - with: - node-version: '16.x' - - - name: Cache python wheels - uses: actions/cache@v2 - with: - path: ~/.cache/pip - key: | - ${{ runner.os }}-pip-${{ matrix.python-version }}-${{ hashFiles('setup.py', 'docs/requirements.txt') }} - restore-keys: | - ${{ runner.os }}-pip-${{ matrix.python-version }}- - ${{ runner.os }}-pip- - - - name: Cache node_modules - uses: actions/cache@v2 - with: - path: 'node_modules' - key: | - ${{ runner.os }}-node-modules-${{ hashFiles('yarn.lock') }} - - - name: Install dependencies - run: | - python -m pip install --upgrade pip wheel setuptools - python -m pip install -e .[coverage] - yarn --frozen-lockfile - - # Build the docs - - name: Build docs to store - run: | - export PATH="$HOME/miniconda/bin:$PATH" - sphinx-build -b html docs/ docs/_build/html -W --keep-going - - # Serve the docs and wait to be ready - - name: Serve the built site - run: | - nohup python docs/serve.py --port=${PORT} --host=${HOST} & - curl --retry 10 --retry-connrefused --retry-max-time 60 ${URL}/index.html - - # Run the audit - # TODO: use the hosted API with a secret? would allow for comparison over time... - - name: Make folder for Lighthouse reports - run: mkdir -p /tmp/lighthouse/lighthouse-${{ github.run_number }} - - - name: Run Lighthouse on Site - id: lighthouse - uses: foo-software/lighthouse-check-action@v2.0.0 - with: - # TODO: generate this list to audit all html pages - urls: >- - ${{ env.URL }}/index.html, - ${{ env.URL }}/demo/api.html, - ${{ env.URL }}/demo/demo.html, - ${{ env.URL }}/demo/example_pandas.html, - ${{ env.URL }}/user_guide/accessibility.html - outputDirectory: /tmp/lighthouse/lighthouse-${{ github.run_number }} - verbose: true - - - name: Run the accessibility audit - run: python docs/a11y.py --no-serve - - # Check the audit for threshold values - # TODO: write this someplace after a PR is merged, and load? - - name: Assess Lighthouse Check results - uses: foo-software/lighthouse-check-status-action@v1.0.1 - with: - lighthouseCheckResults: ${{ steps.lighthouse.outputs.lighthouseCheckResults }} - minAccessibilityScore: "96" - minBestPracticesScore: "85" - minPerformanceScore: "10" - minSeoScore: "80" - if: always() - - - name: Publish Audit reports - uses: actions/upload-artifact@v2 - with: - name: Pa11y and Lighthouse ${{ github.run_number }} - path: | - /tmp/pa11y - /tmp/lighthouse - if: always() + - uses: actions/checkout@v2 - publish: + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v1 + with: + python-version: ${{ matrix.python-version }} + - name: Set up Node/yarn + uses: actions/setup-node@v1 + with: + node-version: "16.x" + + - name: Cache python wheels + uses: actions/cache@v2 + with: + path: ~/.cache/pip + key: | + ${{ runner.os }}-pip-${{ matrix.python-version }}-${{ hashFiles('setup.py', 'docs/requirements.txt') }} + restore-keys: | + ${{ runner.os }}-pip-${{ matrix.python-version }}- + ${{ runner.os }}-pip- + + - name: Cache node_modules + uses: actions/cache@v2 + with: + path: "node_modules" + key: | + ${{ runner.os }}-node-modules-${{ hashFiles('yarn.lock') }} + + - name: Install dependencies + run: | + python -m pip install --upgrade pip wheel setuptools + python -m pip install -e .[coverage] + yarn --frozen-lockfile + + # Build the docs + - name: Build docs to store + run: | + export PATH="$HOME/miniconda/bin:$PATH" + sphinx-build -b html docs/ docs/_build/html -W --keep-going + + # Serve the docs and wait to be ready + - name: Serve the built site + run: | + nohup python docs/serve.py --port=${PORT} --host=${HOST} & + curl --retry 10 --retry-connrefused --retry-max-time 60 ${URL}/index.html + + # Run the audit + # TODO: use the hosted API with a secret? would allow for comparison over time... + - name: Make folder for Lighthouse reports + run: mkdir -p /tmp/lighthouse/lighthouse-${{ github.run_number }} + + - name: Run Lighthouse on Site + id: lighthouse + uses: foo-software/lighthouse-check-action@v2.0.0 + with: + # TODO: generate this list to audit all html pages + urls: >- + ${{ env.URL }}/index.html, + ${{ env.URL }}/demo/api.html, + ${{ env.URL }}/demo/demo.html, + ${{ env.URL }}/demo/example_pandas.html, + ${{ env.URL }}/user_guide/accessibility.html + outputDirectory: /tmp/lighthouse/lighthouse-${{ github.run_number }} + verbose: true + + - name: Run the accessibility audit + run: python docs/a11y.py --no-serve + + # Check the audit for threshold values + # TODO: write this someplace after a PR is merged, and load? + - name: Assess Lighthouse Check results + uses: foo-software/lighthouse-check-status-action@v1.0.1 + with: + lighthouseCheckResults: ${{ steps.lighthouse.outputs.lighthouseCheckResults }} + minAccessibilityScore: "96" + minBestPracticesScore: "85" + minPerformanceScore: "10" + minSeoScore: "80" + if: always() + + - name: Publish Audit reports + uses: actions/upload-artifact@v2 + with: + name: Pa11y and Lighthouse ${{ github.run_number }} + path: | + /tmp/pa11y + /tmp/lighthouse + if: always() + + publish: name: Publish to PyPi needs: [lint, tests] if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags') diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index daa88acc3..a31ed0509 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -10,6 +10,13 @@ repos: entry: bash -c "yarn build:production" files: ^src/* + - repo: https://github.com/pre-commit/mirrors-prettier + rev: v2.4.1 + hooks: + - id: prettier + # Exclude the HTML, since it doesn't understand Jinja2 + exclude: .+((\.html)|index\.(.+)\.css)$ + - repo: https://github.com/psf/black rev: 20.8b1 hooks: diff --git a/README.md b/README.md index 3a140459d..f2940f165 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,6 @@ Sites that are using this theme: - MNE-Python: https://mne.tools/stable/index.html - PyVista: https://docs.pyvista.org - ## Installation and usage The theme is available on PyPI and conda-forge. You can install @@ -62,7 +61,6 @@ more detail in the contributing section of the documentation: - [Contributing source files](docs/contributing.md) - [Contributing rendered docs](https://pydata-sphinx-theme.readthedocs.io/en/latest/contributing.html) - ## How is this theme working? ### The html layout diff --git a/docs/demo/markdown.md b/docs/demo/markdown.md index c0c7dca8b..b5a959694 100644 --- a/docs/demo/markdown.md +++ b/docs/demo/markdown.md @@ -12,18 +12,15 @@ Here's a horizontal rule: It separates major sections of content. - - ## Footnotes Here's a footnote [^myfootnote]. And it should show up at the bottom! [^myfootnote]: Here's the text for the footnote! - ## Tables -| Syntax | Description | Test Text | -| :--- | :----: | ---: | -| Header | Title | Here's this | -| Paragraph | Text | And more | +| Syntax | Description | Test Text | +| :-------- | :---------: | ----------: | +| Header | Title | Here's this | +| Paragraph | Text | And more | diff --git a/environment.yml b/environment.yml index dadf388fa..1fdad6229 100644 --- a/environment.yml +++ b/environment.yml @@ -1,10 +1,10 @@ name: pydata-theme-dev channels: -- conda-forge + - conda-forge dependencies: -- yarn -- nodejs>=14,<15 # We should use whatever the LTS is at https://nodejs.org/en/ -- "python=3.10" -- pip -- pip: - - -r docs/requirements.txt + - yarn + - nodejs>=14,<15 # We should use whatever the LTS is at https://nodejs.org/en/ + - "python=3.10" + - pip + - pip: + - -r docs/requirements.txt diff --git a/readthedocs.yml b/readthedocs.yml index 8f9cb8ef1..7a7fac8f8 100644 --- a/readthedocs.yml +++ b/readthedocs.yml @@ -1,10 +1,10 @@ version: 2 formats: - - htmlzip + - htmlzip python: - version: 3 - install: - - requirements: docs/requirements.txt - - method: pip - path: . + version: 3 + install: + - requirements: docs/requirements.txt + - method: pip + path: . diff --git a/src/js/index.js b/src/js/index.js index eeeab2c04..255f6103a 100644 --- a/src/js/index.js +++ b/src/js/index.js @@ -7,12 +7,12 @@ * To enable Popper.js (and other jQuery plugins) to hook into the same instancce of jQuery, * jQuery is defined as a Webpack external, thus this import uses the externally defined jquery dependency. */ -import 'jquery'; +import "jquery"; -import 'popper.js'; -import 'bootstrap'; +import "popper.js"; +import "bootstrap"; -import './../scss/index.scss'; +import "./../scss/index.scss"; function addTOCInteractivity() { // TOC sidebar - add "active" class to parent list @@ -22,57 +22,57 @@ function addTOCInteractivity() { // // The event is triggered on "window" (and not the nav item as documented), // see https://github.com/twbs/bootstrap/issues/20086 - $(window).on('activate.bs.scrollspy', function () { - const navLinks = document.querySelectorAll('#bd-toc-nav a'); + $(window).on("activate.bs.scrollspy", function () { + const navLinks = document.querySelectorAll("#bd-toc-nav a"); navLinks.forEach((navLink) => { - navLink.parentElement.classList.remove('active'); + navLink.parentElement.classList.remove("active"); }); - const activeNavLinks = document.querySelectorAll('#bd-toc-nav a.active'); + const activeNavLinks = document.querySelectorAll("#bd-toc-nav a.active"); activeNavLinks.forEach((navLink) => { - navLink.parentElement.classList.add('active'); + navLink.parentElement.classList.add("active"); }); }); } - // Navigation sidebar scrolling to active page function scrollToActive() { - var sidebar = document.getElementById('bd-docs-nav') + var sidebar = document.getElementById("bd-docs-nav"); // Remember the sidebar scroll position between page loads // Inspired on source of revealjs.com - let storedScrollTop = parseInt(sessionStorage.getItem('sidebar-scroll-top'), 10); + let storedScrollTop = parseInt( + sessionStorage.getItem("sidebar-scroll-top"), + 10 + ); if (!isNaN(storedScrollTop)) { sidebar.scrollTop = storedScrollTop; - } - else { - var active_pages = sidebar.querySelectorAll(".active") - var offset = 0 + } else { + var active_pages = sidebar.querySelectorAll(".active"); + var offset = 0; var i; for (i = active_pages.length - 1; i > 0; i--) { - var active_page = active_pages[i] + var active_page = active_pages[i]; if (active_page !== undefined) { - offset += active_page.offsetTop + offset += active_page.offsetTop; } } - offset -= sidebar.offsetTop + offset -= sidebar.offsetTop; // Only scroll the navbar if the active link is lower than 50% of the page - if (active_page !== undefined && offset > (sidebar.clientHeight * .5)) { - sidebar.scrollTop = offset - (sidebar.clientHeight * .2) + if (active_page !== undefined && offset > sidebar.clientHeight * 0.5) { + sidebar.scrollTop = offset - sidebar.clientHeight * 0.2; } } // Store the sidebar scroll position - window.addEventListener('beforeunload', () => { - sessionStorage.setItem('sidebar-scroll-top', sidebar.scrollTop); + window.addEventListener("beforeunload", () => { + sessionStorage.setItem("sidebar-scroll-top", sidebar.scrollTop); }); } - $(document).ready(() => { scrollToActive(); addTOCInteractivity(); diff --git a/src/scss/_admonitions.scss b/src/scss/_admonitions.scss index ccf1b08c7..2f09242e8 100644 --- a/src/scss/_admonitions.scss +++ b/src/scss/_admonitions.scss @@ -1,6 +1,7 @@ // Admonitions CSS originally inspired by https://squidfunk.github.io/mkdocs-material/getting-started/ -div.admonition, .admonition{ +div.admonition, +.admonition { margin: 1.5625em auto; padding: 0 0.6rem 0.8rem 0.6rem; overflow: hidden; @@ -8,7 +9,8 @@ div.admonition, .admonition{ border-left: 0.2rem solid; border-color: rgba(var(--pst-color-admonition-default), 1); border-radius: 0.2rem; - box-shadow: 0 0.2rem 0.5rem rgba(0, 0, 0, 0.05), 0 0 0.0625rem rgba(0, 0, 0, 0.1); + box-shadow: 0 0.2rem 0.5rem rgba(0, 0, 0, 0.05), + 0 0 0.0625rem rgba(0, 0, 0, 0.1); transition: color 250ms, background-color 250ms, border-color 250ms; // Last item should have no spacing since we'll control that w/ padding @@ -22,8 +24,9 @@ div.admonition, .admonition{ } // Lists need to have left margin so they don't spill into it - > ol, > ul { - margin-left: 1em; + > ol, + > ul { + margin-left: 1em; } // Defaults for all admonitions @@ -40,7 +43,7 @@ div.admonition, .admonition{ width: 1rem; height: 1rem; color: rgba(var(--pst-color-admonition-default), 1); - font-family: 'Font Awesome 5 Free'; + font-family: "Font Awesome 5 Free"; font-weight: 900; content: var(--pst-icon-admonition-default); } diff --git a/src/scss/_api.scss b/src/scss/_api.scss index b70bdfdd2..0060997fa 100644 --- a/src/scss/_api.scss +++ b/src/scss/_api.scss @@ -1,6 +1,5 @@ // Style API docs from sphinx' autodoc / autosummary - /** * Styling for field lists */ @@ -41,39 +40,41 @@ table.field-list { */ .table.autosummary { -// The first column (with the signature) should not wrap + // The first column (with the signature) should not wrap td:first-child { - white-space: nowrap; + white-space: nowrap; } } - /* overriding basic.css to use our own monospace font */ .sig { - font-family: var(--pst-font-family-monospace); + font-family: var(--pst-font-family-monospace); } - /* C++ specific styling - overriding the basic.css to avoid custom colors*/ .sig-inline.c-texpr, .sig-inline.cpp-texpr { - font-family: unset; + font-family: unset; } -.sig.c .k, .sig.c .kt, -.sig.cpp .k, .sig.cpp .kt { - color: rgba(var(--pst-color-text-base), 1); +.sig.c .k, +.sig.c .kt, +.sig.cpp .k, +.sig.cpp .kt { + color: rgba(var(--pst-color-text-base), 1); } -.sig.c .m, +.sig.c .m, .sig.cpp .m { - color: rgba(var(--pst-color-text-base), 1); + color: rgba(var(--pst-color-text-base), 1); } -.sig.c .s, .sig.c .sc, -.sig.cpp .s, .sig.cpp .sc { - color: rgba(var(--pst-color-text-base), 1); +.sig.c .s, +.sig.c .sc, +.sig.cpp .s, +.sig.cpp .sc { + color: rgba(var(--pst-color-text-base), 1); } // addition diff --git a/src/scss/_base.scss b/src/scss/_base.scss index 77823a0c1..ab542f02c 100644 --- a/src/scss/_base.scss +++ b/src/scss/_base.scss @@ -124,7 +124,7 @@ pre { // Override bootstrap by restoring the basic theme default. dd { - margin-top: 3px; - margin-bottom: 10px; - margin-left: 30px; + margin-top: 3px; + margin-bottom: 10px; + margin-left: 30px; } diff --git a/src/scss/_markdown.scss b/src/scss/_markdown.scss index 8bff8dd77..44d90e951 100644 --- a/src/scss/_markdown.scss +++ b/src/scss/_markdown.scss @@ -1,6 +1,7 @@ // Rules that are unique to MyST markdown parsing / outputs -th, td { +th, +td { &.text-align\:left { text-align: left; } diff --git a/src/scss/_navbar.scss b/src/scss/_navbar.scss index d151cf577..4a614029d 100644 --- a/src/scss/_navbar.scss +++ b/src/scss/_navbar.scss @@ -11,7 +11,7 @@ @include media-breakpoint-up(lg) { // navbar-end-items should be on one line if possible #navbar-end > .navbar-end-item { - display: inline-block; + display: inline-block; } } } @@ -32,12 +32,12 @@ // If we want the shadow to only point downward in the future, set // box-shadow to: 0 0.125rem 0.25rem -0.125rem rgba(0, 0, 0, 0.11); .navbar-light { - background: #fff!important; // Overrides bootstrap + background: #fff !important; // Overrides bootstrap box-shadow: 0 0.125rem 0.25rem 0 rgba(0, 0, 0, 0.11); .navbar-nav { li a.nav-link { - padding: 0 .5rem; + padding: 0 0.5rem; color: rgba(var(--pst-color-navbar-link), 1); &:hover { diff --git a/src/scss/_versionmodified.scss b/src/scss/_versionmodified.scss index 4d075dcc7..f9cebfc82 100644 --- a/src/scss/_versionmodified.scss +++ b/src/scss/_versionmodified.scss @@ -1,4 +1,6 @@ -div.versionadded, div.versionchanged, div.deprecated { +div.versionadded, +div.versionchanged, +div.deprecated { vertical-align: middle; margin: 1.5625em auto; padding: 0 0.6rem 0 0.6rem; @@ -7,7 +9,8 @@ div.versionadded, div.versionchanged, div.deprecated { border-left: 0.2rem solid; border-color: rgba(var(--pst-color-versionmodified-default), 1); border-radius: 0.2rem; - box-shadow: 0 0.2rem 0.5rem rgba(0, 0, 0, 0.05), 0 0 0.0625rem rgba(0, 0, 0, 0.1); + box-shadow: 0 0.2rem 0.5rem rgba(0, 0, 0, 0.05), + 0 0 0.0625rem rgba(0, 0, 0, 0.1); transition: color 250ms, background-color 250ms, border-color 250ms; background-color: rgba(var(--pst-color-admonition-default), 0.1); @@ -15,7 +18,6 @@ div.versionadded, div.versionchanged, div.deprecated { margin-bottom: 0.6rem; margin-top: 0.6rem; } - } div.versionadded { @@ -40,7 +42,7 @@ span.versionmodified { font-style: normal; margin-right: 0.6rem; color: rgba(var(--pst-color-versionmodified-default), 1); - font-family: 'Font Awesome 5 Free'; + font-family: "Font Awesome 5 Free"; font-weight: 900; content: var(--pst-icon-versionmodified-default); } diff --git a/src/scss/index.scss b/src/scss/index.scss index c6e64c022..a0dcf5466 100644 --- a/src/scss/index.scss +++ b/src/scss/index.scss @@ -17,21 +17,21 @@ $grid-breakpoints: ( ); // Import Bootstrap core -@import '~bootstrap/scss/bootstrap'; +@import "~bootstrap/scss/bootstrap"; -@import './base'; -@import './navbar'; -@import './admonitions'; -@import './api'; -@import './markdown'; -@import './versionmodified'; +@import "./base"; +@import "./navbar"; +@import "./admonitions"; +@import "./api"; +@import "./markdown"; +@import "./versionmodified"; // Custom css, TODO: to be refactored in different partials // GitHub blockquote style blockquote { padding: 0 1em; color: #6a737d; - border-left: .25em solid #dfe2e5; + border-left: 0.25em solid #dfe2e5; } // For consistency, add bracket around footnotes/citations which are @@ -84,7 +84,6 @@ span.guilabel { */ footer { - width: 100%; border-top: 1px solid #ccc; padding: 10px; @@ -197,7 +196,6 @@ footer { @include media-breakpoint-up(md) { display: block; - } } @@ -254,24 +252,22 @@ footer { } nav.bd-links { - p.caption { - font-size: var(--pst-sidebar-caption-font-size); - text-transform: uppercase; - font-weight: bold; - position: relative; - margin-top: 1.25em; - margin-bottom: 0.5em; - padding: 0 1.5rem; - color: rgba(var(--pst-color-sidebar-caption), 1); - &:first-child { - margin-top: 0; - } + font-size: var(--pst-sidebar-caption-font-size); + text-transform: uppercase; + font-weight: bold; + position: relative; + margin-top: 1.25em; + margin-bottom: 0.5em; + padding: 0 1.5rem; + color: rgba(var(--pst-color-sidebar-caption), 1); + &:first-child { + margin-top: 0; + } } } .bd-sidebar .nav { - font-size: var(--pst-sidebar-font-size); ul { @@ -292,11 +288,11 @@ nav.bd-links { &.reference.external { &:after { - font-family: 'Font Awesome 5 Free'; + font-family: "Font Awesome 5 Free"; font-weight: 900; - content: '\f35d'; - font-size: .75em; - margin-left: 0.3em + content: "\f35d"; + font-size: 0.75em; + margin-left: 0.3em; } } } @@ -397,7 +393,7 @@ nav.bd-links { .prev-next-info { flex-direction: column; - margin: 0 .5em; + margin: 0 0.5em; .prev-next-subtitle { text-transform: capitalize; @@ -437,7 +433,7 @@ nav.bd-links { &.fa, &.fab, &.far, - &.fas{ + &.fas { vertical-align: middle; font-style: normal; font-size: 1.5rem; @@ -454,7 +450,7 @@ nav.bd-links { } &.fa-gitlab:before { - color: #548 + color: #548; } &.fa-bitbucket:before { @@ -463,7 +459,6 @@ nav.bd-links { } } - /* TOC section headers */ .tocsection { @@ -488,15 +483,13 @@ nav.bd-links { // xarray output display in bootstrap .xr-wrap[hidden] { - display: block!important; + display: block !important; } - //////////////////////////////////////////////////////////////////////////////// // Togglable expand/collapse //////////////////////////////////////////////////////////////////////////////// - .toctree-checkbox { position: absolute; display: none; @@ -519,9 +512,7 @@ nav.bd-links { } } - .bd-sidebar { - li { position: relative; } @@ -566,7 +557,8 @@ nav.bd-links { // From https://stackoverflow.com/a/34372191 table.highlighttable td.linenos, span.linenos, -div.doctest > div.highlight span.gp { /* gp: Generic.Prompt */ +div.doctest > div.highlight span.gp { + /* gp: Generic.Prompt */ user-select: none; -webkit-user-select: text; /* Safari fallback only */ -webkit-user-select: none; /* Chrome/Safari */ diff --git a/webpack.js b/webpack.js index 330fc015c..4ad37bec4 100644 --- a/webpack.js +++ b/webpack.js @@ -1,29 +1,29 @@ -const { resolve } = require('path'); -const webpack = require('webpack'); -const { CleanWebpackPlugin } = require('clean-webpack-plugin'); -const HtmlWebpackPlugin = require('html-webpack-plugin'); -const CopyPlugin = require('copy-webpack-plugin'); +const { resolve } = require("path"); +const webpack = require("webpack"); +const { CleanWebpackPlugin } = require("clean-webpack-plugin"); +const HtmlWebpackPlugin = require("html-webpack-plugin"); +const CopyPlugin = require("copy-webpack-plugin"); const OptimizeCssAssetsPlugin = require("optimize-css-assets-webpack-plugin"); const TerserPlugin = require("terser-webpack-plugin"); -const staticPath = resolve(__dirname, 'pydata_sphinx_theme', 'static'); +const staticPath = resolve(__dirname, "pydata_sphinx_theme", "static"); -const vendor = resolve(staticPath, 'vendor'); +const vendor = resolve(staticPath, "vendor"); const vendorVersions = { - fontAwesome: require('@fortawesome/fontawesome-free/package.json').version, + fontAwesome: require("@fortawesome/fontawesome-free/package.json").version, }; const vendorPaths = { - fontAwesome: resolve(vendor, 'fontawesome', vendorVersions.fontAwesome), + fontAwesome: resolve(vendor, "fontawesome", vendorVersions.fontAwesome), }; // generates cache-busting templates to be used in `layout.html` without knowing versions function macroTemplate({ compilation }) { const indexes = Object.keys(compilation.assets).filter( - (file) => file.indexOf('/index.') != -1 + (file) => file.indexOf("/index.") != -1 ); - const css = indexes.filter((file) => file.endsWith('.css')); - const js = indexes.filter((file) => file.endsWith('.js')); + const css = indexes.filter((file) => file.endsWith(".css")); + const js = indexes.filter((file) => file.endsWith(".js")); const stylesheet = (css) => { return `\ @@ -59,34 +59,34 @@ function macroTemplate({ compilation }) { {% endmacro %} {% macro head_pre_bootstrap() %} - ${css.map(stylesheet).join('\n')} + ${css.map(stylesheet).join("\n")} {% endmacro %} {% macro head_js_preload() %} - ${js.map(preload).join('\n')} + ${js.map(preload).join("\n")} {% endmacro %} {% macro body_post() %} - ${js.map(script).join('\n')} + ${js.map(script).join("\n")} {% endmacro %}`; } module.exports = { mode: "production", entry: { - index: ['./src/js/index.js'], + index: ["./src/js/index.js"], }, output: { - filename: 'js/[name].[hash].js', + filename: "js/[name].[hash].js", path: staticPath, }, optimization: { - minimizer: [new TerserPlugin(), new OptimizeCssAssetsPlugin({})] + minimizer: [new TerserPlugin(), new OptimizeCssAssetsPlugin({})], }, externals: { // Define jQuery as external, this way Sphinx related javascript // and custom javascript like popper.js can hook into jQuery. - jquery: 'jQuery', + jquery: "jQuery", }, module: { rules: [ @@ -94,19 +94,19 @@ module.exports = { test: /\.scss$/, use: [ { - loader: 'file-loader', + loader: "file-loader", options: { - name: 'css/[name].[hash].css', + name: "css/[name].[hash].css", }, }, { - loader: 'extract-loader', + loader: "extract-loader", }, { - loader: 'css-loader?-url', + loader: "css-loader?-url", }, { - loader: 'sass-loader', + loader: "sass-loader", }, ], }, @@ -114,10 +114,15 @@ module.exports = { }, plugins: [ new CleanWebpackPlugin({ - cleanOnceBeforeBuildPatterns: ['**/*', '!css', '!css/theme.css', '!css/blank.css'], + cleanOnceBeforeBuildPatterns: [ + "**/*", + "!css", + "!css/theme.css", + "!css/blank.css", + ], }), new HtmlWebpackPlugin({ - filename: resolve(staticPath, 'webpack-macros.html'), + filename: resolve(staticPath, "webpack-macros.html"), inject: false, minify: false, css: true, @@ -126,19 +131,19 @@ module.exports = { new CopyPlugin([ // fontawesome { - context: './node_modules/@fortawesome/fontawesome-free', - from: 'LICENSE.txt', - to: resolve(vendorPaths.fontAwesome, 'LICENSE.txt'), + context: "./node_modules/@fortawesome/fontawesome-free", + from: "LICENSE.txt", + to: resolve(vendorPaths.fontAwesome, "LICENSE.txt"), }, { - context: './node_modules/@fortawesome/fontawesome-free/css', - from: 'all.min.css', - to: resolve(vendorPaths.fontAwesome, 'css'), + context: "./node_modules/@fortawesome/fontawesome-free/css", + from: "all.min.css", + to: resolve(vendorPaths.fontAwesome, "css"), }, { - context: './node_modules/@fortawesome/fontawesome-free', - from: 'webfonts', - to: resolve(vendorPaths.fontAwesome, 'webfonts'), + context: "./node_modules/@fortawesome/fontawesome-free", + from: "webfonts", + to: resolve(vendorPaths.fontAwesome, "webfonts"), }, ]), ],