Skip to content

Commit cd0fa3e

Browse files
Remove qiskit theme (#585)
Closes #577. This allows us to greatly simplify the repository. Now we only have a single theme, whereas before we had 3 themes so had to generalize a bunch of logic like our visual regression testing.
1 parent 5bca8e3 commit cd0fa3e

37 files changed

+57
-150
lines changed

.github/workflows/main.yml

+5-11
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ jobs:
66
runs-on: ubuntu-latest
77
if: github.repository_owner == 'Qiskit'
88
container:
9-
# Keep in sync with tests/js/Dockerfile.base's base image.
9+
# Keep in sync with tests/js/Dockerfile's base image.
1010
image: mcr.microsoft.com/playwright:v1.34.0-jammy
1111
steps:
1212
- uses: actions/checkout@v3
@@ -36,16 +36,11 @@ jobs:
3636

3737
- name: Create artifacts/ folder
3838
run: mkdir artifacts
39-
- name: Build Qiskit (Furo) theme
40-
run: |
41-
tox run -e qiskit
42-
tar -zcvf qiskit_html_docs.tar.gz example_docs/docs/_qiskit_build
43-
mv qiskit_html_docs.tar.gz artifacts/.
4439
- name: Build Ecosystem theme
4540
run: |
46-
tox run -e ecosystem
47-
tar -zcvf ecosystem_html_docs.tar.gz example_docs/docs/_ecosystem_build
48-
mv ecosystem_html_docs.tar.gz artifacts/.
41+
tox run -e docs
42+
tar -zcvf html_docs.tar.gz example_docs/docs/_build
43+
mv html_docs.tar.gz artifacts/.
4944
- name: Upload Sphinx builds
5045
uses: actions/upload-artifact@v3
5146
if: always()
@@ -55,8 +50,7 @@ jobs:
5550

5651
- name: Run visual regression tests
5752
run: |
58-
npm run _run-qiskit-tests
59-
npm run _run-ecosystem-tests
53+
npm run _run-tests
6054
- name: Upload snapshot results
6155
if: failure()
6256
uses: actions/upload-artifact@v3

CONTRIBUTING.md

+16-26
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
# Contributing
22

3-
First read the overall Qiskit project contributing guidelines. These are all
4-
included in the qiskit documentation:
5-
6-
https://qiskit.org/documentation/contributing_to_qiskit.html
3+
First read the overall [Qiskit project contributing guidelines](https://github.com/Qiskit/qiskit/blob/main/CONTRIBUTING.md#).
74

85
## Contributing to qiskit_sphinx_theme
96

@@ -16,18 +13,17 @@ contributing to qiskit_sphinx_theme, these are documented below.
1613
There are a few important subfolders to be aware of:
1714

1815
### `/src`
19-
This subfolder contains the HTML, CSS, and Python files that are used for the Qiskit themes. It has these folders:
16+
This subfolder contains the HTML, CSS, and Python files that are used for the `qiskit-ecosystem` theme. It has these folders:
2017

21-
* `assets`: CSS and JavaScript for the `qiskit` theme.
22-
* `ecosystem`: the code for the `qiskit-ecosystem` theme, which is built on top of the base `qiskit` theme. This folder only has overrides.
23-
* `theme`: static files, like HTML templates, for the `qiskit` theme.
18+
* `assets`: CSS
19+
* `theme`: HTML templates and the `theme.conf` config file
2420

2521
The top-level Python files are used for logic used by the theme, such as `translations.py` determining what URLs the HTML should use for translations support.
2622

2723
### `/example_docs`
2824
This subfolder contains a scaled down version of the Sphinx build that builds the documentation for the Qiskit repos.
2925

30-
It pulls styles from the `/src` subfolder. You can check any changes you are making to theme by building the documentation (see running locally section) and opening the HTML files generated in `example_docs/docs/_qiskit_build` and `example_docs/docs/_ecosystem_build`.
26+
It pulls styles from the `/src` subfolder. You can check any changes you are making to theme by building the documentation (see running locally section) and opening the HTML files generated in `example_docs/docs/_build`.
3127

3228
### `/docs_guide`
3329
This subfolder contains guidance on how to write documentation and build sphinx projects for Qiskit and Qiskit Ecosystem projects. You can view the fully rendered docs guide at https://qisk.it/docs-guide
@@ -38,18 +34,15 @@ This subfolder contains guidance on how to write documentation and build sphinx
3834
We use [Tox](https://tox.wiki/en/latest/), which you will need to install globally (e.g. using [`pipx`](https://pypa.github.io/pipx/)).
3935

4036
* Run Python tests: `tox -e py`
41-
* Build `example_docs/` with the `qiskit` theme:
42-
1. `tox -e qiskit`
43-
2. Open up `example_docs/docs/_qiskit_build/index.html` in your browser
44-
* Build `example_docs/` with the `qiskit-ecosystem` theme:
45-
1. `tox -e ecosystem`
46-
2. Open up `example_docs/docs/_ecosystem_build/index.html` in your browser
37+
* Build `example_docs/`:
38+
1. `tox -e docs`
39+
2. Open up `example_docs/docs/_build/index.html` in your browser
4740
* Build `docs_guide`:
4841
1. `tox -e docs-guide`
4942
2. Open up `docs_guide/_build/html/index.html` in your browser.
5043
* Run doctests for the docs guide: `tox -e doctest`
5144

52-
Sometimes Sphinx's caching can get in a bad state. First, try running `tox -e clean`, which will remove Sphinx's cache. If you are still having issues, try adding `-r` your command, e.g. `tox -e qiskit -r`. `-r` tells Tox to reinstall the dependencies.
45+
Sometimes Sphinx's caching can get in a bad state. First, try running `tox -e clean`, which will remove Sphinx's cache. If you are still having issues, try adding `-r` your command, e.g. `tox -e docs -r`. `-r` tells Tox to reinstall the dependencies.
5346

5447
------
5548
## Visual regression testing
@@ -85,21 +78,21 @@ First, you need to install:
8578
Then, to run the tests locally:
8679

8780
1. `npm install`
88-
2. `npm run test-qiskit` or `npm run test-ecosystem`, depending on which theme you want.
81+
2. `npm run test`.
8982
* Warning: the very first time you run the tests, they will fail because the `snapshot-results` folder will not yet exist. Try running again.
9083

91-
The docs will rebuild every time you run `npm run test-qiskit` and `npm run test-ecosystem`.
84+
The docs will rebuild every time you run `npm run test`.
9285

9386
### How to update the expected snapshot for intentional changes
9487

9588
First, get the `snapshot_results` folder, either by downloading it from CI or by running the tests locally. Then:
9689

9790
1. Find the "actual" snapshot for the failing test, such as `api-docs-class-page-1-actual.png`.
98-
2. Copy that snapshot into the folder `tests/js/qiskit.test.js-snapshots` or `tests/js/ecosystem.test.js-snapshots`, depending on which theme failed. Rename the `-actual.png` file ending to be `-linux.png` and overwrite the prior file.
91+
2. Copy that snapshot into the folder `tests/js/tests.js-snapshots`. Rename the `-actual.png` file ending to be `-linux.png` and overwrite the prior file.
9992

10093
### How to add a new snapshot
10194

102-
Copy the tests in `qiskit.test.js` or `ecosystem.test.js` for inspiration. Make sure the selector you use in `page.locator()` is accurate. Title the tests with a useful but concise description of what you're testing.
95+
Copy the tests in `tests.js` for inspiration. Make sure the selector you use in `page.locator()` is accurate. Title the tests with a useful but concise description of what you're testing.
10396

10497
Then, run the tests either locally or in CI to generate the snapshots. When running locally, the files will be added automatically. When using CI, follow the section [How to update the expected snapshot for intentional changes](#how-to-update-the-expected-snapshot-for-intentional-changes).
10598

@@ -110,19 +103,16 @@ We upload the docs builds to CI. So, you can download what the site will look li
110103

111104
1. Navigate to the GitHub Actions page for the "Tests" action.
112105
2. Open the "Summary" page with the house icon.
113-
3. Under the "Artifacts" section, there should be a "html_docs" entry. Download it.
114-
4. Choose the theme you want, such as `qiskit_html_docs.tar.gz`, and un-tar it. Then, open the `index.html` page in a browser.
106+
3. Under the "Artifacts" section, there should be a "html_docs" entry. Download it. Un-tar it, then open the `index.html` page in a browswer.
115107

116108
Contributors with write access can also use live previews of the docs: GitHub will deploy a website using your changes. To use live previews, push your branch to `upstream` rather than your fork. GitHub will leave a comment with the link to the site. Please prefix your branch name with your initials, e.g. `EA/add-translations`, for good Git hygiene.
117109

118110
------
119111
## FYI: How Furo Theme Inheritance Works
120112

121-
We use Sphinx's inheritance future for our Furo-based `qiskit` theme, which we set in `theme/qiskit-sphinx-theme/theme.conf`. Sphinx will default to using all the files from Furo. But if we have a file with the same name as Furo, then Sphinx will use our copy. That allows us to override only what we care about.
122-
123-
We try to keep changes to a minimum because every divergence we make from base Furo increases our maintenance burden. Hence we prioritise only making changes that are important to the Qiskit brand. If the change would be generally useful to other users of Furo, we try to contribute upstream to the Furo project itself.
113+
We use Sphinx's inheritance feature because our theme is built on top of [Furo](https://github.com/pradyunsg/furo). The `furo` inheritance is configured in `theme/qiskit-sphinx-theme/theme.conf`. Sphinx will default to using all the files from Furo. But if we have a file with the same name as Furo, then Sphinx will use our copy. That allows us to override only what we care about.
124114

125-
The `qiskit-ecosystem` theme then inherits the `qiskit` theme to make some tweaks, although we're removing the `qiskit` theme so the themes are converging.
115+
We try to keep changes to a minimum because every divergence we make from base Furo increases our maintenance burden. Hence we prioritise only making changes that are important to the Qiskit Ecosystem brand. If the change would be generally useful to other users of Furo, we try to contribute upstream to the Furo project itself.
126116

127117
### How to change HTML
128118
Copy the HTML template from Furo and save it in the same file path. Then, at the top of the file, add this header:

Dockerfile

+2-2
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ WORKDIR /app
2727

2828
COPY . .
2929

30-
RUN tox run -e qiskit
30+
RUN tox run -e docs
3131

3232
EXPOSE 8000
33-
CMD ["python", "-m", "http.server", "-d", "example_docs/docs/_qiskit_build"]
33+
CMD ["python", "-m", "http.server", "-d", "example_docs/docs/_build"]

README.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@ See [Migrate from old Pytorch theme to new theme](https://github.com/Qiskit/qisk
1010
## Overview
1111

1212
This repository hosts three things:
13-
- Qiskit Sphinx themes (located in the `src/` folder)
14-
- Example Docs (located in the `example_docs/` folder)
13+
- `qiskit-ecosystem` theme (located in the `src/` folder)
14+
- example docs (located in the `example_docs/` folder)
1515
- Qiskit Docs Guide (located in the `docs_guide/` folder)
1616

17-
The Qiskit Sphinx Themes are the themes used by Qiskit Documentation (https://qiskit.org/documentation/) and Qiskit Ecosystem projects.
17+
The `qiskit-ecosystem` theme is used by projects in the [Qiskit Ecosystem](https://qiskit.github.io/ecosystem).
1818

19-
The Example Docs is a minimal Sphinx project that is used for testing the Qiskit Sphinx Theme. Every
20-
pull request will trigger [a GitHub workflow](https://github.com/Qiskit/qiskit_sphinx_theme/blob/main/.github/workflows/main.yml) that builds the Example Docs to make sure the changes do
19+
The example docs are a minimal Sphinx project that is used for testing the Qiskit Sphinx Theme. Every
20+
pull request will trigger [a GitHub workflow](https://github.com/Qiskit/qiskit_sphinx_theme/blob/main/.github/workflows/main.yml) that builds the example docs to make sure the changes do
2121
not introduce unintended changes.
2222

2323
The Qiskit Docs Guide hosts instructions, guidelines and recommendations of good documentation
@@ -34,7 +34,7 @@ pip install qiskit-sphinx-theme
3434

3535
Then, set up the theme by updating `conf.py`:
3636

37-
1. Set `html_theme = "qiskit-ecosystem"` (only Qiskit Terra should use `qiskit`)
37+
1. Set `html_theme = "qiskit-ecosystem"`
3838
2. Add `"qiskit_sphinx_theme"` to `extensions`
3939

4040
You also likely want to set `html_title` in `conf.py`. This results in the left sidebar having a more useful and concise name, along with the page title in the browser. Most projects will want to use this in their `conf.py`:

example_docs/docs/conf.py

+2-5
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
language = "en"
2323
release = "9.99"
2424

25+
html_theme = "qiskit-ecosystem"
26+
2527
# This allows including custom CSS and HTML templates.
2628
html_static_path = ["_static"]
2729
templates_path = ["_templates"]
@@ -58,11 +60,6 @@
5860
# for interpolation, i.e. Sphinx doesn't have built-in interpolation.
5961
html_title = f"{project} {release}"
6062

61-
# This allows us to test both the Qiskit and Qiskit Ecosystem themes. In normal repositories, `html_theme`
62-
# would be set to one specific theme.
63-
_THEME = os.getenv("THEME", "qiskit")
64-
html_theme = _THEME
65-
6663
html_context = {
6764
# Users of the theme can set prior version numbers. They'll
6865
# show up in the sidebar under the "Previous Versions" section.

package.json

+3-6
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,8 @@
1515
},
1616
"scripts": {
1717
"build": "webpack",
18-
"start-qiskit": "http-server example_docs/docs/_qiskit_build -p 8080",
19-
"start-ecosystem": "http-server example_docs/docs/_ecosystem_build -p 8081",
20-
"test-qiskit": "tests/js/run_docker.py qiskit",
21-
"test-ecosystem": "tests/js/run_docker.py ecosystem",
22-
"_run-qiskit-tests": "THEME=qiskit playwright test",
23-
"_run-ecosystem-tests": "THEME=ecosystem playwright test"
18+
"start": "http-server example_docs/docs/_build -p 8080",
19+
"test": "tests/js/run_docker.py",
20+
"_run-tests": "playwright test"
2421
}
2522
}

playwright.config.js

+3-14
Original file line numberDiff line numberDiff line change
@@ -13,23 +13,12 @@
1313

1414
import { defineConfig } from "@playwright/test";
1515

16-
let testMatch;
17-
let baseURL;
18-
let startCommand;
19-
if (process.env.THEME === "qiskit") {
20-
testMatch = /.*qiskit.test.js/;
21-
baseURL = "http://127.0.0.1:8080";
22-
startCommand = "start-qiskit";
23-
} else {
24-
testMatch = /.*ecosystem.test.js/;
25-
baseURL = "http://127.0.0.1:8081";
26-
startCommand = "start-ecosystem";
27-
}
16+
const baseURL = "http://127.0.0.1:8080"
2817

2918
export default defineConfig({
3019
outputDir: "snapshot_results",
3120
workers: process.env.CI ? 1 : undefined,
32-
testMatch,
21+
testMatch: /.*tests\.js$/,
3322
expect: {
3423
toHaveScreenshot: {
3524
threshold: 0.01, // We expect colors to be near exact matches.
@@ -41,7 +30,7 @@ export default defineConfig({
4130
viewport: { width: 1920, height: 1080 },
4231
},
4332
webServer: {
44-
command: `npm run ${startCommand}`,
33+
command: "npm run start",
4534
url: baseURL,
4635
},
4736
});

pyproject.toml

-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ dependencies = [
3232
]
3333

3434
[project.entry-points."sphinx.html_themes"]
35-
qiskit = "qiskit_sphinx_theme"
3635
qiskit-ecosystem = "qiskit_sphinx_theme"
3736

3837
[project.urls]

src/qiskit_sphinx_theme/__init__.py

-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,6 @@ def setup(app: sphinx.application.Sphinx) -> dict[str, bool]:
8585
previous_releases.setup(app)
8686
translations.setup(app)
8787

88-
app.add_html_theme("qiskit", _get_theme_absolute_path("theme/qiskit-sphinx-theme"))
8988
app.add_html_theme("qiskit-ecosystem", _get_theme_absolute_path("theme/qiskit-sphinx-theme"))
9089

9190
app.connect("config-inited", activate_furo)

tests/js/Dockerfile.base tests/js/Dockerfile

+4-4
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,12 @@
1111
# that they have been altered from the originals.
1212

1313

14-
# A base Dockerfile to run our snapshot tests locally. This is to avoid issues with CI and local
14+
# This Dockerfile allows us to run our snapshot tests locally. That avoids issues with CI and local
1515
# differing. In CI, we also run with the same base image.
1616
# See https://playwright.dev/docs/test-snapshots.
1717
#
1818
# Note that we build the Sphinx docs outside of this Docker image; we only need to run the
1919
# server inside Docker so that the docs are rendered the same locally and in CI.
20-
#
21-
# Each specific theme extends this base image to copy in the built docs and run their specific
22-
# project with Playwright.
2320

2421

2522
# Keep this base image in sync with .github/workflows/main.yml.
@@ -33,3 +30,6 @@ RUN npm ci
3330
# Copy over our tests.
3431
COPY playwright.config.js ./
3532
COPY tests/js tests/js
33+
34+
COPY example_docs/docs/_build example_docs/docs/_build
35+
CMD [ "npm", "run", "_run-tests" ]

tests/js/Dockerfile.ecosystem

-16
This file was deleted.

tests/js/Dockerfile.qiskit

-16
This file was deleted.

tests/js/ecosystem.test.js

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

0 commit comments

Comments
 (0)