Skip to content

Commit 579d7ce

Browse files
pradyunsgcholdgraf
authored andcommitted
Rework theme to utilise sphinx-theme-builder
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.
1 parent 56d5621 commit 579d7ce

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+154
-16283
lines changed

setup.cfg renamed to .flake8

File renamed without changes.

.gitignore

+5-1
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,11 @@ envs/
103103
# mypy
104104
.mypy_cache/
105105

106+
# nodejs
107+
.nodeenv/
108+
.yarn-packages
106109
node_modules/
110+
111+
# Editors
107112
.vscode
108-
.yarn-packages
109113
.idea

.pre-commit-config.yaml

+2-10
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,7 @@
1-
# Exclude the generated static assets.
2-
exclude: .+(/static/).+|github_deploy_key_pandas_dev_pandas_sphinx_theme\.enc
1+
# Exclude the encrypted file.
2+
exclude: github_deploy_key_pandas_dev_pandas_sphinx_theme\.enc
33

44
repos:
5-
- repo: local
6-
hooks:
7-
- id: yarn-build-production
8-
name: Build src files
9-
language: system
10-
entry: bash -c "yarn build:production"
11-
files: ^src/*
12-
135
- repo: https://github.com/pre-commit/mirrors-prettier
146
rev: v2.4.1
157
hooks:

.yarnrc

-4
This file was deleted.

MANIFEST.in

-16
This file was deleted.

docs/contributing.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ To install this theme locally, along with the dependencies needed to develop it,
188188

189189
.. code-block:: console
190190
191-
$ pip install -e .[dev,test]
191+
$ pip install -e .[dev]
192192
193193
Install javascript development dependencies
194194
-------------------------------------------

docs/requirements.txt

-14
This file was deleted.

docs/user_guide/customizing.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ In order to change a variable, follow these steps:
6363
For a complete list of the theme variables that you may override, see the
6464
`theme variables defaults CSS file <pydata-css-variables_>`_:
6565

66-
.. literalinclude:: ../../pydata_sphinx_theme/static/css/theme.css
66+
.. literalinclude:: ../../src/pydata_sphinx_theme/theme/pydata_sphinx_theme/static/styles/theme.css
6767
:language: CSS
6868

6969

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

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

131131
.. meta::

environment.yml

-10
This file was deleted.

noxfile.py

+8-62
Original file line numberDiff line numberDiff line change
@@ -1,75 +1,21 @@
11
import nox
2-
from pathlib import Path
3-
from yaml import safe_load
42

53
nox.options.reuse_existing_virtualenvs = True
64

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

13-
14-
@nox.session(venv_backend="conda")
15-
def build(session):
16-
_install_environment(session)
17-
session.run("yarn", "build")
18-
19-
20-
@nox.session(venv_backend="conda")
6+
@nox.session
217
def docs(session):
22-
_install_environment(session)
23-
session.cd("docs")
24-
session.run("make", "html")
8+
session.install(".[doc]")
9+
session.run("sphinx-build", "-b=html", "docs/", "docs/_build/html")
2510

2611

27-
@nox.session(name="docs-live", venv_backend="conda")
12+
@nox.session(name="docs-live")
2813
def docs_live(session):
29-
_install_environment(session)
30-
# fmt: off
31-
session.run(
32-
"sphinx-autobuild",
33-
"--watch", "pydata_sphinx_theme",
34-
"--watch", "src",
35-
"--pre-build", "yarn build",
36-
"--re-ignore", "pydata_sphinx_theme/static/.*",
37-
"--re-ignore", "pydata_sphinx_theme/static/theme.conf",
38-
"--re-ignore", "_build/.*",
39-
"--delay", "2",
40-
"--port", "0",
41-
"--open-browser",
42-
"-n", "-b", "html", "docs/", "docs/_build/html"
43-
)
44-
# fmt: on
14+
session.install("sphinx-theme-builder[cli]")
15+
session.run("stb", "serve", "docs", "--open-browser")
4516

4617

47-
@nox.session(name="test", venv_backend="conda")
18+
@nox.session(name="test")
4819
def test(session):
49-
_install_environment(session, yarn=False)
50-
session.install(".[test]")
20+
session.install("-e", ".[test]")
5121
session.run("pytest", *session.posargs)
52-
53-
54-
def _install_environment(session, yarn=True):
55-
"""Install the JS and Python environment needed to develop the theme."""
56-
# Assume that if sphinx is already installed, we don't need to re-install
57-
try:
58-
bin = Path(session.bin)
59-
except ValueError:
60-
# we are in a pass-through environment, just return and not install anything
61-
return
62-
63-
if list(bin.rglob("sphinx-build")) and "reinstall" not in session.posargs:
64-
return
65-
66-
# Install JS and Python dependencies
67-
session.conda_install("--channel", "conda-forge", *conda)
68-
for pkg in requirements:
69-
# We split each line in case there's a space for `-r`
70-
session.install(*pkg.split())
71-
session.install("-e", ".")
72-
73-
# Build JS packages
74-
if yarn:
75-
session.run("yarn", "--frozen-lockfile")

package.json

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
{
22
"name": "pydata_sphinx_theme",
3-
"version": "0.0.1",
4-
"main": "js/index.js",
53
"repository": "https://github.com/pydata/pydata-sphinx-theme",
64
"scripts": {
7-
"build": "yarn build:production",
8-
"build:production": "webpack --config webpack.js"
5+
"build": "webpack"
96
},
107
"devDependencies": {
118
"clean-webpack-plugin": "^3.0.0",

pydata_sphinx_theme/static/css/blank.css

-2
This file was deleted.

pydata_sphinx_theme/static/css/index.38f2ebe09480739b4ba0fa585d02b29a.css

-6
This file was deleted.

pydata_sphinx_theme/static/js/index.30d17a8aef5d942e5d26.js

-32
This file was deleted.

pydata_sphinx_theme/static/vendor/fontawesome/5.13.0/LICENSE.txt

-34
This file was deleted.

pydata_sphinx_theme/static/vendor/fontawesome/5.13.0/css/all.min.css

-5
This file was deleted.
Binary file not shown.

0 commit comments

Comments
 (0)