Skip to content

Add CSS for the Python handler of mkdocstrings#7

Closed
pawamoy wants to merge 2 commits into
zensical:masterfrom
pawamoy:feat/add-mkdocstrings-css
Closed

Add CSS for the Python handler of mkdocstrings#7
pawamoy wants to merge 2 commits into
zensical:masterfrom
pawamoy:feat/add-mkdocstrings-css

Conversation

@pawamoy
Copy link
Copy Markdown
Contributor

@pawamoy pawamoy commented Nov 30, 2025

No description provided.

Signed-off-by: pawamoy <dev@pawamoy.fr>
@zensical
Copy link
Copy Markdown

zensical Bot commented Nov 30, 2025

Some commits were not verified and/or signed off:


We require all commits to be verified and signed off by all contributors. By signing off, contributors affirm that they comply with the Developer Certificate of Origin (DCO), a lightweight legal attestation that they have the right to submit their code under the project's open source license (MIT).

This process helps ensure clear provenance, accountability, and legal clarity for all code contributions.

}

.md-sidebar code.doc-symbol-type_parameter::after {
content: "T";
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: Same as Type, but with different color. Not sure if we should use TP instead (makes me think of toilet paper...), and two letters would make a less round label 🤷

}

.md-sidebar code.doc-symbol-method::after {
content: "M";
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: Same as Module, but with a different color. Not sure if we should use more letters.

}

.md-sidebar code.doc-symbol-module::after {
content: "M";
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: Might use MOD to differentiate from methods, nor sure 🤷

Comment on lines +226 to +247
:root {
--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>')
}
.md-typeset .admonition.mkdocstrings-source,
.md-typeset details.mkdocstrings-source {
border: none;
padding: 0;
}
.md-typeset .admonition.mkdocstrings-source:focus-within,
.md-typeset details.mkdocstrings-source:focus-within {
box-shadow: none;
}
.md-typeset .mkdocstrings-source > .admonition-title,
.md-typeset .mkdocstrings-source > summary {
background-color: inherit;
}
.md-typeset .mkdocstrings-source > .admonition-title::before,
.md-typeset .mkdocstrings-source > summary::before {
background-color: var(--md-default-fg-color);
-webkit-mask-image: var(--md-admonition-icon--mkdocstrings-source);
mask-image: var(--md-admonition-icon--mkdocstrings-source);
}
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue: This "works" only with the classic theme and needs to be fixed in the modern one (very ugly currently). The goal is simply to make these "source code blocks" admonition visually less noisy.

Comment on lines +249 to +253
/* Indentation. */
div.doc-contents:not(.first) {
padding-left: 25px;
border-left: .05rem solid var(--md-typeset-table-color);
}
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: This isn't part of the CSS for the classic theme. I wonder if we should add it by default to the modern one. Not all users of mkdocstrings set this in their projects (maybe because they simply didn't know they could).

Comment on lines +255 to +275
/* Mark external links as such. */
a.external::after,
a.autorefs-external::after {
/* https://primer.style/octicons/arrow-up-right-24 */
mask-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M18.25 15.5a.75.75 0 00.75-.75v-9a.75.75 0 00-.75-.75h-9a.75.75 0 000 1.5h7.19L6.22 16.72a.75.75 0 101.06 1.06L17.5 7.56v7.19c0 .414.336.75.75.75z"></path></svg>');
-webkit-mask-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M18.25 15.5a.75.75 0 00.75-.75v-9a.75.75 0 00-.75-.75h-9a.75.75 0 000 1.5h7.19L6.22 16.72a.75.75 0 101.06 1.06L17.5 7.56v7.19c0 .414.336.75.75.75z"></path></svg>');
content: ' ';

display: inline-block;
vertical-align: middle;
position: relative;

height: 1em;
width: 1em;
background-color: currentColor;
}

a.external:hover::after,
a.autorefs-external:hover::after {
background-color: var(--md-accent-fg-color);
} No newline at end of file
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: This isn't part of the CSS for the classic theme. After a query on https://grep.app/ it looks like most projects did set this manually, by literally copying it from my own recommendations, so I assume it's a good idea to provide this by default.

Comment thread src/assets/stylesheets/modern/main/extensions/mkdocstrings/_python.scss Outdated
@squidfunk
Copy link
Copy Markdown
Member

Not sure why, but I accidentally pushed without signing, and now I can't manage to force-push again. I created #8 in response which includes all commits from #7.

@squidfunk squidfunk closed this Dec 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants