sunpy-sphinx-theme 2.1.1__tar.gz → 2.2.1__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.1}/PKG-INFO +2 -1
  2. {sunpy_sphinx_theme-2.1.1 → sunpy_sphinx_theme-2.2.1}/pyproject.toml +6 -0
  3. {sunpy_sphinx_theme-2.1.1 → sunpy_sphinx_theme-2.2.1}/src/sunpy_sphinx_theme/__init__.py +57 -5
  4. {sunpy_sphinx_theme-2.1.1 → sunpy_sphinx_theme-2.2.1}/src/sunpy_sphinx_theme/theme/sunpy/static/sunpy_style.css +26 -2
  5. {sunpy_sphinx_theme-2.1.1 → sunpy_sphinx_theme-2.2.1}/src/sunpy_sphinx_theme.egg-info/PKG-INFO +2 -1
  6. {sunpy_sphinx_theme-2.1.1 → sunpy_sphinx_theme-2.2.1}/src/sunpy_sphinx_theme.egg-info/requires.txt +1 -0
  7. {sunpy_sphinx_theme-2.1.1 → sunpy_sphinx_theme-2.2.1}/.editorconfig +0 -0
  8. {sunpy_sphinx_theme-2.1.1 → sunpy_sphinx_theme-2.2.1}/.readthedocs.yaml +0 -0
  9. {sunpy_sphinx_theme-2.1.1 → sunpy_sphinx_theme-2.2.1}/.rtd-environment.yml +0 -0
  10. {sunpy_sphinx_theme-2.1.1 → sunpy_sphinx_theme-2.2.1}/.stylelintrc.json +0 -0
  11. {sunpy_sphinx_theme-2.1.1 → sunpy_sphinx_theme-2.2.1}/LICENSE.md +0 -0
  12. {sunpy_sphinx_theme-2.1.1 → sunpy_sphinx_theme-2.2.1}/MANIFEST.in +0 -0
  13. {sunpy_sphinx_theme-2.1.1 → sunpy_sphinx_theme-2.2.1}/README.md +0 -0
  14. {sunpy_sphinx_theme-2.1.1 → sunpy_sphinx_theme-2.2.1}/_typos.toml +0 -0
  15. {sunpy_sphinx_theme-2.1.1 → sunpy_sphinx_theme-2.2.1}/ruff.toml +0 -0
  16. {sunpy_sphinx_theme-2.1.1 → sunpy_sphinx_theme-2.2.1}/setup.cfg +0 -0
  17. {sunpy_sphinx_theme-2.1.1 → sunpy_sphinx_theme-2.2.1}/src/sunpy_sphinx_theme/cards.py +0 -0
  18. {sunpy_sphinx_theme-2.1.1 → sunpy_sphinx_theme-2.2.1}/src/sunpy_sphinx_theme/conf.py +0 -0
  19. {sunpy_sphinx_theme-2.1.1 → sunpy_sphinx_theme-2.2.1}/src/sunpy_sphinx_theme/theme/sunpy/components/built-with.html +0 -0
  20. {sunpy_sphinx_theme-2.1.1 → sunpy_sphinx_theme-2.2.1}/src/sunpy_sphinx_theme/theme/sunpy/components/footer-links.html +0 -0
  21. {sunpy_sphinx_theme-2.1.1 → sunpy_sphinx_theme-2.2.1}/src/sunpy_sphinx_theme/theme/sunpy/components/navbar-logo.html +0 -0
  22. {sunpy_sphinx_theme-2.1.1 → sunpy_sphinx_theme-2.2.1}/src/sunpy_sphinx_theme/theme/sunpy/components/navbar_center.html +0 -0
  23. {sunpy_sphinx_theme-2.1.1 → sunpy_sphinx_theme-2.2.1}/src/sunpy_sphinx_theme/theme/sunpy/components/navbar_start.html +0 -0
  24. {sunpy_sphinx_theme-2.1.1 → sunpy_sphinx_theme-2.2.1}/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.1}/src/sunpy_sphinx_theme/theme/sunpy/sections/header.html +0 -0
  26. {sunpy_sphinx_theme-2.1.1 → sunpy_sphinx_theme-2.2.1}/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.1}/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.1}/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.1}/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.1}/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.1}/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.1}/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.1}/src/sunpy_sphinx_theme/theme/sunpy/theme.toml +0 -0
  34. {sunpy_sphinx_theme-2.1.1 → sunpy_sphinx_theme-2.2.1}/src/sunpy_sphinx_theme.egg-info/SOURCES.txt +0 -0
  35. {sunpy_sphinx_theme-2.1.1 → sunpy_sphinx_theme-2.2.1}/src/sunpy_sphinx_theme.egg-info/dependency_links.txt +0 -0
  36. {sunpy_sphinx_theme-2.1.1 → sunpy_sphinx_theme-2.2.1}/src/sunpy_sphinx_theme.egg-info/entry_points.txt +0 -0
  37. {sunpy_sphinx_theme-2.1.1 → sunpy_sphinx_theme-2.2.1}/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.1
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
@@ -4,16 +4,19 @@ SunPy Sphinx Theme.
4
4
 
5
5
  import json
6
6
  import os
7
+ import posixpath
7
8
  from functools import partial
8
- from pathlib import Path
9
+ from pathlib import Path, PurePosixPath
9
10
  from textwrap import dedent, indent
10
- from urllib.parse import urljoin
11
+ from urllib.parse import urljoin, urlparse
11
12
 
12
13
  from pydata_sphinx_theme import utils
13
14
  from sphinx.application import Sphinx
14
15
 
15
16
  __all__ = ["ON_RTD", "PNG_ICON", "SVG_ICON", "get_html_theme_path"]
16
17
 
18
+ SPHINX_GALLERY_IMAGE_EXTENSIONS = {".apng", ".gif", ".jpeg", ".jpg", ".png", ".webp"}
19
+
17
20
 
18
21
  def get_theme_options(app):
19
22
  """
@@ -55,18 +58,32 @@ def update_config(app) -> None:
55
58
  if not utils.config_provided_by_user(app, "html_logo"):
56
59
  app.config.html_logo = str(get_html_theme_path() / "static" / "img" / "sunpy_icon.svg")
57
60
 
61
+ if not utils.config_provided_by_user(app, "ogp_use_first_image"):
62
+ app.config.ogp_use_first_image = True
63
+
64
+ if app.config.html_baseurl and not utils.config_provided_by_user(app, "ogp_site_url"):
65
+ app.config.ogp_site_url = app.config.html_baseurl
66
+
58
67
  # Include sunpy.org in extra_search_projects as long as none of
59
68
  # navbar_links, rtd_search_projects and rtd_extra_search_projects
60
69
  # are set, i.e. you are using the default sunpy set of projects.
61
70
  # Without this non-sunpy projects would have to explicitly un-set
62
71
  # rtd_extra_search_projects
63
72
  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")
73
+ "navbar_links" not in theme_options
74
+ or "rtd_search_projects" not in theme_options
75
+ or "rtd_extra_search_projects" not in theme_options
67
76
  ):
68
77
  theme_options["rtd_extra_search_projects"] = [["sunpyorg", "https://sunpy.org"]]
69
78
 
79
+ if "sphinx_gallery.gen_gallery" in app.extensions:
80
+ ssi = theme_options_with_defaults["secondary_sidebar_items"].split(",")
81
+ if "sg_download_links" not in ssi:
82
+ ssi.append("sg_download_links")
83
+ if "sg_launcher_links" not in ssi:
84
+ ssi.append("sg_launcher_links")
85
+ theme_options["secondary_sidebar_items"] = ", ".join(ssi)
86
+
70
87
 
71
88
  def sst_pathto(context, document, relative_to=0):
72
89
  """
@@ -105,6 +122,38 @@ def update_html_context(app: Sphinx, pagename: str, templatename: str, context,
105
122
  context["sst_pathto"] = partial(sst_pathto, context)
106
123
 
107
124
 
125
+ def update_opengraph_context(app: Sphinx, pagename: str, templatename: str, context, doctree) -> None: # NOQA: ARG001
126
+ """
127
+ Add Sphinx-Gallery images to the Open Graph metadata context.
128
+ """
129
+ if doctree is None:
130
+ return
131
+
132
+ metadata = context.get("meta") or {}
133
+ if "og:image" in metadata:
134
+ return
135
+
136
+ for node in doctree.findall():
137
+ if node.__class__.__name__ != "imgsgnode" or not node.get("uri"):
138
+ continue
139
+
140
+ parsed_uri = urlparse(node["uri"])
141
+ image_suffix = PurePosixPath(parsed_uri.path).suffix.lower()
142
+ if image_suffix not in SPHINX_GALLERY_IMAGE_EXTENSIONS:
143
+ continue
144
+
145
+ if parsed_uri.scheme:
146
+ metadata["og:image"] = node["uri"]
147
+ else:
148
+ metadata["og:image"] = posixpath.join(app.builder.imagedir, PurePosixPath(parsed_uri.path).name)
149
+
150
+ if node.get("alt") and "og:image:alt" not in metadata:
151
+ metadata["og:image:alt"] = node["alt"]
152
+
153
+ context["meta"] = metadata
154
+ return
155
+
156
+
108
157
  def generate_search_config(app):
109
158
  """
110
159
  This function parses the config for the "Documentation" section of the theme config.
@@ -150,12 +199,15 @@ def generate_search_config(app):
150
199
 
151
200
 
152
201
  def setup(app: Sphinx):
202
+ app.setup_extension("sphinxext.opengraph")
203
+
153
204
  # Register theme
154
205
  theme_dir = get_html_theme_path()
155
206
  app.add_html_theme("sunpy", theme_dir)
156
207
  app.add_css_file("sunpy_style.css", priority=600)
157
208
  app.connect("builder-inited", update_config, priority=100)
158
209
  app.connect("builder-inited", generate_search_config, priority=500)
210
+ app.connect("html-page-context", update_opengraph_context, priority=400)
159
211
  app.connect("html-page-context", update_html_context)
160
212
  # Conditionally include goat counter js
161
213
  # 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.1
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]