Skip to content

Commit

Permalink
ci/docs: set Sphinx public theme as alternative (#236)
Browse files Browse the repository at this point in the history
  • Loading branch information
Borda authored Apr 19, 2024
1 parent 91ac188 commit 593c2f1
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 13 deletions.
9 changes: 2 additions & 7 deletions .github/workflows/docs-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,10 @@ jobs:
python-version: "3.10"

- name: Pull sphinx template
run: |
pip install -q "awscli >=1.30.0"
aws s3 sync --no-sign-request s3://sphinx-packages/ ${PYPI_LOCAL_DIR}
pip install lai-sphinx-theme -U -f ${PYPI_LOCAL_DIR}
run: make get-sphinx-theme
- name: Install pandoc
timeout-minutes: 5
run: |
sudo apt-get update --fix-missing
sudo apt-get install -y pandoc
run: sudo apt-get install -y pandoc
- name: Install package & dependencies
timeout-minutes: 20
run: pip install . -U -r requirements/docs.txt
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ test: clean
python -m coverage run --source thunder -m pytest thunder tests -v
python -m coverage report

sphinx-theme:
get-sphinx-theme:
pip install -q awscli
mkdir -p dist/
aws s3 sync --no-sign-request s3://sphinx-packages/ dist/
pip install lai-sphinx-theme -f dist/

docs: clean sphinx-theme
docs: clean get-sphinx-theme
pip install -e . --quiet -r requirements/docs.txt -f https://download.pytorch.org/whl/cpu/torch_stable.html
cd docs ; python -m sphinx -b html -W --keep-going source build

Expand Down
25 changes: 21 additions & 4 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,21 @@
import sys
from importlib.util import module_from_spec, spec_from_file_location

import lai_sphinx_theme
from lightning_utilities.core.imports import package_available

_INSTALLED_NEW_THEME = package_available("lai_sphinx_theme")

if _INSTALLED_NEW_THEME:
import lai_sphinx_theme
else:
import pt_lightning_sphinx_theme
import warnings

warnings.warn(
"You are using the old theme, please install the new theme 'lai_sphinx_theme';"
" you can do this by running 'make get-sphinx-theme'."
)


_PATH_HERE = os.path.abspath(os.path.dirname(__file__))
_PATH_ROOT = os.path.realpath(os.path.join(_PATH_HERE, "..", ".."))
Expand Down Expand Up @@ -98,8 +112,9 @@ def _transform_changelog(path_in: str, path_out: str) -> None:
"sphinx_copybutton",
"sphinx_paramlinks",
"sphinx_togglebutton",
"lai_sphinx_theme.extensions.lightning",
]
if _INSTALLED_NEW_THEME:
extensions.append("lai_sphinx_theme.extensions.lightning")

# Add any paths that contain templates here, relative to this directory.
templates_path = ["_templates"]
Expand Down Expand Up @@ -152,8 +167,10 @@ def _transform_changelog(path_in: str, path_out: str) -> None:
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
html_theme = "lai_sphinx_theme"
html_theme_path = [lai_sphinx_theme.get_html_theme_path()]
html_theme = "lai_sphinx_theme" if _INSTALLED_NEW_THEME else "pt_lightning_sphinx_theme"
html_theme_path = [
lai_sphinx_theme.get_html_theme_path() if _INSTALLED_NEW_THEME else pt_lightning_sphinx_theme.get_html_theme_path()
]

# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
Expand Down
2 changes: 2 additions & 0 deletions requirements/docs.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,5 @@ sphinx-copybutton ==0.5.2

# installed from S3 location and fetched in advance
lai-sphinx-theme
# alternative /back-up (old) theme
pt-lightning-sphinx-theme @ https://github.com/PyTorchLightning/lightning_sphinx_theme/archive/master.zip

0 comments on commit 593c2f1

Please sign in to comment.