Skip to content

Commit

Permalink
Rework theme to utilise sphinx-theme-builder
Browse files Browse the repository at this point in the history
Restructure the repository to be compatible with `sphinx-theme-builder`
and switch away from setuptools. This enables excluding the generated
assets from version control, since `sphinx-theme-builder` will generate
them, when generating the wheel.

Replace the usage of `yarn` with vanilla `npm`, to be more compatible
with `sphinx-theme-builder`, and for reducing the complexity in the
setup.

Explicitly declare that this theme uses the latest 14.x LTS release of
NodeJS.

Simplify `noxfile.py` since it is no longer necessary to use conda for
fetching the theme's non-Python dependencies. It happens transparently
in a `pip` based workflow. Use `stb serve` for serving documentation,
in `noxfile.py`.

Move `flake8` configuration into a flake8-specific file.
  • Loading branch information
pradyunsg authored and choldgraf committed Dec 3, 2021
1 parent 56d5621 commit 579d7ce
Show file tree
Hide file tree
Showing 67 changed files with 154 additions and 16,283 deletions.
File renamed without changes.
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.

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]
Install javascript development dependencies
-------------------------------------------
Expand Down
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")
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]")
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

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")
5 changes: 1 addition & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
{
"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",
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

0 comments on commit 579d7ce

Please sign in to comment.