Skip to content

Commit d1b0031

Browse files
committed
Add CSS for the Python handler of mkdocstrings
Signed-off-by: pawamoy <dev@pawamoy.fr>
1 parent 4fa53d7 commit d1b0031

File tree

4 files changed

+494
-0
lines changed

4 files changed

+494
-0
lines changed

src/assets/stylesheets/classic/main.scss

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@
7878
@import "./main/extensions/markdown/footnotes";
7979
@import "./main/extensions/markdown/toc";
8080

81+
@import "./main/extensions/mkdocstrings/python";
82+
8183
@import "./main/extensions/pymdownx/arithmatex";
8284
@import "./main/extensions/pymdownx/critic";
8385
@import "./main/extensions/pymdownx/details";
Lines changed: 215 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,215 @@
1+
/* Avoid breaking parameter names, etc. in table cells. */
2+
.doc-contents td code {
3+
word-break: normal !important;
4+
}
5+
6+
/* No line break before first paragraph of descriptions. */
7+
.doc-md-description,
8+
.doc-md-description>p:first-child {
9+
display: inline;
10+
}
11+
12+
/* No text transformation for H5 headings. */
13+
.md-typeset h5 .doc-object-name {
14+
text-transform: none;
15+
}
16+
17+
/* Max width for docstring sections tables. */
18+
.doc .md-typeset__table,
19+
.doc .md-typeset__table table {
20+
display: table !important;
21+
width: 100%;
22+
}
23+
24+
.doc .md-typeset__table tr {
25+
display: table-row;
26+
}
27+
28+
/* Defaults in Spacy table style. */
29+
.doc-param-default,
30+
.doc-type_param-default {
31+
float: right;
32+
}
33+
34+
/* Parameter headings must be inline, not blocks. */
35+
.doc-heading-parameter,
36+
.doc-heading-type_parameter {
37+
display: inline;
38+
}
39+
40+
/* Default font size for parameter headings. */
41+
.md-typeset .doc-heading-parameter {
42+
font-size: inherit;
43+
}
44+
45+
/* Prefer space on the right, not the left of parameter permalinks. */
46+
.doc-heading-parameter .headerlink,
47+
.doc-heading-type_parameter .headerlink {
48+
margin-left: 0 !important;
49+
margin-right: 0.2rem;
50+
}
51+
52+
/* Backward-compatibility: docstring section titles in bold. */
53+
.doc-section-title {
54+
font-weight: bold;
55+
}
56+
57+
/* Maintain syntax highlighting on cross-references, add underline. */
58+
.doc-signature .autorefs {
59+
color: inherit;
60+
border-bottom: 1px dotted currentcolor;
61+
}
62+
63+
/* Symbols in Navigation and ToC. */
64+
:root, :host,
65+
[data-md-color-scheme="default"] {
66+
--doc-symbol-parameter-fg-color: #829bd1;
67+
--doc-symbol-type_parameter-fg-color: #829bd1;
68+
--doc-symbol-attribute-fg-color: #953800;
69+
--doc-symbol-function-fg-color: #8250df;
70+
--doc-symbol-method-fg-color: #8250df;
71+
--doc-symbol-class-fg-color: #0550ae;
72+
--doc-symbol-type_alias-fg-color: #0550ae;
73+
--doc-symbol-module-fg-color: #5cad0f;
74+
75+
--doc-symbol-parameter-bg-color: #829bd11a;
76+
--doc-symbol-type_parameter-bg-color: #829bd11a;
77+
--doc-symbol-attribute-bg-color: #9538001a;
78+
--doc-symbol-function-bg-color: #8250df1a;
79+
--doc-symbol-method-bg-color: #8250df1a;
80+
--doc-symbol-class-bg-color: #0550ae1a;
81+
--doc-symbol-type_alias-bg-color: #0550ae1a;
82+
--doc-symbol-module-bg-color: #5cad0f1a;
83+
}
84+
85+
[data-md-color-scheme="slate"] {
86+
--doc-symbol-parameter-fg-color: #829bd1;
87+
--doc-symbol-type_parameter-fg-color: #829bd1;
88+
--doc-symbol-attribute-fg-color: #ffa657;
89+
--doc-symbol-function-fg-color: #d2a8ff;
90+
--doc-symbol-method-fg-color: #d2a8ff;
91+
--doc-symbol-class-fg-color: #79c0ff;
92+
--doc-symbol-type_alias-fg-color: #79c0ff;
93+
--doc-symbol-module-fg-color: #baff79;
94+
95+
--doc-symbol-parameter-bg-color: #829bd11a;
96+
--doc-symbol-type_parameter-bg-color: #829bd11a;
97+
--doc-symbol-attribute-bg-color: #ffa6571a;
98+
--doc-symbol-function-bg-color: #d2a8ff1a;
99+
--doc-symbol-method-bg-color: #d2a8ff1a;
100+
--doc-symbol-class-bg-color: #79c0ff1a;
101+
--doc-symbol-type_alias-bg-color: #79c0ff1a;
102+
--doc-symbol-module-bg-color: #baff791a;
103+
}
104+
105+
code.doc-symbol {
106+
border-radius: .1rem;
107+
font-size: .85em;
108+
padding: 0 .3em;
109+
font-weight: bold;
110+
}
111+
112+
code.doc-symbol-parameter,
113+
a code.doc-symbol-parameter {
114+
color: var(--doc-symbol-parameter-fg-color);
115+
background-color: var(--doc-symbol-parameter-bg-color);
116+
}
117+
118+
code.doc-symbol-parameter::after {
119+
content: "param";
120+
}
121+
122+
code.doc-symbol-type_parameter,
123+
a code.doc-symbol-type_parameter {
124+
color: var(--doc-symbol-type_parameter-fg-color);
125+
background-color: var(--doc-symbol-type_parameter-bg-color);
126+
}
127+
128+
code.doc-symbol-type_parameter::after {
129+
content: "type-param";
130+
}
131+
132+
code.doc-symbol-attribute,
133+
a code.doc-symbol-attribute {
134+
color: var(--doc-symbol-attribute-fg-color);
135+
background-color: var(--doc-symbol-attribute-bg-color);
136+
}
137+
138+
code.doc-symbol-attribute::after {
139+
content: "attr";
140+
}
141+
142+
code.doc-symbol-function,
143+
a code.doc-symbol-function {
144+
color: var(--doc-symbol-function-fg-color);
145+
background-color: var(--doc-symbol-function-bg-color);
146+
}
147+
148+
code.doc-symbol-function::after {
149+
content: "func";
150+
}
151+
152+
code.doc-symbol-method,
153+
a code.doc-symbol-method {
154+
color: var(--doc-symbol-method-fg-color);
155+
background-color: var(--doc-symbol-method-bg-color);
156+
}
157+
158+
code.doc-symbol-method::after {
159+
content: "meth";
160+
}
161+
162+
code.doc-symbol-class,
163+
a code.doc-symbol-class {
164+
color: var(--doc-symbol-class-fg-color);
165+
background-color: var(--doc-symbol-class-bg-color);
166+
}
167+
168+
code.doc-symbol-class::after {
169+
content: "class";
170+
}
171+
172+
173+
code.doc-symbol-type_alias,
174+
a code.doc-symbol-type_alias {
175+
color: var(--doc-symbol-type_alias-fg-color);
176+
background-color: var(--doc-symbol-type_alias-bg-color);
177+
}
178+
179+
code.doc-symbol-type_alias::after {
180+
content: "type";
181+
}
182+
183+
code.doc-symbol-module,
184+
a code.doc-symbol-module {
185+
color: var(--doc-symbol-module-fg-color);
186+
background-color: var(--doc-symbol-module-bg-color);
187+
}
188+
189+
code.doc-symbol-module::after {
190+
content: "mod";
191+
}
192+
193+
/* Source code blocks (admonitions). */
194+
:root {
195+
--md-admonition-icon--mkdocstrings-source: url('data:image/svg+xml;charset=utf-8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M15.22 4.97a.75.75 0 0 1 1.06 0l6.5 6.5a.75.75 0 0 1 0 1.06l-6.5 6.5a.749.749 0 0 1-1.275-.326.75.75 0 0 1 .215-.734L21.19 12l-5.97-5.97a.75.75 0 0 1 0-1.06m-6.44 0a.75.75 0 0 1 0 1.06L2.81 12l5.97 5.97a.749.749 0 0 1-.326 1.275.75.75 0 0 1-.734-.215l-6.5-6.5a.75.75 0 0 1 0-1.06l6.5-6.5a.75.75 0 0 1 1.06 0"/></svg>')
196+
}
197+
.md-typeset .admonition.mkdocstrings-source,
198+
.md-typeset details.mkdocstrings-source {
199+
border: none;
200+
padding: 0;
201+
}
202+
.md-typeset .admonition.mkdocstrings-source:focus-within,
203+
.md-typeset details.mkdocstrings-source:focus-within {
204+
box-shadow: none;
205+
}
206+
.md-typeset .mkdocstrings-source > .admonition-title,
207+
.md-typeset .mkdocstrings-source > summary {
208+
background-color: inherit;
209+
}
210+
.md-typeset .mkdocstrings-source > .admonition-title::before,
211+
.md-typeset .mkdocstrings-source > summary::before {
212+
background-color: var(--md-default-fg-color);
213+
-webkit-mask-image: var(--md-admonition-icon--mkdocstrings-source);
214+
mask-image: var(--md-admonition-icon--mkdocstrings-source);
215+
}

src/assets/stylesheets/modern/main.scss

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@
7878
@import "./main/extensions/markdown/footnotes";
7979
@import "./main/extensions/markdown/toc";
8080

81+
@import "./main/extensions/mkdocstrings/python";
82+
8183
@import "./main/extensions/pymdownx/arithmatex";
8284
@import "./main/extensions/pymdownx/critic";
8385
@import "./main/extensions/pymdownx/details";

0 commit comments

Comments
 (0)