Skip to content

Commit 2041d5f

Browse files
authored
Merge pull request #58 from jklymak/enh-default-logo-loc
ENH: default logo loc
2 parents 5d2b419 + 1fcf6a8 commit 2041d5f

File tree

6 files changed

+32
-7
lines changed

6 files changed

+32
-7
lines changed

docs/conf.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,11 @@
4444
html_theme = "mpl_sphinx_theme"
4545
html_favicon = "_static/favicon.ico"
4646
html_theme_options = {
47-
"logo": {"link": "https://matplotlib.org/stable/",
48-
"image_light": "images/logo2.svg",
49-
"image_dark": "images/logo_dark.svg"},
47+
# logo is installed by mpl-sphinx-theme as:
48+
# "logo": {"link": "https://matplotlib.org/stable/",
49+
# "image_light": "_static/logo2.svg",
50+
# "image_dark": "_static/logo_dark.svg"},
51+
# if this default is OK, then no need to modify "logo"
5052
# collapse_navigation in pydata-sphinx-theme is slow, so skipped for local
5153
# and CI builds https://github.com/pydata/pydata-sphinx-theme/pull/386
5254
"collapse_navigation": not is_release_build,
@@ -62,4 +64,4 @@
6264
# Add any paths that contain custom static files (such as style sheets) here,
6365
# relative to this directory. They are copied after the builtin static files,
6466
# so a file named "default.css" will overwrite the builtin "default.css".
65-
# html_static_path = ["static"]
67+
# html_static_path = ["_static"]

docs/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
pydata-sphinx-theme>=0.10.0
1+
pydata-sphinx-theme>=0.13.1
22
matplotlib

mpl_sphinx_theme/__init__.py

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,29 @@
33
from pathlib import Path
44

55

6+
def set_config_defaults(app):
7+
8+
try:
9+
theme = app.builder.theme_options
10+
except AttributeError:
11+
theme = None
12+
if not theme:
13+
theme = {}
14+
15+
# Default logo
16+
logo = theme.get("logo", {})
17+
if "image_dark" not in logo:
18+
logo["image_dark"] = "_static/logo_dark.svg"
19+
if "image_light" not in logo:
20+
logo["image_light"] = "_static/logo2.svg"
21+
if "link" not in logo:
22+
logo["link"] = "https://matplotlib.org/stable/"
23+
theme["logo"] = logo
24+
25+
# Update the HTML theme config
26+
app.builder.theme_options = theme
27+
28+
629
def get_html_theme_path():
730
"""Return list of HTML theme paths."""
831
return [str(Path(__file__).parent.parent.resolve())]
@@ -34,7 +57,7 @@ def setup(app):
3457
here = Path(__file__).parent.resolve()
3558
# Include component templates
3659
app.config.templates_path.append(str(here / "components"))
37-
3860
app.add_html_theme("mpl_sphinx_theme", str(here))
61+
app.connect("builder-inited", set_config_defaults)
3962
app.connect("html-page-context", setup_html_page_context)
4063
return {'version': __version__, 'parallel_read_safe': True}

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
pydata-sphinx-theme>=0.11.0
1+
pydata-sphinx-theme>=0.13.1
22
matplotlib

0 commit comments

Comments
 (0)