diff --git a/.gitignore b/.gitignore index 3f9949e6..f0dca213 100644 --- a/.gitignore +++ b/.gitignore @@ -134,3 +134,4 @@ dmypy.json # JavaScript /node_modules /snapshot_results +/.nodeenv/ diff --git a/package.json b/package.json index 0c0fcd14..3c0fd033 100644 --- a/package.json +++ b/package.json @@ -7,6 +7,7 @@ "playwright": "^1.34.3" }, "scripts": { + "build": ":", "start": "http-server example_docs/docs/_build/html", "test-snapshots": "npm run _docker-build && npm run _docker-run", "_docker-build": "docker build -t qiskit_sphinx_theme -f tests/js/Dockerfile .", diff --git a/pyproject.toml b/pyproject.toml index c70e9c75..30b2fd4d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,11 +1,12 @@ [build-system] -requires = ["setuptools"] -build-backend = "setuptools.build_meta" +requires = ["sphinx-theme-builder>=0.2.0b2"] +build-backend = "sphinx_theme_builder" [project] -version = "1.12.0rc1" -name = "qiskit_sphinx_theme" +name = "qiskit-sphinx-theme" description = "A Sphinx theme for Qiskit and Qiskit Ecosystem projects" +dynamic = ["version"] + license = { text = "Apache 2" } authors = [{ name = "Qiskit Development Team", email = "hello@qiskit.org" }] classifiers = [ @@ -39,6 +40,10 @@ _qiskit_furo = "qiskit_sphinx_theme" "Bug Tracker" = "https://github.com/Qiskit/qiskit_sphinx_theme/issues" "Source Code" = "https://github.com/Qiskit/qiskit_sphinx_theme" +[tool.sphinx-theme-builder] +node-version = "18.16.0" + + [tool.pytest.ini_options] addopts = ["--import-mode=importlib"] diff --git a/src/qiskit_sphinx_theme/__init__.py b/src/qiskit_sphinx_theme/__init__.py index 89df8388..0cb630a9 100644 --- a/src/qiskit_sphinx_theme/__init__.py +++ b/src/qiskit_sphinx_theme/__init__.py @@ -10,8 +10,6 @@ # copyright notice, and modified files need to carry a notice indicating # that they have been altered from the originals. -"""Pytorch Sphinx theme.""" - from __future__ import annotations from pathlib import Path @@ -84,26 +82,16 @@ def setup(app: sphinx.application.Sphinx) -> dict[str, bool]: translations.setup(app) app.add_html_theme("qiskit_sphinx_theme", _get_theme_absolute_path("pytorch")) - app.add_html_theme("_qiskit_furo", _get_theme_absolute_path("theme/furo")) + app.add_html_theme("_qiskit_furo", _get_theme_absolute_path("theme/qiskit-sphinx-theme")) app.connect("html-page-context", remove_thebe_if_not_needed) - if app.config.html_theme == "_qiskit_furo": - # The below must be kept in sync with `furo/__init__.py`. - from furo import ( - WrapTableAndMathInAContainerTransform, - _builder_inited, - _html_page_context, - _overwrite_pygments_css, - ) - - app.add_post_transform(WrapTableAndMathInAContainerTransform) - app.connect("html-page-context", _html_page_context) - app.connect("builder-inited", _builder_inited) - app.connect("build-finished", _overwrite_pygments_css) - else: - # Sphinx 6 stopped including jQuery by default. Our Pytorch theme depend on jQuery, - # so activate it for our users automatically. - app.setup_extension("sphinxcontrib.jquery") + # TODO: figure out how to make this conditional. + app.add_css_file("styles/furo.css", 100) + app.add_js_file("scripts/furo.js") + + # Sphinx 6 stopped including jQuery by default. Our Pytorch theme depend on jQuery, + # so activate it for our users automatically. + app.setup_extension("sphinxcontrib.jquery") return {"parallel_read_safe": True, "parallel_write_safe": True} diff --git a/src/qiskit_sphinx_theme/assets/scripts/qiskit-sphinx-theme.js b/src/qiskit_sphinx_theme/assets/scripts/qiskit-sphinx-theme.js new file mode 100644 index 00000000..cf6e54c2 --- /dev/null +++ b/src/qiskit_sphinx_theme/assets/scripts/qiskit-sphinx-theme.js @@ -0,0 +1,4 @@ +// Empty file required by sphinx-theme-builder. +// +// This will allow us to fix Furo's JavaScript code to workaround +// https://github.com/Qiskit/qiskit_sphinx_theme/issues/368. diff --git a/src/qiskit_sphinx_theme/assets/styles/qiskit-sphinx-theme.css b/src/qiskit_sphinx_theme/assets/styles/qiskit-sphinx-theme.css new file mode 100644 index 00000000..9c548b47 --- /dev/null +++ b/src/qiskit_sphinx_theme/assets/styles/qiskit-sphinx-theme.css @@ -0,0 +1,3 @@ +/* Empty file required by sphinx-theme-builder. + +This will be replaced by Sass code that gets compiled. */ diff --git a/src/qiskit_sphinx_theme/theme/furo/base.html b/src/qiskit_sphinx_theme/theme/qiskit-sphinx-theme/base.html similarity index 100% rename from src/qiskit_sphinx_theme/theme/furo/base.html rename to src/qiskit_sphinx_theme/theme/qiskit-sphinx-theme/base.html diff --git a/src/qiskit_sphinx_theme/theme/furo/custom_templates/extra_head.html b/src/qiskit_sphinx_theme/theme/qiskit-sphinx-theme/custom_templates/extra_head.html similarity index 100% rename from src/qiskit_sphinx_theme/theme/furo/custom_templates/extra_head.html rename to src/qiskit_sphinx_theme/theme/qiskit-sphinx-theme/custom_templates/extra_head.html diff --git a/src/qiskit_sphinx_theme/theme/furo/custom_templates/footer_analytics.html b/src/qiskit_sphinx_theme/theme/qiskit-sphinx-theme/custom_templates/footer_analytics.html similarity index 100% rename from src/qiskit_sphinx_theme/theme/furo/custom_templates/footer_analytics.html rename to src/qiskit_sphinx_theme/theme/qiskit-sphinx-theme/custom_templates/footer_analytics.html diff --git a/src/qiskit_sphinx_theme/theme/furo/custom_templates/sidebar_languages.html b/src/qiskit_sphinx_theme/theme/qiskit-sphinx-theme/custom_templates/sidebar_languages.html similarity index 100% rename from src/qiskit_sphinx_theme/theme/furo/custom_templates/sidebar_languages.html rename to src/qiskit_sphinx_theme/theme/qiskit-sphinx-theme/custom_templates/sidebar_languages.html diff --git a/src/qiskit_sphinx_theme/theme/furo/custom_templates/sidebar_version_list.html b/src/qiskit_sphinx_theme/theme/qiskit-sphinx-theme/custom_templates/sidebar_version_list.html similarity index 100% rename from src/qiskit_sphinx_theme/theme/furo/custom_templates/sidebar_version_list.html rename to src/qiskit_sphinx_theme/theme/qiskit-sphinx-theme/custom_templates/sidebar_version_list.html diff --git a/src/qiskit_sphinx_theme/theme/furo/page.html b/src/qiskit_sphinx_theme/theme/qiskit-sphinx-theme/page.html similarity index 100% rename from src/qiskit_sphinx_theme/theme/furo/page.html rename to src/qiskit_sphinx_theme/theme/qiskit-sphinx-theme/page.html diff --git a/src/qiskit_sphinx_theme/theme/furo/partials/icons.html b/src/qiskit_sphinx_theme/theme/qiskit-sphinx-theme/partials/icons.html similarity index 100% rename from src/qiskit_sphinx_theme/theme/furo/partials/icons.html rename to src/qiskit_sphinx_theme/theme/qiskit-sphinx-theme/partials/icons.html diff --git a/src/qiskit_sphinx_theme/theme/furo/static/images/logo.png b/src/qiskit_sphinx_theme/theme/qiskit-sphinx-theme/static/images/logo.png similarity index 100% rename from src/qiskit_sphinx_theme/theme/furo/static/images/logo.png rename to src/qiskit_sphinx_theme/theme/qiskit-sphinx-theme/static/images/logo.png diff --git a/src/qiskit_sphinx_theme/theme/furo/static/js/web-components/top-nav-bar.js b/src/qiskit_sphinx_theme/theme/qiskit-sphinx-theme/static/js/web-components/top-nav-bar.js similarity index 100% rename from src/qiskit_sphinx_theme/theme/furo/static/js/web-components/top-nav-bar.js rename to src/qiskit_sphinx_theme/theme/qiskit-sphinx-theme/static/js/web-components/top-nav-bar.js diff --git a/src/qiskit_sphinx_theme/theme/furo/static/styles/qiskit_changes.css b/src/qiskit_sphinx_theme/theme/qiskit-sphinx-theme/static/styles/qiskit-sphinx-theme.css similarity index 100% rename from src/qiskit_sphinx_theme/theme/furo/static/styles/qiskit_changes.css rename to src/qiskit_sphinx_theme/theme/qiskit-sphinx-theme/static/styles/qiskit-sphinx-theme.css diff --git a/src/qiskit_sphinx_theme/theme/furo/theme.conf b/src/qiskit_sphinx_theme/theme/qiskit-sphinx-theme/theme.conf similarity index 64% rename from src/qiskit_sphinx_theme/theme/furo/theme.conf rename to src/qiskit_sphinx_theme/theme/qiskit-sphinx-theme/theme.conf index bb8e7767..bf6ef613 100644 --- a/src/qiskit_sphinx_theme/theme/furo/theme.conf +++ b/src/qiskit_sphinx_theme/theme/qiskit-sphinx-theme/theme.conf @@ -1,11 +1,6 @@ [theme] inherit = furo - -# Our stylesheet takes precedence. -stylesheet = - styles/furo.css, - styles/furo-extensions.css, - styles/qiskit_changes.css +stylesheet = styles/qiskit-sphinx-theme.css sidebars = sidebar/search.html,