Skip to content

Commit 76f4764

Browse files
committed
refactor: Make source admonitions more subtle
Issue-mkdocstrings#525: mkdocstrings/mkdocstrings#525
1 parent 7f95686 commit 76f4764

File tree

3 files changed

+26
-3
lines changed

3 files changed

+26
-3
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ Context:
192192
{% if config.merge_init_into_class %}
193193
{% if "__init__" in all_members and all_members["__init__"].source %}
194194
{% with init = all_members["__init__"] %}
195-
<details class="quote">
195+
<details class="mkdocstrings-source">
196196
<summary>Source code in <code>
197197
{%- if init.relative_filepath.is_absolute() -%}
198198
{{ init.relative_package_filepath }}
@@ -205,7 +205,7 @@ Context:
205205
{% endwith %}
206206
{% endif %}
207207
{% elif class.source %}
208-
<details class="quote">
208+
<details class="mkdocstrings-source">
209209
<summary>Source code in <code>
210210
{%- if class.relative_filepath.is_absolute() -%}
211211
{{ 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
@@ -145,7 +145,7 @@ Context:
145145
This block renders the source code for the function.
146146
-#}
147147
{% if config.show_source and function.source %}
148-
<details class="quote">
148+
<details class="mkdocstrings-source">
149149
<summary>{{ lang.t("Source code in") }} <code>
150150
{%- if function.relative_filepath.is_absolute() -%}
151151
{{ function.relative_package_filepath }}

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

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,3 +178,26 @@ code.doc-symbol-module::after {
178178
color: inherit;
179179
border-bottom: 1px dotted currentcolor;
180180
}
181+
182+
/* Source code blocks (admonitions). */
183+
:root {
184+
--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>')
185+
}
186+
.md-typeset .admonition.mkdocstrings-source,
187+
.md-typeset details.mkdocstrings-source {
188+
border: none;
189+
padding: 0;
190+
}
191+
.md-typeset .admonition.mkdocstrings-source:focus-within,
192+
.md-typeset details.mkdocstrings-source:focus-within {
193+
box-shadow: none;
194+
}
195+
.md-typeset .mkdocstrings-source > .admonition-title,
196+
.md-typeset .mkdocstrings-source > summary {
197+
background-color: inherit;
198+
}
199+
.md-typeset .mkdocstrings-source > .admonition-title::before,
200+
.md-typeset .mkdocstrings-source > summary::before {
201+
-webkit-mask-image: var(--md-admonition-icon--mkdocstrings-source);
202+
mask-image: var(--md-admonition-icon--mkdocstrings-source);
203+
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy