Skip to content

Commit

Permalink
Pydata 0.15 (#228)
Browse files Browse the repository at this point in the history
* Make some updates for 0.14

* Add more packages to list

Fixes #227

* Add some more style

* Add more colours and testing element to test_package

* More work towards a sunpy colour scheme

* Precommit

* rando

* More tweaks to colors

* More upstream colors, ULTRA KILL

* Revert in future maybe

* Colors

* Update pyproject.toml

* pre-commit

* override light pygments theme

* Fix navbar color

* Footer is now same as header in light theme

* fix mouse over for theme change

* Remove duplicate variables which are defined in light/dark

* Some cleanup

* Change dark theme background color back to old one

* Simplify footer text color

* Change footer background colours to be closer to old

* Remove double underline for xhoverref

* Fix misalignment of sidebar toggles

---------

Co-authored-by: Nabil Freij <nabil.freij@gmail.com>
  • Loading branch information
Cadair and nabobalis committed Mar 20, 2024
1 parent 9c61680 commit 2634f6f
Show file tree
Hide file tree
Showing 14 changed files with 169 additions and 74 deletions.
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ ci:
autoupdate_schedule: "quarterly"
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: "v0.1.9"
rev: "v0.3.1"
hooks:
- id: ruff
args: ["--fix"]
- repo: https://github.com/PyCQA/autoflake
rev: v2.2.1
rev: v2.3.0
hooks:
- id: autoflake
args:
Expand All @@ -27,7 +27,7 @@ repos:
hooks:
- id: isort
- repo: https://github.com/psf/black
rev: 23.12.1
rev: 24.2.0
hooks:
- id: black
- repo: https://github.com/pre-commit/mirrors-prettier
Expand Down
2 changes: 1 addition & 1 deletion .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ conda:
sphinx:
builder: html
configuration: docs/conf.py
fail_on_warning: false
fail_on_warning: True

formats:
- htmlzip
Expand Down
17 changes: 17 additions & 0 deletions docs/colors.rst
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,23 @@ The following image should help you understand these overlays:
</div>
</div>

Admonitions
-----------

.. admonition:: Generic Admonition

Generic admonition needs content apparently

.. attention:: attention
.. caution:: caution
.. danger:: danger
.. error:: error
.. hint:: hint
.. important:: important
.. note:: note
.. tip:: tip
.. warning:: warning

Snippets
--------

Expand Down
1 change: 1 addition & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Configuration file for the Sphinx documentation builder.
"""

import os
import sys
import datetime
Expand Down
1 change: 1 addition & 0 deletions docs/test_package/animals.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
This module provides a collection of functions.
"""

from sunpy.util.decorators import deprecated

__all__ = [
Expand Down
1 change: 1 addition & 0 deletions docs/test_package/timerange.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
This module provides a object that can handle a time range.
"""

from datetime import timedelta

import astropy.units as u
Expand Down
1 change: 1 addition & 0 deletions examples/example_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
thing>. Include links to referenced packages like this: `sunpy.io.fits` to
show the sunpy.io.fits or like this `~sunpy.io.fits` to show just 'fits'
"""

###########################################################################
# If you have multiple plots in your example, Sphinx will use the first
# plot for the thumbnail by default. You can set which plot is used as the
Expand Down
1 change: 1 addition & 0 deletions examples/section/example_template_subsection.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
thing>. Include links to referenced packages like this: `sunpy.io.fits` to
show the sunpy.io.fits or like this `~sunpy.io.fits` to show just 'fits'
"""

###########################################################################
# If you have multiple plots in your example, Sphinx will use the first
# plot for the thumbnail by default. You can set which plot is used as the
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ classifiers = [
]
requires-python = ">=3.9"
dependencies = [
"pydata-sphinx-theme<0.14",
"pydata-sphinx-theme~=0.15.0",
"sphinx"
]

Expand Down
34 changes: 5 additions & 29 deletions src/sunpy_sphinx_theme/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
SunPy Sphinx Theme.
"""

import os
from pathlib import Path
from functools import partial
Expand All @@ -17,8 +18,7 @@ def get_html_theme_path():
Return list of HTML theme paths.
"""
parent = Path(__file__).parent.resolve()
theme_path = parent / "theme" / "sunpy"
return theme_path
return parent / "theme" / "sunpy"


def default_navbar():
Expand Down Expand Up @@ -69,10 +69,9 @@ def update_config(app):
# To do this, you must manually modify `app.builder.theme_options`.
theme_options = utils.get_theme_options_dict(app)

if theme_options.get("sst_logo"):
if not isinstance(theme_options["sst_logo"], dict):
sst_logo = str(theme_options["sst_logo"])
theme_options["sst_logo"] = {"light": sst_logo, "dark": sst_logo}
if theme_options.get("sst_logo") and not isinstance(theme_options["sst_logo"], dict):
sst_logo = str(theme_options["sst_logo"])
theme_options["sst_logo"] = {"light": sst_logo, "dark": sst_logo}

theme_options["sst_is_root"] = bool(theme_options.get("sst_is_root", False))

Expand Down Expand Up @@ -132,28 +131,6 @@ def update_html_context(app: Sphinx, pagename: str, templatename: str, context,
context["sst_pathto"] = partial(sst_pathto, context)


# See https://github.com/pydata/pydata-sphinx-theme/blob/f6e1943c5f9fab4442f7e7d6f5ce5474833b66f6/src/pydata_sphinx_theme/__init__.py#L178
# Copied here to make footer_center behave like footer start and end
def update_and_remove_templates(app: Sphinx, pagename: str, templatename: str, context, doctree) -> None:
"""
Update template names and assets for page build.
"""
# Allow for more flexibility in template names
template_sections = [
"theme_footer_center",
]
for section in template_sections:
if context.get(section):
# Break apart `,` separated strings so we can use , in the defaults
if isinstance(context.get(section), str):
context[section] = [ii.strip() for ii in context.get(section).split(",")]

# Add `.html` to templates with no suffix
for ii, template in enumerate(context.get(section)):
if not os.path.splitext(template)[1]:
context[section][ii] = template + ".html"


def setup(app: Sphinx):
# Register theme
theme_dir = get_html_theme_path()
Expand All @@ -162,7 +139,6 @@ def setup(app: Sphinx):

app.connect("builder-inited", update_config)
app.connect("html-page-context", update_html_context)
app.connect("html-page-context", update_and_remove_templates)

return {
"parallel_read_safe": True,
Expand Down
10 changes: 9 additions & 1 deletion src/sunpy_sphinx_theme/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,20 @@
now been moved into the theme itself or can be imported from the main namespace
of the theme.
"""

from sunpy_sphinx_theme import ON_RTD as on_rtd # noqa
from sunpy_sphinx_theme import PNG_ICON as png_icon # noqa
from sunpy_sphinx_theme import SVG_ICON as svg_icon # noqa
from sunpy_sphinx_theme import get_html_theme_path

__all__ = ["html_static_path", "html_theme_path", "html_theme", "on_rtd", "png_icon", "svg_icon"]
__all__ = [
"html_static_path",
"html_theme_path",
"html_theme",
"on_rtd",
"png_icon",
"svg_icon",
]

html_theme = "sunpy"
html_theme_options = {}
Expand Down

0 comments on commit 2634f6f

Please sign in to comment.