Skip to content

Commit cf780e3

Browse files
authored
📚🎨👌 Change docs theme from RTD to pydata (#324)
It is 2025 and I'm tired of getting flash banged by our docs 😅 While the RTD theme served us for a long time, they do not offer a dark theme version. Whereas the [`pydata` theme](https://pydata-sphinx-theme.readthedocs.io/en/stable/index.html) offers both light and dark themes as well as a more modern look in general. While working on this I found a bug when running the link checker so I added a workaround here and opened a [PR upstream](pydata/pydata-sphinx-theme#2097) to fix it. ### Change summary - [📚🎨 Change docs theme from RTD to pydata](a85457a) - [📚🎨🩹 Fix mermaid edge and marker (arrow head) color in darkmode](9eb459a) - [📚✨ Add interrogate badge](3650143) - [🚇🩹 Workaround to fix pydata_sphinx_theme error on linkcheck](f5b35f9)
1 parent de10ba2 commit cf780e3

File tree

7 files changed

+51
-15
lines changed

7 files changed

+51
-15
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ coverage.xml
9595
# Sphinx documentation
9696
docs/_build/
9797
docs/api/
98-
docs/_static
98+
docs/_static/pygta_config.schema.json
9999
# documents generated by Sphinx.ext.autosummary
100100
docs/source/user_documentation/api/*
101101
# doc figures

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
99
[![codecov](https://codecov.io/gh/glotaran/pyglotaran-extras/branch/main/graph/badge.svg?token=I6F412Y390)](https://codecov.io/gh/glotaran/pyglotaran-extras)
10+
[![interrogate](https://raw.githubusercontent.com/econchick/interrogate/acbfb5ad55046b3ac7549811b6d73ea8072e7568/tests/unit/fixtures/plastic/100.svg)](https://github.com/econchick/interrogate)
1011
[![Discord](https://img.shields.io/discord/883443835135475753.svg?label=&logo=discord&logoColor=ffffff&color=7389D8&labelColor=6A7EC2)](https://discord.gg/KfnEYRSTJx)
1112

1213
Supplementary package for pyglotaran with (example) plotting code for use with the pyglotaran package.

docs/_static/css/mermaid_dark.css

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/* Overwrite edge colors and arror marker color in dakr mode. in */
2+
html[data-theme="dark"] pre.mermaid {
3+
& .marker {
4+
fill: #e3e3e3 !important;
5+
stroke: #e3e3e3 !important;
6+
}
7+
& .flowchart-link {
8+
stroke: #e3e3e3 !important;
9+
}
10+
}

docs/conf.py

Lines changed: 35 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@
2424

2525
pyglotaran_extras.create_config_schema(HERE/"_static")
2626

27+
# Workaround for error caused by pydata-sphinx-theme==0.16.1 during link check
28+
# TODO: Remove workaround when fix is available
29+
(HERE / "_build/linkcheck/_static").mkdir(parents=True, exist_ok=True)
30+
2731
# -- General configuration ---------------------------------------------
2832

2933
# If your documentation needs a minimal Sphinx version, state it here.
@@ -40,7 +44,7 @@
4044
"myst_nb",
4145
'sphinxcontrib.mermaid',
4246
"sphinx_copybutton",
43-
"sphinx_rtd_theme",
47+
"pydata_sphinx_theme",
4448
]
4549

4650
myst_fence_as_directive = ["mermaid"]
@@ -97,9 +101,6 @@
97101
# This patterns also effect to html_static_path and html_extra_path
98102
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]
99103

100-
# The name of the Pygments (syntax highlighting) style to use.
101-
pygments_style = "sphinx"
102-
103104
# If true, `todo` and `todoList` produce output, else they produce nothing.
104105
todo_include_todos = False
105106

@@ -109,9 +110,34 @@
109110
# The theme to use for HTML and HTML Help pages. See the documentation for
110111
# a list of builtin themes.
111112
#
112-
html_theme = "sphinx_rtd_theme"
113+
image_gh_raw_base = "https://raw.githubusercontent.com/glotaran/pyglotaran/eb8a1ea0e4e0e499c829766a3298e79ea4975f58/docs/source/images"
114+
html_theme = "pydata_sphinx_theme"
115+
html_logo =f"{image_gh_raw_base}/pyglotaran_logo_light_theme.svg"
116+
html_favicon = f"{image_gh_raw_base}/pyglotaran_favicon_transparent.svg"
113117
html_theme_options = {
114-
"navigation_depth": 7,
118+
"pygments_dark_style": "monokai",
119+
"icon_links": [
120+
{
121+
"name": "GitHub",
122+
"url": "https://github.com/glotaran/pyglotaran-extras",
123+
"icon": "fa-brands fa-square-github",
124+
"type": "fontawesome",
125+
}
126+
],
127+
"logo": {
128+
"text": "Pyglotaran-Extras",
129+
"image_dark": f"{image_gh_raw_base}/pyglotaran_logo_dark_theme.svg",
130+
},
131+
132+
}
133+
# Hide empty sidebars
134+
# Ref.: https://github.com/pydata/pydata-sphinx-theme/issues/1662#issuecomment-1913672649
135+
html_sidebars = {
136+
'installation': [],
137+
'usage': [],
138+
'contributing': [],
139+
'changelog': [],
140+
'config/project/subproject/config_docs': [],
115141
}
116142

117143
# Theme options are theme-specific and customize the look and feel of a
@@ -124,7 +150,9 @@
124150
# relative to this directory. They are copied after the builtin static files,
125151
# so a file named "default.css" will overwrite the builtin "default.css".
126152
html_static_path = ["_static"]
127-
153+
html_css_files = [
154+
'css/mermaid_dark.css',
155+
]
128156

129157
# -- Options for HTMLHelp output ---------------------------------------
130158

docs/index.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
# Welcome to pyglotaran_extras's documentation!
1+
```{include} ../README.md
2+
3+
```
24

35
```{toctree}
46
:caption: 'Contents:'
57
:maxdepth: 2
68
7-
readme
89
installation
910
usage
1011
config/project/subproject/config_docs

docs/readme.md

Lines changed: 0 additions & 3 deletions
This file was deleted.

pyproject.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,10 @@ optional-dependencies.docs = [
5353
"myst-nb>=1.1.1", # notebook docs
5454
"myst-parser>=0.12",
5555
"numpydoc>=0.8",
56+
"pydata-sphinx-theme>=0.16.1",
5657
"sphinx>=3.2",
5758
"sphinx-copybutton>=0.3",
5859
"sphinx-last-updated-by-git>=0.3",
59-
"sphinx-rtd-theme>=1.2",
60-
"sphinxcontrib-jquery>=4.1", # Needed for the search to work Ref.: https://github.com/readthedocs/sphinx_rtd_theme/issues/1434
6160
"sphinxcontrib-mermaid>=0.9.2",
6261
]
6362
optional-dependencies.test = [

0 commit comments

Comments
 (0)