Skip to content

Commit 2764cd2

Browse files
authored
📚 DOCS: Improve CSS (#688)
1 parent 9d1869d commit 2764cd2

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

docs/_static/local.css

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,9 @@ span.label {
5050
/* pyscript changes this and it messes up footnote labels */
5151
all: unset;
5252
}
53+
54+
.tippy-box {
55+
background-color:var(--pst-color-surface);
56+
color:var(--pst-color-text-base);
57+
border: 1px solid var(--pst-color-border);
58+
}

docs/conf.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@
134134
# relative to this directory. They are copied after the builtin static files,
135135
# so a file named "default.css" will overwrite the builtin "default.css".
136136
html_static_path = ["_static"]
137+
html_css_files = ["local.css"]
137138

138139
rediraffe_redirects = {
139140
"using/intro.md": "sphinx/intro.md",
@@ -190,9 +191,18 @@ def setup(app: Sphinx):
190191
MystWarningsDirective,
191192
)
192193

193-
app.add_css_file("local.css")
194194
app.add_directive("myst-config", MystConfigDirective)
195195
app.add_directive("docutils-cli-help", DocutilsCliHelpDirective)
196196
app.add_directive("doc-directive", DirectiveDoc)
197197
app.add_directive("myst-warnings", MystWarningsDirective)
198198
app.add_post_transform(StripUnsupportedLatex)
199+
app.connect("html-page-context", add_version_to_css)
200+
201+
202+
def add_version_to_css(app, pagename, templatename, context, doctree):
203+
"""Add the version number to the local.css file, to bust the cache for changes."""
204+
if app.builder.name != "html":
205+
return
206+
if "_static/local.css" in context.get("css_files", {}):
207+
index = context["css_files"].index("_static/local.css")
208+
context["css_files"][index] = f"_static/local.css?v={__version__}"

0 commit comments

Comments
 (0)