Add warning block support in rustdoc

This commit is contained in:
Guillaume Gomez 2023-01-07 14:48:55 +01:00
parent 3071e0aef6
commit d51521e280
4 changed files with 26 additions and 3 deletions

View File

@ -270,7 +270,7 @@ ul ul, ol ul, ul ol, ol ol {
margin-bottom: .625em; margin-bottom: .625em;
} }
p { p, .docblock > .warning {
/* Paragraph spacing at least 1.5 times line spacing per Web Content Accessibility Guidelines. /* Paragraph spacing at least 1.5 times line spacing per Web Content Accessibility Guidelines.
Line-height is 1.5rem, so line spacing is .5rem; .75em is 1.5 times that. Line-height is 1.5rem, so line spacing is .5rem; .75em is 1.5 times that.
https://www.w3.org/WAI/WCAG21/Understanding/visual-presentation.html */ https://www.w3.org/WAI/WCAG21/Understanding/visual-presentation.html */
@ -278,7 +278,7 @@ p {
} }
/* For the last child of a div, the margin will be taken care of /* For the last child of a div, the margin will be taken care of
by the margin-top of the next item. */ by the margin-top of the next item. */
p:last-child { p:last-child, .docblock > .warning:last-child {
margin: 0; margin: 0;
} }
@ -1096,7 +1096,7 @@ pre.rust .doccomment {
} }
.example-wrap.ignore .tooltip { .example-wrap.ignore .tooltip {
color: var(--codeblock-ignore-color); color: var(--codeblock-ignore-color);
} }
.example-wrap.compile_fail:hover .tooltip, .example-wrap.compile_fail:hover .tooltip,
@ -1124,6 +1124,26 @@ pre.rust .doccomment {
font-size: 1.25rem; font-size: 1.25rem;
} }
/* This class only exists for users who want to draw attention to a particular element in their
documentation. */
.content .docblock .warning {
border-left: 2px solid var(--warning-border-color);
padding: 14px;
position: relative;
/* The "!important" part is required because the rule is otherwise overruled in this CSS
selector: ".docblock > :not(.more-examples-toggle):not(.example-wrap)" */
overflow-x: visible !important;
}
.content .docblock .warning::before {
color: var(--warning-border-color);
content: "ⓘ";
position: absolute;
left: -25px;
top: 5px;
font-weight: bold;
font-size: 1.25rem;
}
a.test-arrow { a.test-arrow {
visibility: hidden; visibility: hidden;
position: absolute; position: absolute;

View File

@ -31,6 +31,7 @@ Original by Dempfi (https://github.com/dempfi/ayu)
--codeblock-error-color: rgba(255, 0, 0, .5); --codeblock-error-color: rgba(255, 0, 0, .5);
--codeblock-ignore-hover-color: rgb(255, 142, 0); --codeblock-ignore-hover-color: rgb(255, 142, 0);
--codeblock-ignore-color: rgba(255, 142, 0, .6); --codeblock-ignore-color: rgba(255, 142, 0, .6);
--warning-border-color: rgb(255, 142, 0);
--type-link-color: #ffa0a5; --type-link-color: #ffa0a5;
--trait-link-color: #39afd7; --trait-link-color: #39afd7;
--assoc-item-link-color: #39afd7; --assoc-item-link-color: #39afd7;

View File

@ -26,6 +26,7 @@
--codeblock-error-color: rgba(255, 0, 0, .5); --codeblock-error-color: rgba(255, 0, 0, .5);
--codeblock-ignore-hover-color: rgb(255, 142, 0); --codeblock-ignore-hover-color: rgb(255, 142, 0);
--codeblock-ignore-color: rgba(255, 142, 0, .6); --codeblock-ignore-color: rgba(255, 142, 0, .6);
--warning-border-color: rgb(255, 142, 0);
--type-link-color: #2dbfb8; --type-link-color: #2dbfb8;
--trait-link-color: #b78cf2; --trait-link-color: #b78cf2;
--assoc-item-link-color: #d2991d; --assoc-item-link-color: #d2991d;

View File

@ -26,6 +26,7 @@
--codeblock-error-color: rgba(255, 0, 0, .5); --codeblock-error-color: rgba(255, 0, 0, .5);
--codeblock-ignore-hover-color: rgb(255, 142, 0); --codeblock-ignore-hover-color: rgb(255, 142, 0);
--codeblock-ignore-color: rgba(255, 142, 0, .6); --codeblock-ignore-color: rgba(255, 142, 0, .6);
--warning-border-color: rgb(255, 142, 0);
--type-link-color: #ad378a; --type-link-color: #ad378a;
--trait-link-color: #6e4fc9; --trait-link-color: #6e4fc9;
--assoc-item-link-color: #3873ad; --assoc-item-link-color: #3873ad;