-
Notifications
You must be signed in to change notification settings - Fork 356
Switch to sphinx-theme-builder and improve webpack.config.js
#514
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
Changes from all commits
b530c3a
5a043b1
6156c8a
5ffa841
c3bdb3c
8427e3c
bd6168b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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] | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess we should also add 3.10 now?
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 :-)
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fair enough ;-) |
||
| include: | ||
| - python-version: 3.9 | ||
| dev: true | ||
|
|
@@ -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 | ||
|
|
||
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
| 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]") | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does this also need a
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It does need that line. I missed it.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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") | ||
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
There was a problem hiding this comment.
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.