From 14be8c38def946965fc1d0bcc0ce9ebf1bc07f80 Mon Sep 17 00:00:00 2001 From: Stuart Mumford Date: Fri, 15 Sep 2023 11:49:20 +0100 Subject: [PATCH 01/13] Make some updates for 0.14 --- pyproject.toml | 2 +- src/sunpy_sphinx_theme/__init__.py | 23 ------------------- .../theme/sunpy/static/sunpy_style.css | 22 ++++-------------- src/sunpy_sphinx_theme/theme/sunpy/theme.conf | 2 +- 4 files changed, 6 insertions(+), 43 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index f1d22676..c4c46b0f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -23,7 +23,7 @@ classifiers = [ ] requires-python = ">=3.7" dependencies = [ - "pydata-sphinx-theme<0.14", + "pydata-sphinx-theme~=0.14.0", "sphinx" ] diff --git a/src/sunpy_sphinx_theme/__init__.py b/src/sunpy_sphinx_theme/__init__.py index d3cffcfa..8e2d22c9 100644 --- a/src/sunpy_sphinx_theme/__init__.py +++ b/src/sunpy_sphinx_theme/__init__.py @@ -130,28 +130,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() @@ -160,7 +138,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, diff --git a/src/sunpy_sphinx_theme/theme/sunpy/static/sunpy_style.css b/src/sunpy_sphinx_theme/theme/sunpy/static/sunpy_style.css index 4185ed55..5c121d49 100644 --- a/src/sunpy_sphinx_theme/theme/sunpy/static/sunpy_style.css +++ b/src/sunpy_sphinx_theme/theme/sunpy/static/sunpy_style.css @@ -166,6 +166,10 @@ html[data-theme="light"] .bd-sidebar-primary .theme-switch-button span { border-color: var(--sst-accent-color-bright); } +.bd-header .navbar-header-items__start { + width: auto; +} + /* Sidebar */ .bd-sidebar-primary { background-color: var(--sst-sidebar-background-color); @@ -219,24 +223,6 @@ img.logo__image { border-top: none; } -/* Override the default start and end from pst here so we make it the same as our new center */ -.bd-footer .footer-items__end, -.bd-footer .footer-items__start, -.bd-footer .footer-items__center { - display: flex; - flex-direction: column; - justify-content: center; - flex-grow: 1; -} - -.bd-footer .footer-items__center { - text-align: center; -} - -.bd-footer .footer-items__end { - margin-left: 0; -} - .bd-footer a { color: var(--pst-color-link); } diff --git a/src/sunpy_sphinx_theme/theme/sunpy/theme.conf b/src/sunpy_sphinx_theme/theme/sunpy/theme.conf index 309b7ad0..b8721627 100644 --- a/src/sunpy_sphinx_theme/theme/sunpy/theme.conf +++ b/src/sunpy_sphinx_theme/theme/sunpy/theme.conf @@ -7,10 +7,10 @@ navbar_start = components/navbar_start.html navbar_center = components/navbar_center.html footer_start = copyright.html +footer_center = components/footer-links.html footer_end = components/built-with.html # sunpy-sphinx-theme config -footer_center = components/footer-links.html # This config sets the base URL for top navbar items when sst_is_root is False sst_site_root = https://sunpy.org # If true then the site that's being built is the site that's normally deployed at sst_site_root From 2a97f69296d89963cefe1740806f33859a7ee833 Mon Sep 17 00:00:00 2001 From: Stuart Mumford Date: Fri, 15 Sep 2023 11:52:32 +0100 Subject: [PATCH 02/13] Add more packages to list Fixes #227 --- src/sunpy_sphinx_theme/__init__.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/sunpy_sphinx_theme/__init__.py b/src/sunpy_sphinx_theme/__init__.py index 8e2d22c9..3c3ace38 100644 --- a/src/sunpy_sphinx_theme/__init__.py +++ b/src/sunpy_sphinx_theme/__init__.py @@ -48,6 +48,8 @@ def default_navbar(): ("sunraster", "https://docs.sunpy.org/projects/sunraster/", 3), ("sunpy-soar", "https://github.com/sunpy/sunpy-soar#readme", 3), ("roentgen", "https://roentgen.readthedocs.io/", 3), + ("demcmc", "https://demcmc.readthedocs.io/en/latest/", 3), + ("dkist", "https://docs.dkist.nso.edu/projects/python-tools", 3), ], ), ("Affiliated Packages", "affiliated.html", 2), From 0cf8206bc85cb556fd8ee4e1f6b9d297dc1c3cdf Mon Sep 17 00:00:00 2001 From: Stuart Mumford Date: Mon, 18 Sep 2023 09:56:55 +0100 Subject: [PATCH 03/13] Add some more style --- src/sunpy_sphinx_theme/theme/sunpy/static/sunpy_style.css | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/sunpy_sphinx_theme/theme/sunpy/static/sunpy_style.css b/src/sunpy_sphinx_theme/theme/sunpy/static/sunpy_style.css index 5c121d49..41f8e5b2 100644 --- a/src/sunpy_sphinx_theme/theme/sunpy/static/sunpy_style.css +++ b/src/sunpy_sphinx_theme/theme/sunpy/static/sunpy_style.css @@ -72,6 +72,10 @@ body { --sg-thumb-hover-border: var(--sst-accent-color-bright); } +.sphx-glr-download a > code { + color: var(--sg-download-a-color); +} + /* Global Styling */ a:visited { color: var(--pst-color-link); @@ -232,6 +236,10 @@ img.logo__image { padding: 0 10px; } +.bd-footer .footer-items__center { + text-align: left; +} + /* This width is hard coded, ideally it should be when then content gets wider than */ /* the viewport, I just don't know how to do that. */ @media only screen and (max-width: 800px) { From 92cba39932238966bca0a05e13932d3550dc7247 Mon Sep 17 00:00:00 2001 From: Stuart Mumford Date: Mon, 18 Sep 2023 09:57:10 +0100 Subject: [PATCH 04/13] Add more colours and testing element to test_package --- test_package/docs/index.rst | 60 +++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) diff --git a/test_package/docs/index.rst b/test_package/docs/index.rst index a15eb162..7ad23b7f 100644 --- a/test_package/docs/index.rst +++ b/test_package/docs/index.rst @@ -50,6 +50,49 @@ It's good to have your upstream remote have a scary name [#]_, to remind you tha .. [#] Text of the first footnote. +Colors +------ + +Copied from the pydata-sphinx theme docs, here's the colours used. +These colors change between the dark and light themes. + +.. raw:: html + + +

+ primary + secondary + accent + success + info + warning + danger + background + on-background + surface + on-surface + target + link + code + inline code +

+ Testing ------- @@ -80,3 +123,20 @@ Normal Sometimes you need a URL: `bbc.com `__ Contributing to ``sunraster`` + +Admonitions +----------- + +.. admonition:: Generic Admonition + + You can make up your own admonition too. + +.. attention:: attention +.. caution:: caution +.. danger:: danger +.. error:: error +.. hint:: hint +.. important:: important +.. note:: note +.. tip:: tip +.. warning:: warning From 769e7424246ac33c64c644e2087c570169096b51 Mon Sep 17 00:00:00 2001 From: Stuart Mumford Date: Mon, 18 Sep 2023 11:01:59 +0100 Subject: [PATCH 05/13] More work towards a sunpy colour scheme --- .../theme/sunpy/static/sunpy_style.css | 41 ++++++++++++++++--- test_package/docs/index.rst | 12 ++++-- 2 files changed, 44 insertions(+), 9 deletions(-) diff --git a/src/sunpy_sphinx_theme/theme/sunpy/static/sunpy_style.css b/src/sunpy_sphinx_theme/theme/sunpy/static/sunpy_style.css index 41f8e5b2..abdc37cb 100644 --- a/src/sunpy_sphinx_theme/theme/sunpy/static/sunpy_style.css +++ b/src/sunpy_sphinx_theme/theme/sunpy/static/sunpy_style.css @@ -8,7 +8,7 @@ /* SunPy Variables */ - /* SunPy Logo Colors */ + /* SunPy Colors */ /* These should not be directly used */ --sst-sunpy-logo-primary-color: #fe7900; --sst-sunpy-logo-secondary-color: #fed20b; @@ -37,20 +37,51 @@ } html[data-theme="light"] { + /* A lot of these colors we have inherited from pst however, I have copied them all */ + /* in here to make it obvious which colors are in use, and to shield us from any */ + /* upstream changes. */ --pst-color-primary: var(--sst-darker-color); --pst-color-secondary: var(--sst-accent-color-muted); + --pst-color-accent: var(--sst-sunpy-logo-secondary-color); + --pst-color-success: rgb(0, 132, 63); + --pst-color-info: rgb(39, 107, 233); + --pst-color-warning: rgb(246, 106, 10); + --pst-color-danger: rgb(215, 45, 71); + --pst-color-background: var(--sst-lightest-color); + --pst-color-on-background: var(--sst-lightest-color); + --pst-color-surface: var(--sst-lighter-color); + --pst-color-on-surface: var(--sst-darkest-color); + --pst-color-target: rgb(243, 207, 149); --pst-color-link: var(--sst-accent-color-muted); + --pst-color-inline-code: rgb(145, 37, 131); + --pst-color-inline-code-links: rgb(8, 93, 108); + --pst-color-text-base: var(--sst-darkest-color); + --pst-color-text-muted: var(--sst-darker-color); + --sst-footer-background-color: var(--sst-lightest-color); } html[data-theme="dark"] { - /* Swap primary and secondary for dark theme */ - --pst-color-secondary: var(--sst-darker-color); + /* A lot of these colors we have inherited from pst however, I have copied them all */ + /* in here to make it obvious which colors are in use, and to shield us from any */ + /* upstream changes. */ --pst-color-primary: var(--sst-accent-color-bright); + --pst-color-secondary: var(--sst-darker-color); + --pst-color-accent: var(--sst-sunpy-logo-secondary-color); + --pst-color-success: rgb(95, 180, 136); + --pst-color-info: rgb(121, 163, 242); + --pst-color-warning: rgb(255, 146, 69); + --pst-color-danger: rgb(231, 136, 148); --pst-color-background: var(--sst-darkest-color); - /* Make the text colours slightly lighter than default as we are using a lighter background */ + --pst-color-on-background: var(--sst-darker-color); + --pst-color-surface: var(--sst-dark-color); + --pst-color-on-surface: var(--sst-lighter-color); + --pst-color-target: rgb(103, 92, 4); + --pst-color-link: var(--sst-accent-color-muted); + --pst-color-inline-code: rgb(243, 199, 238); + --pst-color-inline-code-links: rgb(63, 177, 197); --pst-color-text-base: var(--sst-lighter-color); - --pst-color-text-muted: var(--sst-lighter-color); + --pst-color-text-muted: var(--sst-light-color); --sst-header-background: var(--sst-darker-color); --sst-footer-background-color: var(--sst-darker-color); diff --git a/test_package/docs/index.rst b/test_package/docs/index.rst index 7ad23b7f..7a17c3ae 100644 --- a/test_package/docs/index.rst +++ b/test_package/docs/index.rst @@ -72,8 +72,10 @@ These colors change between the dark and light themes. span.pst-on-surface {background-color: var(--pst-color-on-surface);} span.pst-target {background-color: var(--pst-color-target);} span.pst-link {background-color: var(--pst-color-link);} - span.pst-code {background-color: var(--pst-color-code);} span.pst-inline-code {background-color: var(--pst-color-inline-code);} + span.pst-inline-code-links {background-color: var(--pst-color-inline-code-links);} + span.pst-text {background-color: var(--pst-color-text-base); color: white;} + span.pst-text-muted {background-color: var(--pst-color-text-muted);}

primary @@ -89,8 +91,10 @@ These colors change between the dark and light themes. on-surface target link - code inline code + inline code links + text base + text muted

Testing @@ -120,7 +124,7 @@ Normal Normal `numpy.ndarray.mean` -Sometimes you need a URL: `bbc.com `__ +Sometimes you need a URL: `bbc.com `__ Contributing to ``sunraster`` @@ -129,7 +133,7 @@ Admonitions .. admonition:: Generic Admonition - You can make up your own admonition too. + Generic admnition needs content apparently .. attention:: attention .. caution:: caution From 38c646a7a95d84ae3f43aa36d458f917a74e3f67 Mon Sep 17 00:00:00 2001 From: Nabil Freij Date: Fri, 29 Dec 2023 22:25:56 -0800 Subject: [PATCH 06/13] Precommit --- .pre-commit-config.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index a23b01ce..980401bb 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -29,17 +29,17 @@ repos: args: ['--make-summary-multi-line', '--pre-summary-newline', '-ri'] - repo: https://github.com/PyCQA/isort - rev: 5.12.0 + rev: 5.13.2 hooks: - id: isort - repo: https://github.com/psf/black - rev: 23.11.0 + rev: 23.12.1 hooks: - id: black - repo: https://github.com/pre-commit/mirrors-prettier - rev: v3.1.0 + rev: v4.0.0-alpha.8 hooks: - id: prettier types_or: [css, scss, javascript] From f506500ee4384467cd976be7367378fd264fe742 Mon Sep 17 00:00:00 2001 From: Nabil Freij Date: Sat, 30 Dec 2023 12:34:22 -0800 Subject: [PATCH 07/13] rando --- rebuild_all_rtd.py | 24 ++++++------ src/sunpy_sphinx_theme/__init__.py | 10 ++--- test_package/docs/conf.py | 3 +- test_package/test_package/timerange.py | 53 ++++++++++++++++---------- 4 files changed, 49 insertions(+), 41 deletions(-) diff --git a/rebuild_all_rtd.py b/rebuild_all_rtd.py index 0caf2614..7c3142d5 100644 --- a/rebuild_all_rtd.py +++ b/rebuild_all_rtd.py @@ -2,18 +2,23 @@ Run all builds for all active versions of all SunPy and SunPy subprojects on RTD. """ + import os import requests BASE_PROJECT = "sunpy" -BASE_URL = f"https://readthedocs.org/api/v3/projects/" +BASE_URL = "https://readthedocs.org/api/v3/projects/" TOKEN = os.environ["RTD_AUTH_TOKEN"] headers = {"Authorization": f"Token {TOKEN}"} def get_active_versions(project): - r = requests.get(BASE_URL + f"{project}/versions", headers=headers, params={"active": True}) + r = requests.get( + f"{BASE_URL}{project}/versions", + headers=headers, + params={"active": True}, + ) if not r.ok: print(f"Failed to get versions for {project}: {r}") return [] @@ -23,27 +28,20 @@ def get_active_versions(project): print(r) return [] results = r["results"] - slugs = [] - for res in results: - slugs.append(res["slug"]) - - return slugs + return [res["slug"] for res in results] def get_all_subprojects(base_project): - r = requests.get(BASE_URL + f"{base_project}/subprojects", headers=headers) + r = requests.get(f"{BASE_URL}{base_project}/subprojects", headers=headers) r = r.json() results = r["results"] - projects = [] - for res in results: - projects.append(res["child"]["slug"]) - return projects + return [res["child"]["slug"] for res in results] def rebuild_all_versions_for_project(project): slugs = get_active_versions(project) for slug in slugs: - r = requests.post(BASE_URL + f"{project}/versions/{slug}/builds/", headers=headers) + r = requests.post(f"{BASE_URL}{project}/versions/{slug}/builds/", headers=headers) if r.status_code != 202: print(f"{slug} failed to build with: {r}") diff --git a/src/sunpy_sphinx_theme/__init__.py b/src/sunpy_sphinx_theme/__init__.py index 3c3ace38..b160488c 100644 --- a/src/sunpy_sphinx_theme/__init__.py +++ b/src/sunpy_sphinx_theme/__init__.py @@ -17,8 +17,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(): @@ -69,10 +68,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)) diff --git a/test_package/docs/conf.py b/test_package/docs/conf.py index f774329f..6aab135e 100644 --- a/test_package/docs/conf.py +++ b/test_package/docs/conf.py @@ -1,12 +1,13 @@ """ Configuration file for the Sphinx documentation builder. """ + import os import datetime project = "Test Package" author = "The Test Package Community" -copyright = "{}, {}".format(datetime.datetime.now().year, author) +copyright = f"{datetime.datetime.now().year}, {author}" extensions = [ "matplotlib.sphinxext.plot_directive", "sphinx_automodapi.automodapi", diff --git a/test_package/test_package/timerange.py b/test_package/test_package/timerange.py index f67f29d6..e1e939ef 100644 --- a/test_package/test_package/timerange.py +++ b/test_package/test_package/timerange.py @@ -247,27 +247,40 @@ def __repr__(self): fully_qualified_name = f"{self.__class__.__module__}.{self.__class__.__name__}" return ( - " <{} object at {}>".format(fully_qualified_name, hex(id(self))) - + "\n Start:".ljust(12) - + t1 - + "\n End:".ljust(12) - + t2 - + "\n Center:".ljust(12) - + center - + "\n Duration:".ljust(12) - + str(self.days.value) - + " days or" - + "\n ".ljust(12) - + str(self.hours.value) - + " hours or" - + "\n ".ljust(12) - + str(self.minutes.value) - + " minutes or" + ( + ( + ( + ( + ( + ( + ( + f" <{fully_qualified_name} object at {hex(id(self))}>" + + "\n Start:".ljust(12) + ) + + t1 + ) + + "\n End:".ljust(12) + + t2 + ) + + "\n Center:".ljust(12) + + center + ) + + "\n Duration:".ljust(12) + + str(self.days.value) + + " days or" + ) + + "\n ".ljust(12) + + str(self.hours.value) + + " hours or" + ) + + "\n ".ljust(12) + + str(self.minutes.value) + + " minutes or" + ) + "\n ".ljust(12) + str(self.seconds.value) + " seconds" - + "\n" - ) + ) + "\n" def split(self, n=2): """ @@ -402,11 +415,9 @@ def get_dates(self): """ Return all partial days contained within the time range. """ - dates = [] - dates = [ + return [ parse_time(self.start.strftime("%Y-%m-%d")) + TimeDelta(i * u.day) for i in range(int(self.days.value) + 1) ] - return dates @add_common_docstring(**_variables_for_parse_time_docstring()) def __contains__(self, time): From 1947d5e83db7c22c368bcf62ce17acd1803b599c Mon Sep 17 00:00:00 2001 From: Nabil Freij Date: Sat, 30 Dec 2023 13:20:00 -0800 Subject: [PATCH 08/13] More tweaks to colors --- .../theme/sunpy/static/sunpy_style.css | 66 +++++++++++++++---- 1 file changed, 52 insertions(+), 14 deletions(-) diff --git a/src/sunpy_sphinx_theme/theme/sunpy/static/sunpy_style.css b/src/sunpy_sphinx_theme/theme/sunpy/static/sunpy_style.css index abdc37cb..dd1084ac 100644 --- a/src/sunpy_sphinx_theme/theme/sunpy/static/sunpy_style.css +++ b/src/sunpy_sphinx_theme/theme/sunpy/static/sunpy_style.css @@ -22,17 +22,17 @@ --sst-dark-color: var(--sst-sunpy-logo-gray); --sst-darker-color: #333333; --sst-darkest-color: #222222; - --sst-lightest-color: rgb(251, 251, 251); - --sst-lighter-color: rgb(231, 231, 231); + --sst-lightest-color: rgb(255, 255, 255); + --sst-lighter-color: rgb(245, 245, 245); --sst-light-color: rgb(206, 206, 206); - /* Component Colours */ + /* Component Colors */ /* If you add or change the names of these please update the docs */ --sst-header-background: var(--sst-dark-color); --sst-header-text: var(--sst-lighter-color); --sst-sidebar-background-color: var(--pst-color-background); - /* sphinx-design themeing */ + /* sphinx-design theming */ --sd-color-card-border-hover: var(--sst-accent-color-bright); } @@ -45,7 +45,8 @@ html[data-theme="light"] { --pst-color-accent: var(--sst-sunpy-logo-secondary-color); --pst-color-success: rgb(0, 132, 63); --pst-color-info: rgb(39, 107, 233); - --pst-color-warning: rgb(246, 106, 10); + --pst-color-warning: rgb(238, 144, 64); + --pst-color-warning-text: rgb(255, 255, 255); --pst-color-danger: rgb(215, 45, 71); --pst-color-background: var(--sst-lightest-color); --pst-color-on-background: var(--sst-lightest-color); @@ -54,7 +55,7 @@ html[data-theme="light"] { --pst-color-target: rgb(243, 207, 149); --pst-color-link: var(--sst-accent-color-muted); --pst-color-inline-code: rgb(145, 37, 131); - --pst-color-inline-code-links: rgb(8, 93, 108); + --pst-color-inline-code-links: rgb(238, 144, 64); --pst-color-text-base: var(--sst-darkest-color); --pst-color-text-muted: var(--sst-darker-color); @@ -77,16 +78,17 @@ html[data-theme="dark"] { --pst-color-surface: var(--sst-dark-color); --pst-color-on-surface: var(--sst-lighter-color); --pst-color-target: rgb(103, 92, 4); - --pst-color-link: var(--sst-accent-color-muted); + --pst-color-link: var(--sst-accent-color-bright); --pst-color-inline-code: rgb(243, 199, 238); - --pst-color-inline-code-links: rgb(63, 177, 197); - --pst-color-text-base: var(--sst-lighter-color); - --pst-color-text-muted: var(--sst-light-color); + --pst-color-inline-code-links: rgb(238, 144, 64); + --pst-color-text-base: var(--sst-lightest-color); + --pst-color-text-muted: var(--sst-lighter-color); --sst-header-background: var(--sst-darker-color); --sst-footer-background-color: var(--sst-darker-color); --sg-thumb-box-shadow-color: var(--sst-dark-color); --sd-color-secondary: var(--pst-color-primary); + --sd-color-card-border: var(var(--sst-lightest-color)); } /* sphinx-gallery themeing */ @@ -135,6 +137,27 @@ html[data-theme="dark"] div.graphviz > object.inheritance { filter: invert(0.9); } +/* The sidebar text is light gray, so we make it white here */ +html[data-theme="dark"] nav.bd-links li > a { + color: rgb(255, 255, 255); +} + +/* The sphinx design card border in dark mode is blue */ +html[data-theme="dark"] .sd-card { + border-top-color: var(--pst-color-text-base); + border-left-color: var(--pst-color-text-base); + border-right-color: var(--pst-color-text-base); + border-bottom-color: var(--pst-color-text-base); +} + +html[data-theme="dark"] .sd-card .sd-card-header { + border-bottom-color: var(--pst-color-text-base); +} + +html[data-theme="dark"] .sidebar-secondary-item { + border-left-color: var(--pst-color-text-base); +} + /* Top Nav */ nav.bd-header { background-color: var(--sst-header-background) !important; @@ -201,6 +224,7 @@ html[data-theme="light"] .bd-sidebar-primary .theme-switch-button span { border-color: var(--sst-accent-color-bright); } +/* Required to center the items in the bottom bar */ .bd-header .navbar-header-items__start { width: auto; } @@ -258,6 +282,24 @@ img.logo__image { border-top: none; } +/* Override the default start and end from pst here so we make it the same as our new center */ +.bd-footer .footer-items__end, +.bd-footer .footer-items__start, +.bd-footer .footer-items__center { + display: flex; + flex-direction: column; + justify-content: center; + flex-grow: 1; +} + +.bd-footer .footer-items__center { + text-align: center; +} + +.bd-footer .footer-items__end { + margin-left: 0; +} + .bd-footer a { color: var(--pst-color-link); } @@ -267,10 +309,6 @@ img.logo__image { padding: 0 10px; } -.bd-footer .footer-items__center { - text-align: left; -} - /* This width is hard coded, ideally it should be when then content gets wider than */ /* the viewport, I just don't know how to do that. */ @media only screen and (max-width: 800px) { From cb72410a915686c940ea662b35eab38393b5206a Mon Sep 17 00:00:00 2001 From: Nabil Freij Date: Sun, 31 Dec 2023 11:19:46 -0800 Subject: [PATCH 09/13] Copied from pydata --- rebuild_all_rtd.py | 6 +- test_package/docs/color.rst | 96 ++++++++++ test_package/docs/index.rst | 67 +------ test_package/docs/web-components.rst | 261 +++++++++++++++++++++++++++ 4 files changed, 361 insertions(+), 69 deletions(-) create mode 100644 test_package/docs/color.rst create mode 100644 test_package/docs/web-components.rst diff --git a/rebuild_all_rtd.py b/rebuild_all_rtd.py index 7c3142d5..f19970aa 100644 --- a/rebuild_all_rtd.py +++ b/rebuild_all_rtd.py @@ -14,11 +14,7 @@ def get_active_versions(project): - r = requests.get( - f"{BASE_URL}{project}/versions", - headers=headers, - params={"active": True}, - ) + r = requests.get(f"{BASE_URL}{project}/versions", headers=headers, params={"active": True}) if not r.ok: print(f"Failed to get versions for {project}: {r}") return [] diff --git a/test_package/docs/color.rst b/test_package/docs/color.rst new file mode 100644 index 00000000..668236f5 --- /dev/null +++ b/test_package/docs/color.rst @@ -0,0 +1,96 @@ +.. COPY FROM PYDATA THEME DOCS + +Color +***** + +This theme specifies color variables for the primary and secondary colors (``--pst-color-primary`` and ``--pst-color-secondary``, respectively). +These are meant to complement one another visually across the theme, if you modify these, choose colors that look good when paired with one another. +There are also several other color variables that control the color for admonitions, links, menu items, etc. + +Each color variable has two values, one corresponding to the "light" and one for the "dark" theme. +These are used throughout many of the theme elements to define text color, background color, etc. + +Here is an overview of the colors available in the theme (change theme mode to switch from light to dark versions). + +.. raw:: html + + + +

+ primary + secondary + accent + success + info + warning + danger + background + on-background + surface + on-surface + target +

+ + +**To modify the colors for these variables** for light and dark themes, :ref:`add a custom CSS stylesheet ` with a structure like so: + +.. code-block:: css + + html[data-theme="light"] { + --pst-color-primary: black; + } + + html[data-theme="dark"] { + --pst-color-primary: white; + } + +This theme uses shadows to convey depth in the light theme mode and opacity in the dark one. +It defines 4 color variables that help build overlays in your documentation. + +- :code:`background`: color of the back-most surface of the documentation +- :code:`on-background` elements that are set on top of this background (e.g. the header navbar on dark mode). +- :code:`surface` elements set on the background with a light-grey color in the light theme mode. This color has been kept in the dark theme (e.g. code-block directives). +- :code:`on-surface` elements that are on top of :code:`surface` elements (e.g. sidebar directives). + +The following image should help you understand these overlays: + +.. raw:: html + + + +
+
+

background

+
+
+

on-background

+
+
+

surface

+
+
+

on-surface

+
+
diff --git a/test_package/docs/index.rst b/test_package/docs/index.rst index 7a17c3ae..a7c259cf 100644 --- a/test_package/docs/index.rst +++ b/test_package/docs/index.rst @@ -29,6 +29,8 @@ Documentation :any:`index ` and :any:`Module ` index. .. toctree:: :maxdepth: 3 + color + web-components subsections subsections_toc @@ -40,7 +42,7 @@ Some code: Parameters ---------- x : `type` - Description of parameter x. + Description of parameter x. """ It's good to have your upstream remote have a scary name [#]_, to remind you that it's a read-write remote:: @@ -50,52 +52,6 @@ It's good to have your upstream remote have a scary name [#]_, to remind you tha .. [#] Text of the first footnote. -Colors ------- - -Copied from the pydata-sphinx theme docs, here's the colours used. -These colors change between the dark and light themes. - -.. raw:: html - - -

- primary - secondary - accent - success - info - warning - danger - background - on-background - surface - on-surface - target - link - inline code - inline code links - text base - text muted -

Testing ------- @@ -127,20 +83,3 @@ Normal Sometimes you need a URL: `bbc.com `__ Contributing to ``sunraster`` - -Admonitions ------------ - -.. admonition:: Generic Admonition - - Generic admnition needs content apparently - -.. attention:: attention -.. caution:: caution -.. danger:: danger -.. error:: error -.. hint:: hint -.. important:: important -.. note:: note -.. tip:: tip -.. warning:: warning diff --git a/test_package/docs/web-components.rst b/test_package/docs/web-components.rst new file mode 100644 index 00000000..bd8e3ef4 --- /dev/null +++ b/test_package/docs/web-components.rst @@ -0,0 +1,261 @@ +.. INSPIRED FROM sphinx-design documentation +.. COPY FROM PYDATA THEME DOCS + +======================== +Sphinx Design Components +======================== + +The PyData Sphinx Theme uses `sphinx-design `__ +to add several UI components and provide extra flexibility for content creation. +These include badges, buttons, cards, and tabs, among other components. +This theme provides custom CSS to ensure that `sphinx-design `__ elements look and feel consistent with this theme. + +.. seealso:: + + For more information about how to use these extensions, see `the sphinx-design documentation `_. + +Below you can find some examples of the components created with the :code:`sphinx-design` extension. + +.. _badges-buttons: + +Badges and button-links +======================= + +Here are some of the available badges: + +:bdg-primary:`primary` +:bdg-secondary:`secondary` +:bdg-success:`success` +:bdg-primary-line:`primary outline` +:bdg-secondary-line:`secondary outline` +:bdg-success-line:`success outline` + +Here are some of the available button-style links, also using semantic colors: + +.. grid:: auto + + .. grid-item:: + + .. button-ref:: badges-buttons + :ref-type: ref + :color: info + :shadow: + + Info + + .. grid-item:: + + .. button-ref:: badges-buttons + :ref-type: ref + :color: success + :shadow: + + Success + + .. grid-item:: + + .. button-ref:: badges-buttons + :ref-type: ref + :color: warning + :shadow: + + Warning + + .. grid-item:: + + .. button-ref:: badges-buttons + :ref-type: ref + :color: danger + :shadow: + + Danger + + .. grid-item:: + + .. button-ref:: badges-buttons + :ref-type: ref + :color: muted + :shadow: + + Muted + + .. grid-item:: + + .. button-ref:: badges-buttons + :ref-type: ref + :color: light + :shadow: + + Light + + .. grid-item:: + + .. button-ref:: badges-buttons + :ref-type: ref + :color: dark + :shadow: + + Dark + +.. note:: + + `Sphinx Design buttons + `__ + are actually links, meaning they are rendered in HTML with ```` tags + instead of ``