Skip to content

Commit 55440fd

Browse files
committed
doc: switch to sphinx-book theme
1 parent 37a617e commit 55440fd

5 files changed

Lines changed: 72 additions & 27 deletions

File tree

ci/environment.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,5 @@ dependencies:
1111
- pys2index
1212
- pytest
1313
- pytest-cov
14+
- pydata-sphinx-theme=0.15.4
15+
- sphinx-book-theme=1.1.4

doc/_static/style.css

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
2+
code.literal {
3+
background-color: unset;
4+
border: unset;
5+
}
6+
7+
.xr-wrap {
8+
/* workaround when (ipy)widgets are present in output cells
9+
* https://github.com/xarray-contrib/xarray-indexes/issues/14
10+
* only rely on pydata-sphinx-theme variables here!
11+
*/
12+
--xr-font-color0: var(--pst-color-text-base);
13+
--xr-font-color2: var(--pst-color-text-base);
14+
--xr-font-color3: var(--pst-color-text-base);
15+
--xr-border-color: hsl(from var(--pst-color-text-base) h s calc(l + 40));
16+
--xr-disabled-color: hsl(from var(--pst-color-text-base) h s calc(l + 40));
17+
--xr-background-color: var(--pst-color-on-background);
18+
--xr-background-color-row-even: hsl(
19+
from var(--pst-color-on-background) h s calc(l - 5)
20+
);
21+
--xr-background-color-row-odd: hsl(
22+
from var(--pst-color-on-background) h s calc(l - 15)
23+
);
24+
25+
font-size: 0.9em;
26+
margin-left: 1.25em;
27+
}
28+
29+
html[data-theme="dark"] .xr-wrap {
30+
--xr-border-color: hsl(from var(--pst-color-text-base) h s calc(l - 40));
31+
--xr-disabled-color: hsl(from var(--pst-color-text-base) h s calc(l - 40));
32+
--xr-background-color-row-even: hsl(
33+
from var(--pst-color-on-background) h s calc(l + 5)
34+
);
35+
--xr-background-color-row-odd: hsl(
36+
from var(--pst-color-on-background) h s calc(l + 15)
37+
);
38+
}
39+
40+
.xr-array-wrap,
41+
.xr-var-data,
42+
.xr-var-preview {
43+
/* font-size: 0.9em; */
44+
}
45+
.gp {
46+
color: darkorange;
47+
}
48+
49+
/* workaround Pydata Sphinx theme using light colors for widget cell outputs in dark-mode */
50+
/* works for many widgets but not for Xarray html reprs */
51+
/* https://github.com/pydata/pydata-sphinx-theme/issues/2189 */
52+
html[data-theme="dark"] .output_area.rendered_html:has(div.xr-wrap) {
53+
background-color: var(--pst-color-on-background) !important;
54+
color: var(--pst-color-text-base) !important;
55+
}

doc/conf.py

Lines changed: 13 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -66,17 +66,18 @@
6666
# The theme to use for HTML and HTML Help pages. See the documentation for
6767
# a list of builtin themes.
6868
#
69-
html_theme = "sphinx_rtd_theme"
70-
71-
# Theme options are theme-specific and customize the look and feel of a theme
72-
# further. For a list of options available for each theme, see the
73-
# documentation.
74-
# html_theme_options = {
75-
# "github_url": "https://github.com/xarray-contrib/xoak",
76-
# "use_edit_page_button": True,
77-
# "search_bar_position": "navbar",
78-
# }
79-
69+
html_theme = "sphinx_book_theme"
70+
html_title = "Xoak"
71+
72+
html_theme_options = dict(
73+
repository_url="https://github.com/xarray-contrib/xoak",
74+
repository_branch="master",
75+
path_to_docs="doc",
76+
use_edit_page_button=True,
77+
use_repository_button=True,
78+
use_issues_button=True,
79+
home_page_in_toc=False,
80+
)
8081

8182
html_context = {
8283
"github_user": "xarray-contrib",
@@ -85,22 +86,11 @@
8586
"doc_path": "doc",
8687
}
8788

88-
# Add any paths that contain custom static files (such as style sheets) here,
89-
# relative to this directory. They are copied after the builtin static files,
90-
# so a file named "default.css" will overwrite the builtin "default.css".
9189
html_static_path = ["_static"]
90+
html_css_files = ["style.css"]
9291

93-
94-
# Enable notebook execution
95-
# https://nbsphinx.readthedocs.io/en/0.4.2/never-execute.html
96-
# nbsphinx_execute = 'auto'
97-
# Allow errors in all notebooks by
98-
# nbsphinx_allow_errors = True
9992
nbsphinx_kernel_name = "python3"
100-
101-
# Disable cell timeout
10293
nbsphinx_timeout = -1
103-
10494
nbsphinx_prolog = """
10595
{% set docname = env.doc2path(env.docname, base=None) %}
10696

doc/examples/dask_support.ipynb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@
2222
"import numpy as np\n",
2323
"import xarray as xr\n",
2424
"import xoak\n",
25-
"\n",
26-
"xr.set_options(display_style='text');"
25+
"\n"
2726
]
2827
},
2928
{

doc/examples/introduction.ipynb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@
1818
"import numpy as np\n",
1919
"import xarray as xr\n",
2020
"import xoak\n",
21-
"\n",
22-
"xr.set_options(display_style='text');"
21+
"\n"
2322
]
2423
},
2524
{

0 commit comments

Comments
 (0)