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

Switch to sphinx-theme-builder and improve webpack.config.js #514

Merged
merged 7 commits into from
Dec 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
File renamed without changes.
48 changes: 4 additions & 44 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,58 +8,18 @@ env:
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/setup-python@v2
- uses: pre-commit/[email protected]

# Build docs on a number of Python versions. In the future this can be
# where tests go.
tests:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.6, 3.7, 3.8, 3.9]
python-version: [3.7, 3.8, 3.9]
Copy link
Collaborator

Choose a reason for hiding this comment

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

I just want to highlight that we're dropping Python 3.6 support here, in case anybody has a strong objection. I think it is fine because it will no longer have official support soon anyway, but just making it clear here.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I guess we should also add 3.10 now?

Copy link
Collaborator

Choose a reason for hiding this comment

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

IMO we should add that explicitly in a separate PR, because we don't know if this might break something. I feel more comfortable about dropping supported versions as a side-effect, rather than adding them :-)

Copy link
Collaborator

Choose a reason for hiding this comment

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

Fair enough ;-)

include:
- python-version: 3.9
dev: true
Expand Down Expand Up @@ -211,7 +171,7 @@ jobs:
if: always()

publish:
name: Publish to PyPi
name: Publish to PyPI
needs: [lint, tests]
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags')
runs-on: ubuntu-latest
Expand Down
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,11 @@ envs/
# mypy
.mypy_cache/

# nodejs
.nodeenv/
.yarn-packages
node_modules/

# Editors
.vscode
.yarn-packages
.idea
12 changes: 2 additions & 10 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,15 +1,7 @@
# Exclude the generated static assets.
exclude: .+(/static/).+|github_deploy_key_pandas_dev_pandas_sphinx_theme\.enc
# Exclude the encrypted file.
exclude: github_deploy_key_pandas_dev_pandas_sphinx_theme\.enc

repos:
- repo: local
hooks:
- id: yarn-build-production
name: Build src files
language: system
entry: bash -c "yarn build:production"
files: ^src/*

- repo: https://github.com/pre-commit/mirrors-prettier
rev: v2.4.1
hooks:
Expand Down
4 changes: 0 additions & 4 deletions .yarnrc

This file was deleted.

16 changes: 0 additions & 16 deletions MANIFEST.in

This file was deleted.

20 changes: 0 additions & 20 deletions docs/Makefile

This file was deleted.

2 changes: 1 addition & 1 deletion docs/contributing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ To install this theme locally, along with the dependencies needed to develop it,

.. code-block:: console

$ pip install -e .[dev,test]
$ pip install -e .[dev]
pradyunsg marked this conversation as resolved.
Show resolved Hide resolved

Install javascript development dependencies
-------------------------------------------
Expand Down
35 changes: 0 additions & 35 deletions docs/make.bat

This file was deleted.

14 changes: 0 additions & 14 deletions docs/requirements.txt

This file was deleted.

4 changes: 2 additions & 2 deletions docs/user_guide/customizing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ In order to change a variable, follow these steps:
For a complete list of the theme variables that you may override, see the
`theme variables defaults CSS file <pydata-css-variables_>`_:

.. literalinclude:: ../../pydata_sphinx_theme/static/css/theme.css
.. literalinclude:: ../../src/pydata_sphinx_theme/theme/pydata_sphinx_theme/static/styles/theme.css
:language: CSS


Expand Down Expand Up @@ -125,7 +125,7 @@ The default body and header fonts can be changed as follows:
specifically the binary font files. This ensure the files will be loaded
before waiting for the CSS to be parsed, but should be used with care.

.. _pydata-css-variables: https://github.com/pydata/pydata-sphinx-theme/blob/master/pydata_sphinx_theme/static/css/theme.css
.. _pydata-css-variables: https://github.com/pydata/pydata-sphinx-theme/blob/master/src/pydata_sphinx_theme/theme/pydata_sphinx_theme/static/styles/theme.css
.. _css-variable-help: https://developer.mozilla.org/en-US/docs/Web/CSS/Using_CSS_custom_properties

.. meta::
Expand Down
10 changes: 0 additions & 10 deletions environment.yml

This file was deleted.

70 changes: 8 additions & 62 deletions noxfile.py
Original file line number Diff line number Diff line change
@@ -1,75 +1,21 @@
import nox
from pathlib import Path
from yaml import safe_load

nox.options.reuse_existing_virtualenvs = True

# Parse the environment files we'll need later
environment = safe_load(Path("environment.yml").read_text())
conda = environment.get("dependencies")
requirements = conda.pop(-1).get("pip")
build_command = ["-b", "html", "docs", "docs/_build/html"]


@nox.session(venv_backend="conda")
def build(session):
_install_environment(session)
session.run("yarn", "build")


@nox.session(venv_backend="conda")
@nox.session
def docs(session):
_install_environment(session)
session.cd("docs")
session.run("make", "html")
session.install(".[doc]")
session.run("sphinx-build", "-b=html", "docs/", "docs/_build/html")


@nox.session(name="docs-live", venv_backend="conda")
@nox.session(name="docs-live")
pradyunsg marked this conversation as resolved.
Show resolved Hide resolved
def docs_live(session):
_install_environment(session)
# fmt: off
session.run(
"sphinx-autobuild",
"--watch", "pydata_sphinx_theme",
"--watch", "src",
"--pre-build", "yarn build",
"--re-ignore", "pydata_sphinx_theme/static/.*",
"--re-ignore", "pydata_sphinx_theme/static/theme.conf",
"--re-ignore", "_build/.*",
"--delay", "2",
"--port", "0",
"--open-browser",
"-n", "-b", "html", "docs/", "docs/_build/html"
)
# fmt: on
session.install("sphinx-theme-builder[cli]")
Copy link
Member

Choose a reason for hiding this comment

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

Does this also need a session.install(".[doc]")?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think that the theme builder will automatically handle the dependencies of the local theme so we don't need to explicitly install it here, but maybe @pradyunsg can confirm that?

Copy link
Contributor Author

@pradyunsg pradyunsg Dec 2, 2021

Choose a reason for hiding this comment

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

It does need that line. I missed it.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yep, I can confirm this is needed but I guess we can fix it in a follow-up PR.

session.run("stb", "serve", "docs", "--open-browser")


@nox.session(name="test", venv_backend="conda")
@nox.session(name="test")
def test(session):
_install_environment(session, yarn=False)
session.install(".[test]")
session.install("-e", ".[test]")
session.run("pytest", *session.posargs)


def _install_environment(session, yarn=True):
"""Install the JS and Python environment needed to develop the theme."""
# Assume that if sphinx is already installed, we don't need to re-install
try:
bin = Path(session.bin)
except ValueError:
# we are in a pass-through environment, just return and not install anything
return
pradyunsg marked this conversation as resolved.
Show resolved Hide resolved

if list(bin.rglob("sphinx-build")) and "reinstall" not in session.posargs:
return

# Install JS and Python dependencies
session.conda_install("--channel", "conda-forge", *conda)
for pkg in requirements:
# We split each line in case there's a space for `-r`
session.install(*pkg.split())
session.install("-e", ".")

# Build JS packages
if yarn:
session.run("yarn", "--frozen-lockfile")
8 changes: 3 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,25 +1,23 @@
{
"name": "pydata_sphinx_theme",
"version": "0.0.1",
"main": "js/index.js",
"repository": "https://github.com/pydata/pydata-sphinx-theme",
"scripts": {
"build": "yarn build:production",
"build:production": "webpack --config webpack.js"
"build": "webpack"
},
"devDependencies": {
"clean-webpack-plugin": "^3.0.0",
"copy-webpack-plugin": "^5.1.1",
"css-loader": "^3.4.2",
"dedent": "^0.7.0",
"extract-loader": "^4.0.3",
"file-loader": "^5.0.2",
"html-webpack-plugin": "^4.3.0",
"imports-loader": "^0.8.0",
"mini-css-extract-plugin": "^0.9.0",
"node-sass": "^6.0.1",
"optimize-css-assets-webpack-plugin": "^5.0.3",
"pa11y-ci-reporter-html": "^2.1.2",
"pa11y-ci": "^2.4.0",
"pa11y-ci-reporter-html": "^2.1.2",
"sass-loader": "^10.1.1",
"style-loader": "^1.1.3",
"webpack": "^4.41.6",
Expand Down
2 changes: 0 additions & 2 deletions pydata_sphinx_theme/static/css/blank.css

This file was deleted.

This file was deleted.

32 changes: 0 additions & 32 deletions pydata_sphinx_theme/static/js/index.30d17a8aef5d942e5d26.js

This file was deleted.

34 changes: 0 additions & 34 deletions pydata_sphinx_theme/static/vendor/fontawesome/5.13.0/LICENSE.txt

This file was deleted.

This file was deleted.

Binary file not shown.
Loading