Skip to content

Commit 6a114f9

Browse files
committed
apply css to the svg to support dark theme
1 parent f3863c4 commit 6a114f9

File tree

4 files changed

+94
-39
lines changed

4 files changed

+94
-39
lines changed

Doc/c-api/lifecycle.dot

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1-
digraph G {
1+
digraph "Life Events" {
22
graph [
33
fontname="svg"
44
fontsize=10.0
5+
id="life_events_graph"
56
layout="dot"
67
ranksep=0.25
8+
stylesheet="lifecycle.dot.css"
79
]
810
node [
911
fontname="Courier"

Doc/c-api/lifecycle.dot.css

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#life_events_graph {
2+
/*
3+
* Unfortunately these colors don't seem to be exposed in any of the theme's
4+
* variables, so they are manually copied here.
5+
*/
6+
--svg-light-fgcolor: black;
7+
--svg-light-bgcolor: white;
8+
--svg-dark-fgcolor: rgba(255, 255, 255, 0.87);
9+
--svg-dark-bgcolor: #222;
10+
--svg-fgcolor: var(--svg-light-fgcolor);
11+
--svg-bgcolor: var(--svg-light-bgcolor);
12+
}
13+
@media (prefers-color-scheme: dark) {
14+
#life_events_graph {
15+
--svg-fgcolor: var(--svg-dark-fgcolor);
16+
--svg-bgcolor: var(--svg-dark-bgcolor);
17+
}
18+
}
19+
@media (prefers-color-scheme: light) {
20+
#life_events_graph {
21+
--svg-fgcolor: var(--svg-light-fgcolor);
22+
--svg-bgcolor: var(--svg-light-bgcolor);
23+
}
24+
}
25+
:root:has(#pydoctheme_dark_css[media="not all"]) #life_events_graph {
26+
--svg-fgcolor: var(--svg-light-fgcolor);
27+
--svg-bgcolor: var(--svg-light-bgcolor);
28+
}
29+
:root:has(#pydoctheme_dark_css[media="all"]) #life_events_graph {
30+
--svg-fgcolor: var(--svg-dark-fgcolor);
31+
--svg-bgcolor: var(--svg-dark-bgcolor);
32+
}
33+
#life_events_graph [stroke="black"] {
34+
stroke: var(--svg-fgcolor);
35+
}
36+
#life_events_graph :is(text, [fill="black"]) {
37+
fill: var(--svg-fgcolor);
38+
}
39+
#life_events_graph :is([fill="white"]) {
40+
fill: var(--svg-bgcolor);
41+
}

Doc/c-api/lifecycle.dot.svg

Lines changed: 39 additions & 38 deletions
Loading

Doc/c-api/lifecycle.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,17 @@ object's life [1]_. An arrow from *A* to *B* indicates that event *B* can
1313
occur after event *A* has occurred, with the arrow's label indicating the
1414
condition that must be true for *B* to occur after *A*.
1515

16+
.. raw:: html
17+
18+
<style type="text/css">
19+
20+
.. raw:: html
21+
:file: lifecycle.dot.css
22+
23+
.. raw:: html
24+
25+
</style>
26+
1627
.. raw:: html
1728
:file: lifecycle.dot.svg
1829

0 commit comments

Comments
 (0)