From 664df200ac84ef2360f45897b6e48164d98517ac Mon Sep 17 00:00:00 2001 From: Eric Arellano <14852634+Eric-Arellano@users.noreply.github.com> Date: Thu, 16 Mar 2023 17:48:14 -0600 Subject: [PATCH] Reorganize to allow theme variants (#216) ## Summary We plan to add variants of the Sphinx theme so that we can differentiate between Core vs the Ecosystem. They'll be distributed in the same package, and users only need to choose the `html_theme` in their `conf.py`. They will also share a "base" theme and override the CSS/images/HTML templates they care about. See https://github.com/Qiskit/qiskit_sphinx_theme/pull/215 for an example of this. This PR reorganizes our folder structure so that we can add variants in followup PRs. ## Details We call the folder `pytorch_base` because we likely will want Pytorch-based variants for Core vs Ecosystem, and they'll use this folder as their base. Those variants will be added in follow ups. This also simplifies our `MANIFEST.in` and `setup.py` with @jakelishman's recommendation from https://github.com/Qiskit/qiskit_sphinx_theme/pull/212#pullrequestreview-1344320986. The benefit of that is we make fewer changes when adding new theme variants (we have to add `graft qiskit_sphinx_theme//static` to MANIFEST.in). I verified this works by using `python -m build` and inspecting the RECORD of the wheel, which shows the contents. --- MANIFEST.in | 8 +++----- qiskit_sphinx_theme/__init__.py | 17 +++++++++-------- .../{ => pytorch_base}/breadcrumbs.html | 0 .../{ => pytorch_base}/footer.html | 0 .../{ => pytorch_base}/languages.html | 0 .../{ => pytorch_base}/layout.html | 0 .../{ => pytorch_base}/layout_old.html | 0 .../{ => pytorch_base}/search.html | 0 .../{ => pytorch_base}/searchbox.html | 0 .../{ => pytorch_base}/sidebar.html | 0 .../{ => pytorch_base}/static/css/theme.css | 0 .../static/images/chevron-down-grey.svg | 0 .../static/images/chevron-right-white.svg | 0 .../static/images/icon-close.svg | 0 .../static/images/icon-menu-dots-dark.svg | 0 .../{ => pytorch_base}/static/images/launch.svg | 0 .../static/images/logo-facebook-dark.svg | 0 .../static/images/logo-icon.svg | 0 .../static/images/logo-twitter-dark.svg | 0 .../static/images/logo-youtube-dark.svg | 0 .../{ => pytorch_base}/static/images/logo.svg | 0 .../static/images/logo_wordmark.svg | 0 .../static/images/qiskit-chevron-down.svg | 0 .../static/images/qiskit-chevron-up.svg | 0 .../static/images/search-icon.svg | 0 .../static/images/view-page-source-icon.svg | 0 .../static/js/modernizr.min.js | 0 .../{ => pytorch_base}/static/js/theme.js | 0 .../{ => pytorch_base}/theme.conf | 0 setup.py | 9 ++------- 30 files changed, 14 insertions(+), 20 deletions(-) rename qiskit_sphinx_theme/{ => pytorch_base}/breadcrumbs.html (100%) rename qiskit_sphinx_theme/{ => pytorch_base}/footer.html (100%) rename qiskit_sphinx_theme/{ => pytorch_base}/languages.html (100%) rename qiskit_sphinx_theme/{ => pytorch_base}/layout.html (100%) rename qiskit_sphinx_theme/{ => pytorch_base}/layout_old.html (100%) rename qiskit_sphinx_theme/{ => pytorch_base}/search.html (100%) rename qiskit_sphinx_theme/{ => pytorch_base}/searchbox.html (100%) rename qiskit_sphinx_theme/{ => pytorch_base}/sidebar.html (100%) rename qiskit_sphinx_theme/{ => pytorch_base}/static/css/theme.css (100%) rename qiskit_sphinx_theme/{ => pytorch_base}/static/images/chevron-down-grey.svg (100%) rename qiskit_sphinx_theme/{ => pytorch_base}/static/images/chevron-right-white.svg (100%) rename qiskit_sphinx_theme/{ => pytorch_base}/static/images/icon-close.svg (100%) rename qiskit_sphinx_theme/{ => pytorch_base}/static/images/icon-menu-dots-dark.svg (100%) rename qiskit_sphinx_theme/{ => pytorch_base}/static/images/launch.svg (100%) rename qiskit_sphinx_theme/{ => pytorch_base}/static/images/logo-facebook-dark.svg (100%) rename qiskit_sphinx_theme/{ => pytorch_base}/static/images/logo-icon.svg (100%) rename qiskit_sphinx_theme/{ => pytorch_base}/static/images/logo-twitter-dark.svg (100%) rename qiskit_sphinx_theme/{ => pytorch_base}/static/images/logo-youtube-dark.svg (100%) rename qiskit_sphinx_theme/{ => pytorch_base}/static/images/logo.svg (100%) rename qiskit_sphinx_theme/{ => pytorch_base}/static/images/logo_wordmark.svg (100%) rename qiskit_sphinx_theme/{ => pytorch_base}/static/images/qiskit-chevron-down.svg (100%) rename qiskit_sphinx_theme/{ => pytorch_base}/static/images/qiskit-chevron-up.svg (100%) rename qiskit_sphinx_theme/{ => pytorch_base}/static/images/search-icon.svg (100%) rename qiskit_sphinx_theme/{ => pytorch_base}/static/images/view-page-source-icon.svg (100%) rename qiskit_sphinx_theme/{ => pytorch_base}/static/js/modernizr.min.js (100%) rename qiskit_sphinx_theme/{ => pytorch_base}/static/js/theme.js (100%) rename qiskit_sphinx_theme/{ => pytorch_base}/theme.conf (100%) diff --git a/MANIFEST.in b/MANIFEST.in index ec5843d1..5451d3b9 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,5 +1,3 @@ -include qiskit_sphinx_theme/theme.conf -include qiskit_sphinx_theme/*.html -include qiskit_sphinx_theme/static/css/*.css -include qiskit_sphinx_theme/static/js/*.js -include qiskit_sphinx_theme/static/images/*.* +recursive-include qiskit_sphinx_theme *.html +recursive-include qiskit_sphinx_theme theme.conf +graft qiskit_sphinx_theme/pytorch_base/static diff --git a/qiskit_sphinx_theme/__init__.py b/qiskit_sphinx_theme/__init__.py index f7cb1523..2bcf8fce 100644 --- a/qiskit_sphinx_theme/__init__.py +++ b/qiskit_sphinx_theme/__init__.py @@ -1,13 +1,17 @@ -"""Pytorch Sphinx theme. +"""Pytorch Sphinx theme.""" -""" -from os import path +from pathlib import Path from warnings import warn __version__ = '1.11.0rc1' __version_full__ = __version__ +def _get_theme_absolute_path(folder_name: str) -> str: + path = Path(__file__).parent / folder_name + return str(path.resolve()) + + def get_html_theme_path(): """Return the absolute path to this package. @@ -23,13 +27,10 @@ def get_html_theme_path(): stacklevel=2, category=DeprecationWarning, ) - cur_dir = path.abspath(path.dirname(path.dirname(__file__))) - return cur_dir + return _get_theme_absolute_path("pytorch_base") # See https://www.sphinx-doc.org/en/master/development/theming.html def setup(app): - app.add_html_theme('qiskit_sphinx_theme', path.abspath(path.dirname(__file__))) - - # return explicit parallel safe + app.add_html_theme("qiskit_sphinx_theme", _get_theme_absolute_path("pytorch_base")) return {'parallel_read_safe': True, 'parallel_write_safe': True} diff --git a/qiskit_sphinx_theme/breadcrumbs.html b/qiskit_sphinx_theme/pytorch_base/breadcrumbs.html similarity index 100% rename from qiskit_sphinx_theme/breadcrumbs.html rename to qiskit_sphinx_theme/pytorch_base/breadcrumbs.html diff --git a/qiskit_sphinx_theme/footer.html b/qiskit_sphinx_theme/pytorch_base/footer.html similarity index 100% rename from qiskit_sphinx_theme/footer.html rename to qiskit_sphinx_theme/pytorch_base/footer.html diff --git a/qiskit_sphinx_theme/languages.html b/qiskit_sphinx_theme/pytorch_base/languages.html similarity index 100% rename from qiskit_sphinx_theme/languages.html rename to qiskit_sphinx_theme/pytorch_base/languages.html diff --git a/qiskit_sphinx_theme/layout.html b/qiskit_sphinx_theme/pytorch_base/layout.html similarity index 100% rename from qiskit_sphinx_theme/layout.html rename to qiskit_sphinx_theme/pytorch_base/layout.html diff --git a/qiskit_sphinx_theme/layout_old.html b/qiskit_sphinx_theme/pytorch_base/layout_old.html similarity index 100% rename from qiskit_sphinx_theme/layout_old.html rename to qiskit_sphinx_theme/pytorch_base/layout_old.html diff --git a/qiskit_sphinx_theme/search.html b/qiskit_sphinx_theme/pytorch_base/search.html similarity index 100% rename from qiskit_sphinx_theme/search.html rename to qiskit_sphinx_theme/pytorch_base/search.html diff --git a/qiskit_sphinx_theme/searchbox.html b/qiskit_sphinx_theme/pytorch_base/searchbox.html similarity index 100% rename from qiskit_sphinx_theme/searchbox.html rename to qiskit_sphinx_theme/pytorch_base/searchbox.html diff --git a/qiskit_sphinx_theme/sidebar.html b/qiskit_sphinx_theme/pytorch_base/sidebar.html similarity index 100% rename from qiskit_sphinx_theme/sidebar.html rename to qiskit_sphinx_theme/pytorch_base/sidebar.html diff --git a/qiskit_sphinx_theme/static/css/theme.css b/qiskit_sphinx_theme/pytorch_base/static/css/theme.css similarity index 100% rename from qiskit_sphinx_theme/static/css/theme.css rename to qiskit_sphinx_theme/pytorch_base/static/css/theme.css diff --git a/qiskit_sphinx_theme/static/images/chevron-down-grey.svg b/qiskit_sphinx_theme/pytorch_base/static/images/chevron-down-grey.svg similarity index 100% rename from qiskit_sphinx_theme/static/images/chevron-down-grey.svg rename to qiskit_sphinx_theme/pytorch_base/static/images/chevron-down-grey.svg diff --git a/qiskit_sphinx_theme/static/images/chevron-right-white.svg b/qiskit_sphinx_theme/pytorch_base/static/images/chevron-right-white.svg similarity index 100% rename from qiskit_sphinx_theme/static/images/chevron-right-white.svg rename to qiskit_sphinx_theme/pytorch_base/static/images/chevron-right-white.svg diff --git a/qiskit_sphinx_theme/static/images/icon-close.svg b/qiskit_sphinx_theme/pytorch_base/static/images/icon-close.svg similarity index 100% rename from qiskit_sphinx_theme/static/images/icon-close.svg rename to qiskit_sphinx_theme/pytorch_base/static/images/icon-close.svg diff --git a/qiskit_sphinx_theme/static/images/icon-menu-dots-dark.svg b/qiskit_sphinx_theme/pytorch_base/static/images/icon-menu-dots-dark.svg similarity index 100% rename from qiskit_sphinx_theme/static/images/icon-menu-dots-dark.svg rename to qiskit_sphinx_theme/pytorch_base/static/images/icon-menu-dots-dark.svg diff --git a/qiskit_sphinx_theme/static/images/launch.svg b/qiskit_sphinx_theme/pytorch_base/static/images/launch.svg similarity index 100% rename from qiskit_sphinx_theme/static/images/launch.svg rename to qiskit_sphinx_theme/pytorch_base/static/images/launch.svg diff --git a/qiskit_sphinx_theme/static/images/logo-facebook-dark.svg b/qiskit_sphinx_theme/pytorch_base/static/images/logo-facebook-dark.svg similarity index 100% rename from qiskit_sphinx_theme/static/images/logo-facebook-dark.svg rename to qiskit_sphinx_theme/pytorch_base/static/images/logo-facebook-dark.svg diff --git a/qiskit_sphinx_theme/static/images/logo-icon.svg b/qiskit_sphinx_theme/pytorch_base/static/images/logo-icon.svg similarity index 100% rename from qiskit_sphinx_theme/static/images/logo-icon.svg rename to qiskit_sphinx_theme/pytorch_base/static/images/logo-icon.svg diff --git a/qiskit_sphinx_theme/static/images/logo-twitter-dark.svg b/qiskit_sphinx_theme/pytorch_base/static/images/logo-twitter-dark.svg similarity index 100% rename from qiskit_sphinx_theme/static/images/logo-twitter-dark.svg rename to qiskit_sphinx_theme/pytorch_base/static/images/logo-twitter-dark.svg diff --git a/qiskit_sphinx_theme/static/images/logo-youtube-dark.svg b/qiskit_sphinx_theme/pytorch_base/static/images/logo-youtube-dark.svg similarity index 100% rename from qiskit_sphinx_theme/static/images/logo-youtube-dark.svg rename to qiskit_sphinx_theme/pytorch_base/static/images/logo-youtube-dark.svg diff --git a/qiskit_sphinx_theme/static/images/logo.svg b/qiskit_sphinx_theme/pytorch_base/static/images/logo.svg similarity index 100% rename from qiskit_sphinx_theme/static/images/logo.svg rename to qiskit_sphinx_theme/pytorch_base/static/images/logo.svg diff --git a/qiskit_sphinx_theme/static/images/logo_wordmark.svg b/qiskit_sphinx_theme/pytorch_base/static/images/logo_wordmark.svg similarity index 100% rename from qiskit_sphinx_theme/static/images/logo_wordmark.svg rename to qiskit_sphinx_theme/pytorch_base/static/images/logo_wordmark.svg diff --git a/qiskit_sphinx_theme/static/images/qiskit-chevron-down.svg b/qiskit_sphinx_theme/pytorch_base/static/images/qiskit-chevron-down.svg similarity index 100% rename from qiskit_sphinx_theme/static/images/qiskit-chevron-down.svg rename to qiskit_sphinx_theme/pytorch_base/static/images/qiskit-chevron-down.svg diff --git a/qiskit_sphinx_theme/static/images/qiskit-chevron-up.svg b/qiskit_sphinx_theme/pytorch_base/static/images/qiskit-chevron-up.svg similarity index 100% rename from qiskit_sphinx_theme/static/images/qiskit-chevron-up.svg rename to qiskit_sphinx_theme/pytorch_base/static/images/qiskit-chevron-up.svg diff --git a/qiskit_sphinx_theme/static/images/search-icon.svg b/qiskit_sphinx_theme/pytorch_base/static/images/search-icon.svg similarity index 100% rename from qiskit_sphinx_theme/static/images/search-icon.svg rename to qiskit_sphinx_theme/pytorch_base/static/images/search-icon.svg diff --git a/qiskit_sphinx_theme/static/images/view-page-source-icon.svg b/qiskit_sphinx_theme/pytorch_base/static/images/view-page-source-icon.svg similarity index 100% rename from qiskit_sphinx_theme/static/images/view-page-source-icon.svg rename to qiskit_sphinx_theme/pytorch_base/static/images/view-page-source-icon.svg diff --git a/qiskit_sphinx_theme/static/js/modernizr.min.js b/qiskit_sphinx_theme/pytorch_base/static/js/modernizr.min.js similarity index 100% rename from qiskit_sphinx_theme/static/js/modernizr.min.js rename to qiskit_sphinx_theme/pytorch_base/static/js/modernizr.min.js diff --git a/qiskit_sphinx_theme/static/js/theme.js b/qiskit_sphinx_theme/pytorch_base/static/js/theme.js similarity index 100% rename from qiskit_sphinx_theme/static/js/theme.js rename to qiskit_sphinx_theme/pytorch_base/static/js/theme.js diff --git a/qiskit_sphinx_theme/theme.conf b/qiskit_sphinx_theme/pytorch_base/theme.conf similarity index 100% rename from qiskit_sphinx_theme/theme.conf rename to qiskit_sphinx_theme/pytorch_base/theme.conf diff --git a/setup.py b/setup.py index 350ae95c..42676337 100644 --- a/setup.py +++ b/setup.py @@ -1,4 +1,4 @@ -from setuptools import setup +from setuptools import find_namespace_packages, setup setup( name='qiskit_sphinx_theme', @@ -7,12 +7,7 @@ author_email="hello@qiskit.org", url="https://github.com/Qiskit/qiskit_sphinx_theme", description="A Sphinx theme for Qiskit that is based on the Pytorch Sphinx theme.", - packages=[ - "qiskit_sphinx_theme", - "qiskit_sphinx_theme.static.css", - "qiskit_sphinx_theme.static.images", - "qiskit_sphinx_theme.static.js", - ], + packages=find_namespace_packages(include=["qiskit_sphinx_theme*"]), include_package_data=True, entry_points={ 'sphinx.html_themes': [