Skip to content

Commit

Permalink
Reorganize to allow theme variants (#216)
Browse files Browse the repository at this point in the history
## 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 #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
#212 (review).
The benefit of that is we make fewer changes when adding new theme
variants (we have to add `graft qiskit_sphinx_theme/<variant>/static` to
MANIFEST.in). I verified this works by using `python -m build` and
inspecting the RECORD of the wheel, which shows the contents.
  • Loading branch information
Eric-Arellano authored Mar 16, 2023
1 parent f18d9a7 commit 664df20
Show file tree
Hide file tree
Showing 30 changed files with 14 additions and 20 deletions.
8 changes: 3 additions & 5 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -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
17 changes: 9 additions & 8 deletions qiskit_sphinx_theme/__init__.py
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes.
9 changes: 2 additions & 7 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from setuptools import setup
from setuptools import find_namespace_packages, setup

setup(
name='qiskit_sphinx_theme',
Expand All @@ -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': [
Expand Down

0 comments on commit 664df20

Please sign in to comment.