Skip to content

Commit fdaeb48

Browse files
committed
feat: Release visually-lighter admonitions for source code blocks
1 parent 669b42e commit fdaeb48

File tree

5 files changed

+40
-5
lines changed

5 files changed

+40
-5
lines changed

docs/insiders/changelog.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,11 @@
22

33
## mkdocstrings-python Insiders
44

5-
### 1.12.0 <small>March 22, 2025</small> { id="1.12.0" }
5+
### 1.12.1 <small>May 24, 2025</small> { id="1.12.1" }
6+
7+
- Visually-lighter admonitions for source code blocks
8+
9+
### 1.12.0 <small>March 24, 2025</small> { id="1.12.0" }
610

711
- [Ordering method: `__all__`][option-members_order]
812

@@ -14,6 +18,11 @@
1418

1519
- [Backlinks][backlinks]
1620

21+
### 1.9.1 <small>December 26, 2024</small> { id="1.9.1" }
22+
23+
- Re-add class template for RTD theme
24+
- Make inheritance diagrams rendering more robust
25+
1726
### 1.9.0 <small>September 03, 2024</small> { id="1.9.0" }
1827

1928
- [Relative cross-references][relative_crossrefs]

docs/insiders/goals.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,4 +50,6 @@ goals:
5050
since: 2025/03/20
5151
- name: "Ordering method: `__all__`"
5252
ref: /usage/configuration/members/#option-members_order
53-
since: 2025/03/22
53+
since: 2025/03/24
54+
- name: "Visually-lighter source code blocks"
55+
since: 2025/05/24

src/mkdocstrings_handlers/python/templates/material/_base/class.html.jinja

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ Context:
252252
{% if config.merge_init_into_class %}
253253
{% if "__init__" in all_members and all_members["__init__"].source %}
254254
{% with init = all_members["__init__"] %}
255-
<details class="quote">
255+
<details class="mkdocstrings-source">
256256
<summary>Source code in <code>
257257
{%- if init.relative_filepath.is_absolute() -%}
258258
{{ init.relative_package_filepath }}
@@ -265,7 +265,7 @@ Context:
265265
{% endwith %}
266266
{% endif %}
267267
{% elif class.source %}
268-
<details class="quote">
268+
<details class="mkdocstrings-source">
269269
<summary>Source code in <code>
270270
{%- if class.relative_filepath.is_absolute() -%}
271271
{{ class.relative_package_filepath }}

src/mkdocstrings_handlers/python/templates/material/_base/function.html.jinja

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ Context:
149149
This block renders the source code for the function.
150150
-#}
151151
{% if config.show_source and function.source %}
152-
<details class="quote">
152+
<details class="mkdocstrings-source">
153153
<summary>{{ lang.t("Source code in") }} <code>
154154
{%- if function.relative_filepath.is_absolute() -%}
155155
{{ function.relative_package_filepath }}

src/mkdocstrings_handlers/python/templates/material/style.css

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,3 +210,27 @@ code.doc-symbol-module::after {
210210
color: inherit;
211211
border-bottom: 1px dotted currentcolor;
212212
}
213+
214+
/* Source code blocks (admonitions). */
215+
:root {
216+
--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>')
217+
}
218+
.md-typeset .admonition.mkdocstrings-source,
219+
.md-typeset details.mkdocstrings-source {
220+
border: none;
221+
padding: 0;
222+
}
223+
.md-typeset .admonition.mkdocstrings-source:focus-within,
224+
.md-typeset details.mkdocstrings-source:focus-within {
225+
box-shadow: none;
226+
}
227+
.md-typeset .mkdocstrings-source > .admonition-title,
228+
.md-typeset .mkdocstrings-source > summary {
229+
background-color: inherit;
230+
}
231+
.md-typeset .mkdocstrings-source > .admonition-title::before,
232+
.md-typeset .mkdocstrings-source > summary::before {
233+
background-color: var(--md-default-fg-color);
234+
-webkit-mask-image: var(--md-admonition-icon--mkdocstrings-source);
235+
mask-image: var(--md-admonition-icon--mkdocstrings-source);
236+
}

0 commit comments

Comments
 (0)