sunpy-sphinx-theme 2.1.1__tar.gz → 2.2.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. {sunpy_sphinx_theme-2.1.1 → sunpy_sphinx_theme-2.2.0}/PKG-INFO +2 -1
  2. {sunpy_sphinx_theme-2.1.1 → sunpy_sphinx_theme-2.2.0}/pyproject.toml +6 -0
  3. {sunpy_sphinx_theme-2.1.1 → sunpy_sphinx_theme-2.2.0}/src/sunpy_sphinx_theme/__init__.py +58 -5
  4. {sunpy_sphinx_theme-2.1.1 → sunpy_sphinx_theme-2.2.0}/src/sunpy_sphinx_theme/theme/sunpy/static/sunpy_style.css +26 -2
  5. {sunpy_sphinx_theme-2.1.1 → sunpy_sphinx_theme-2.2.0}/src/sunpy_sphinx_theme.egg-info/PKG-INFO +2 -1
  6. {sunpy_sphinx_theme-2.1.1 → sunpy_sphinx_theme-2.2.0}/src/sunpy_sphinx_theme.egg-info/requires.txt +1 -0
  7. {sunpy_sphinx_theme-2.1.1 → sunpy_sphinx_theme-2.2.0}/.editorconfig +0 -0
  8. {sunpy_sphinx_theme-2.1.1 → sunpy_sphinx_theme-2.2.0}/.readthedocs.yaml +0 -0
  9. {sunpy_sphinx_theme-2.1.1 → sunpy_sphinx_theme-2.2.0}/.rtd-environment.yml +0 -0
  10. {sunpy_sphinx_theme-2.1.1 → sunpy_sphinx_theme-2.2.0}/.stylelintrc.json +0 -0
  11. {sunpy_sphinx_theme-2.1.1 → sunpy_sphinx_theme-2.2.0}/LICENSE.md +0 -0
  12. {sunpy_sphinx_theme-2.1.1 → sunpy_sphinx_theme-2.2.0}/MANIFEST.in +0 -0
  13. {sunpy_sphinx_theme-2.1.1 → sunpy_sphinx_theme-2.2.0}/README.md +0 -0
  14. {sunpy_sphinx_theme-2.1.1 → sunpy_sphinx_theme-2.2.0}/_typos.toml +0 -0
  15. {sunpy_sphinx_theme-2.1.1 → sunpy_sphinx_theme-2.2.0}/ruff.toml +0 -0
  16. {sunpy_sphinx_theme-2.1.1 → sunpy_sphinx_theme-2.2.0}/setup.cfg +0 -0
  17. {sunpy_sphinx_theme-2.1.1 → sunpy_sphinx_theme-2.2.0}/src/sunpy_sphinx_theme/cards.py +0 -0
  18. {sunpy_sphinx_theme-2.1.1 → sunpy_sphinx_theme-2.2.0}/src/sunpy_sphinx_theme/conf.py +0 -0
  19. {sunpy_sphinx_theme-2.1.1 → sunpy_sphinx_theme-2.2.0}/src/sunpy_sphinx_theme/theme/sunpy/components/built-with.html +0 -0
  20. {sunpy_sphinx_theme-2.1.1 → sunpy_sphinx_theme-2.2.0}/src/sunpy_sphinx_theme/theme/sunpy/components/footer-links.html +0 -0
  21. {sunpy_sphinx_theme-2.1.1 → sunpy_sphinx_theme-2.2.0}/src/sunpy_sphinx_theme/theme/sunpy/components/navbar-logo.html +0 -0
  22. {sunpy_sphinx_theme-2.1.1 → sunpy_sphinx_theme-2.2.0}/src/sunpy_sphinx_theme/theme/sunpy/components/navbar_center.html +0 -0
  23. {sunpy_sphinx_theme-2.1.1 → sunpy_sphinx_theme-2.2.0}/src/sunpy_sphinx_theme/theme/sunpy/components/navbar_start.html +0 -0
  24. {sunpy_sphinx_theme-2.1.1 → sunpy_sphinx_theme-2.2.0}/src/sunpy_sphinx_theme/theme/sunpy/components/sst-sidebar-nav.html +0 -0
  25. {sunpy_sphinx_theme-2.1.1 → sunpy_sphinx_theme-2.2.0}/src/sunpy_sphinx_theme/theme/sunpy/sections/header.html +0 -0
  26. {sunpy_sphinx_theme-2.1.1 → sunpy_sphinx_theme-2.2.0}/src/sunpy_sphinx_theme/theme/sunpy/static/css/rtd_enhanced_search.css +0 -0
  27. {sunpy_sphinx_theme-2.1.1 → sunpy_sphinx_theme-2.2.0}/src/sunpy_sphinx_theme/theme/sunpy/static/css/sunpy_cards.css +0 -0
  28. {sunpy_sphinx_theme-2.1.1 → sunpy_sphinx_theme-2.2.0}/src/sunpy_sphinx_theme/theme/sunpy/static/img/favicon-32.ico +0 -0
  29. {sunpy_sphinx_theme-2.1.1 → sunpy_sphinx_theme-2.2.0}/src/sunpy_sphinx_theme/theme/sunpy/static/img/sunpy_icon.svg +0 -0
  30. {sunpy_sphinx_theme-2.1.1 → sunpy_sphinx_theme-2.2.0}/src/sunpy_sphinx_theme/theme/sunpy/static/img/sunpy_icon_128x128.png +0 -0
  31. {sunpy_sphinx_theme-2.1.1 → sunpy_sphinx_theme-2.2.0}/src/sunpy_sphinx_theme/theme/sunpy/static/js/rtd_enhanced_search.js +0 -0
  32. {sunpy_sphinx_theme-2.1.1 → sunpy_sphinx_theme-2.2.0}/src/sunpy_sphinx_theme/theme/sunpy/static/js/submenu-concertina-toggle.js +0 -0
  33. {sunpy_sphinx_theme-2.1.1 → sunpy_sphinx_theme-2.2.0}/src/sunpy_sphinx_theme/theme/sunpy/theme.toml +0 -0
  34. {sunpy_sphinx_theme-2.1.1 → sunpy_sphinx_theme-2.2.0}/src/sunpy_sphinx_theme.egg-info/SOURCES.txt +0 -0
  35. {sunpy_sphinx_theme-2.1.1 → sunpy_sphinx_theme-2.2.0}/src/sunpy_sphinx_theme.egg-info/dependency_links.txt +0 -0
  36. {sunpy_sphinx_theme-2.1.1 → sunpy_sphinx_theme-2.2.0}/src/sunpy_sphinx_theme.egg-info/entry_points.txt +0 -0
  37. {sunpy_sphinx_theme-2.1.1 → sunpy_sphinx_theme-2.2.0}/src/sunpy_sphinx_theme.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: sunpy-sphinx-theme
3
- Version: 2.1.1
3
+ Version: 2.2.0
4
4
  Summary: The sphinx theme for the SunPy website and documentation.
5
5
  Author: The SunPy Developers
6
6
  License: BSD 2-Clause License
@@ -40,6 +40,7 @@ Requires-Python: >=3.9
40
40
  Description-Content-Type: text/markdown
41
41
  License-File: LICENSE.md
42
42
  Requires-Dist: pydata-sphinx-theme~=0.17
43
+ Requires-Dist: sphinxext-opengraph>=0.13
43
44
  Requires-Dist: sphinx>=7.3.0
44
45
  Provides-Extra: docs
45
46
  Requires-Dist: matplotlib; extra == "docs"
@@ -23,6 +23,7 @@ classifiers = [
23
23
  requires-python = ">=3.9"
24
24
  dependencies = [
25
25
  "pydata-sphinx-theme~=0.17",
26
+ "sphinxext-opengraph>=0.13",
26
27
  "sphinx>=7.3.0"
27
28
  ]
28
29
 
@@ -63,3 +64,8 @@ include-package-data = true
63
64
  url = "sunpy_docs-devdeps/sunpy/docs/_build/html/index.html"
64
65
  message = "sunpy docs with devdeps preview"
65
66
  report_on_fail = true
67
+
68
+ [ tool.gilesbot.circleci_artifacts.astropy_website ]
69
+ url = "astropy.org/_build/html/index.html"
70
+ message = "Astropy website preview"
71
+ report_on_fail = true
@@ -2,18 +2,22 @@
2
2
  SunPy Sphinx Theme.
3
3
  """
4
4
 
5
+ import importlib
5
6
  import json
6
7
  import os
8
+ import posixpath
7
9
  from functools import partial
8
- from pathlib import Path
10
+ from pathlib import Path, PurePosixPath
9
11
  from textwrap import dedent, indent
10
- from urllib.parse import urljoin
12
+ from urllib.parse import urljoin, urlparse
11
13
 
12
14
  from pydata_sphinx_theme import utils
13
15
  from sphinx.application import Sphinx
14
16
 
15
17
  __all__ = ["ON_RTD", "PNG_ICON", "SVG_ICON", "get_html_theme_path"]
16
18
 
19
+ SPHINX_GALLERY_IMAGE_EXTENSIONS = {".apng", ".gif", ".jpeg", ".jpg", ".png", ".webp"}
20
+
17
21
 
18
22
  def get_theme_options(app):
19
23
  """
@@ -55,18 +59,32 @@ def update_config(app) -> None:
55
59
  if not utils.config_provided_by_user(app, "html_logo"):
56
60
  app.config.html_logo = str(get_html_theme_path() / "static" / "img" / "sunpy_icon.svg")
57
61
 
62
+ if not utils.config_provided_by_user(app, "ogp_use_first_image"):
63
+ app.config.ogp_use_first_image = True
64
+
65
+ if app.config.html_baseurl and not utils.config_provided_by_user(app, "ogp_site_url"):
66
+ app.config.ogp_site_url = app.config.html_baseurl
67
+
58
68
  # Include sunpy.org in extra_search_projects as long as none of
59
69
  # navbar_links, rtd_search_projects and rtd_extra_search_projects
60
70
  # are set, i.e. you are using the default sunpy set of projects.
61
71
  # Without this non-sunpy projects would have to explicitly un-set
62
72
  # rtd_extra_search_projects
63
73
  if not (
64
- utils.config_provided_by_user(app, "navbar_links")
65
- or utils.config_provided_by_user(app, "rtd_search_projects")
66
- or utils.config_provided_by_user(app, "rtd_extra_search_projects")
74
+ "navbar_links" not in theme_options
75
+ or "rtd_search_projects" not in theme_options
76
+ or "rtd_extra_search_projects" not in theme_options
67
77
  ):
68
78
  theme_options["rtd_extra_search_projects"] = [["sunpyorg", "https://sunpy.org"]]
69
79
 
80
+ if importlib.util.find_spec("sphinx_gallery"):
81
+ ssi = theme_options_with_defaults["secondary_sidebar_items"].split(",")
82
+ if "sg_download_links" not in ssi:
83
+ ssi.append("sg_download_links")
84
+ if "sg_launcher_links" not in ssi:
85
+ ssi.append("sg_launcher_links")
86
+ theme_options["secondary_sidebar_items"] = ", ".join(ssi)
87
+
70
88
 
71
89
  def sst_pathto(context, document, relative_to=0):
72
90
  """
@@ -105,6 +123,38 @@ def update_html_context(app: Sphinx, pagename: str, templatename: str, context,
105
123
  context["sst_pathto"] = partial(sst_pathto, context)
106
124
 
107
125
 
126
+ def update_opengraph_context(app: Sphinx, pagename: str, templatename: str, context, doctree) -> None: # NOQA: ARG001
127
+ """
128
+ Add Sphinx-Gallery images to the Open Graph metadata context.
129
+ """
130
+ if doctree is None:
131
+ return
132
+
133
+ metadata = context.get("meta") or {}
134
+ if "og:image" in metadata:
135
+ return
136
+
137
+ for node in doctree.findall():
138
+ if node.__class__.__name__ != "imgsgnode" or not node.get("uri"):
139
+ continue
140
+
141
+ parsed_uri = urlparse(node["uri"])
142
+ image_suffix = PurePosixPath(parsed_uri.path).suffix.lower()
143
+ if image_suffix not in SPHINX_GALLERY_IMAGE_EXTENSIONS:
144
+ continue
145
+
146
+ if parsed_uri.scheme:
147
+ metadata["og:image"] = node["uri"]
148
+ else:
149
+ metadata["og:image"] = posixpath.join(app.builder.imagedir, PurePosixPath(parsed_uri.path).name)
150
+
151
+ if node.get("alt") and "og:image:alt" not in metadata:
152
+ metadata["og:image:alt"] = node["alt"]
153
+
154
+ context["meta"] = metadata
155
+ return
156
+
157
+
108
158
  def generate_search_config(app):
109
159
  """
110
160
  This function parses the config for the "Documentation" section of the theme config.
@@ -150,12 +200,15 @@ def generate_search_config(app):
150
200
 
151
201
 
152
202
  def setup(app: Sphinx):
203
+ app.setup_extension("sphinxext.opengraph")
204
+
153
205
  # Register theme
154
206
  theme_dir = get_html_theme_path()
155
207
  app.add_html_theme("sunpy", theme_dir)
156
208
  app.add_css_file("sunpy_style.css", priority=600)
157
209
  app.connect("builder-inited", update_config, priority=100)
158
210
  app.connect("builder-inited", generate_search_config, priority=500)
211
+ app.connect("html-page-context", update_opengraph_context, priority=400)
159
212
  app.connect("html-page-context", update_html_context)
160
213
  # Conditionally include goat counter js
161
214
  # We can't do this in update_config as that causes the scripts to be duplicated.
@@ -154,6 +154,16 @@ body {
154
154
  color: var(--sg-download-a-color);
155
155
  }
156
156
 
157
+ /* Hide the download buttons in the gallery pages, as they are in the secondary side bar */
158
+ .sphx-glr-download-link-note, /* Download link note in header */
159
+ .binder-badge, /* Binder launch badge in footer */
160
+ .lite-badge, /* Lite launch badge in footer */
161
+ .sphx-glr-download-jupyter, /* Download Jupyter notebook link in footer */
162
+ .sphx-glr-download-python, /* Download Python script link in footer */
163
+ .sphx-glr-download-zip /* Download zipped link in footer */ {
164
+ display: none;
165
+ }
166
+
157
167
  /* Global Styling */
158
168
  a:visited {
159
169
  color: var(--pst-color-link);
@@ -290,6 +300,12 @@ html[data-theme="light"] .bd-sidebar-primary .theme-switch-button span {
290
300
  border-right-color: var(--sst-accent-color-bright);
291
301
  }
292
302
 
303
+ /* Put the logo above the version. */
304
+ div.sidebar-primary-item > a.logo {
305
+ display: flex;
306
+ flex-direction: column;
307
+ }
308
+
293
309
  /* Both left and right sidebars */
294
310
  .bd-sidebar-primary,
295
311
  .bd-sidebar-secondary {
@@ -319,7 +335,7 @@ html[data-theme="light"] .bd-sidebar-primary .theme-switch-button span {
319
335
  }
320
336
 
321
337
  img.logo__image {
322
- height: var(--pst-header-height);
338
+ max-height: var(--pst-header-height);
323
339
  }
324
340
 
325
341
  .bd-sidebar-primary .sidebar-primary-items__end {
@@ -468,7 +484,7 @@ html[data-theme="dark"] .search-button-field:hover {
468
484
  .navbar-nav .concertina-toggle:hover,
469
485
  .bd-header .dropdown-item:hover,
470
486
  .bd-header .concertina-toggle:hover {
471
- color: var(--pst-color-link-hover);
487
+ color: var(--sst-accent-color-bright);
472
488
  background-color: transparent;
473
489
  text-decoration: underline;
474
490
  }
@@ -482,7 +498,15 @@ html[data-theme="dark"] .search-button-field:hover {
482
498
  }
483
499
  /* Limit the height of dropdown menu to keep on screen */
484
500
  .bd-header .dropdown-menu {
501
+ --bs-dropdown-bg: var(--sst-header-background);
502
+ --bs-dropdown-color: var(--sst-header-text);
503
+ --bs-dropdown-link-active-bg: var(--bs-dropdown-bg);
485
504
  max-height: 80vh;
486
505
  overflow-y: auto;
487
506
  overscroll-behavior: contain;
488
507
  }
508
+ .dropdown-item.active,
509
+ .dropdown-item:active {
510
+ color: var(--bs-dropdown-link-active-color);
511
+ text-decoration: none;
512
+ }
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: sunpy-sphinx-theme
3
- Version: 2.1.1
3
+ Version: 2.2.0
4
4
  Summary: The sphinx theme for the SunPy website and documentation.
5
5
  Author: The SunPy Developers
6
6
  License: BSD 2-Clause License
@@ -40,6 +40,7 @@ Requires-Python: >=3.9
40
40
  Description-Content-Type: text/markdown
41
41
  License-File: LICENSE.md
42
42
  Requires-Dist: pydata-sphinx-theme~=0.17
43
+ Requires-Dist: sphinxext-opengraph>=0.13
43
44
  Requires-Dist: sphinx>=7.3.0
44
45
  Provides-Extra: docs
45
46
  Requires-Dist: matplotlib; extra == "docs"
@@ -1,4 +1,5 @@
1
1
  pydata-sphinx-theme~=0.17
2
+ sphinxext-opengraph>=0.13
2
3
  sphinx>=7.3.0
3
4
 
4
5
  [docs]