Rollup merge of #74368 - GuillaumeGomez:css-tidy-check, r=Mark-Simulacrum
Add CSS tidy check r? @Mark-Simulacrum
This commit is contained in:
commit
ef0540bb75
1
src/librustdoc/html/static/normalize.css
vendored
1
src/librustdoc/html/static/normalize.css
vendored
@ -1 +1,2 @@
|
||||
/* ignore-tidy-linelength */
|
||||
/*! normalize.css v3.0.0 | MIT License | git.io/normalize */html{font-family:sans-serif;-ms-text-size-adjust:100%;-webkit-text-size-adjust:100%}body{margin:0}article,aside,details,figcaption,figure,footer,header,hgroup,main,nav,section,summary{display:block}audio,canvas,progress,video{display:inline-block;vertical-align:baseline}audio:not([controls]){display:none;height:0}[hidden],template{display:none}a{background:transparent}a:active,a:hover{outline:0}abbr[title]{border-bottom:1px dotted}b,strong{font-weight:bold}dfn{font-style:italic}h1{font-size:2em;margin:.67em 0}mark{background:#ff0;color:#000}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sup{top:-0.5em}sub{bottom:-0.25em}img{border:0}svg:not(:root){overflow:hidden}figure{margin:1em 40px}hr{-moz-box-sizing:content-box;box-sizing:content-box;height:0}pre{overflow:auto}code,kbd,pre,samp{font-family:monospace,monospace;font-size:1em}button,input,optgroup,select,textarea{color:inherit;font:inherit;margin:0}button{overflow:visible}button,select{text-transform:none}button,html input[type="button"],input[type="reset"],input[type="submit"]{-webkit-appearance:button;cursor:pointer}button[disabled],html input[disabled]{cursor:default}button::-moz-focus-inner,input::-moz-focus-inner{border:0;padding:0}input{line-height:normal}input[type="checkbox"],input[type="radio"]{box-sizing:border-box;padding:0}input[type="number"]::-webkit-inner-spin-button,input[type="number"]::-webkit-outer-spin-button{height:auto}input[type="search"]{-webkit-appearance:textfield;-moz-box-sizing:content-box;-webkit-box-sizing:content-box;box-sizing:content-box}input[type="search"]::-webkit-search-cancel-button,input[type="search"]::-webkit-search-decoration{-webkit-appearance:none}fieldset{border:1px solid silver;margin:0 2px;padding:.35em .625em .75em}legend{border:0;padding:0}textarea{overflow:auto}optgroup{font-weight:bold}table{border-collapse:collapse;border-spacing:0}td,th{padding:0}
|
||||
|
@ -49,9 +49,9 @@
|
||||
}
|
||||
|
||||
* {
|
||||
-webkit-box-sizing: border-box;
|
||||
-moz-box-sizing: border-box;
|
||||
box-sizing: border-box;
|
||||
-webkit-box-sizing: border-box;
|
||||
-moz-box-sizing: border-box;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
/* This part handles the "default" theme being used depending on the system one. */
|
||||
@ -91,7 +91,8 @@ h2 {
|
||||
h3 {
|
||||
font-size: 1.3em;
|
||||
}
|
||||
h1, h2, h3:not(.impl):not(.method):not(.type):not(.tymethod):not(.important), h4:not(.method):not(.type):not(.tymethod):not(.associatedconstant) {
|
||||
h1, h2, h3:not(.impl):not(.method):not(.type):not(.tymethod):not(.important),
|
||||
h4:not(.method):not(.type):not(.tymethod):not(.associatedconstant) {
|
||||
font-weight: 500;
|
||||
margin: 20px 0 15px 0;
|
||||
padding-bottom: 6px;
|
||||
@ -103,7 +104,8 @@ h1.fqn {
|
||||
h1.fqn > .in-band > a:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
h2, h3:not(.impl):not(.method):not(.type):not(.tymethod), h4:not(.method):not(.type):not(.tymethod):not(.associatedconstant) {
|
||||
h2, h3:not(.impl):not(.method):not(.type):not(.tymethod),
|
||||
h4:not(.method):not(.type):not(.tymethod):not(.associatedconstant) {
|
||||
border-bottom: 1px solid;
|
||||
}
|
||||
h3.impl, h3.method, h4.method, h3.type, h4.type, h4.associatedconstant {
|
||||
@ -1123,7 +1125,7 @@ h3 > .collapse-toggle, h4 > .collapse-toggle {
|
||||
/* The margin on the tooltip does not capture hover events,
|
||||
this extends the area of hover enough so that mouse hover is not
|
||||
lost when moving the mouse to the tooltip */
|
||||
content: "\00a0\00a0\00a0";
|
||||
content: "\00a0\00a0\00a0";
|
||||
}
|
||||
|
||||
.important-traits .important, .important-traits .docblock {
|
||||
@ -1131,13 +1133,12 @@ h3 > .collapse-toggle, h4 > .collapse-toggle {
|
||||
}
|
||||
|
||||
.important-traits .docblock code.content{
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
font-size: 20px;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
font-size: 20px;
|
||||
}
|
||||
|
||||
/* Example code has the "Run" button that
|
||||
needs to be positioned relative to the pre */
|
||||
/* Example code has the "Run" button that needs to be positioned relative to the pre */
|
||||
pre.rust.rust-example-rendered {
|
||||
position: relative;
|
||||
}
|
||||
|
@ -10,7 +10,8 @@ body {
|
||||
color: #c5c5c5;
|
||||
}
|
||||
|
||||
h1, h2, h3:not(.impl):not(.method):not(.type):not(.tymethod), h4:not(.method):not(.type):not(.tymethod) {
|
||||
h1, h2, h3:not(.impl):not(.method):not(.type):not(.tymethod),
|
||||
h4:not(.method):not(.type):not(.tymethod) {
|
||||
color: white;
|
||||
}
|
||||
h1.fqn {
|
||||
@ -41,13 +42,13 @@ h3 > code, h4 > code, h5 > code {
|
||||
color: #e6e1cf;
|
||||
}
|
||||
pre > code {
|
||||
color: #e6e1cf;
|
||||
color: #e6e1cf;
|
||||
}
|
||||
span code {
|
||||
color: #e6e1cf;
|
||||
color: #e6e1cf;
|
||||
}
|
||||
.docblock a > code {
|
||||
color: #39AFD7 !important;
|
||||
color: #39AFD7 !important;
|
||||
}
|
||||
.docblock code, .docblock-short code {
|
||||
background-color: #191f26;
|
||||
@ -100,11 +101,11 @@ pre {
|
||||
}
|
||||
|
||||
.sidebar-elems .location {
|
||||
color: #ff7733;
|
||||
color: #ff7733;
|
||||
}
|
||||
|
||||
.sidebar-elems .location a {
|
||||
color: #fff;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.sidebar .version {
|
||||
@ -123,9 +124,9 @@ pre {
|
||||
|
||||
.line-numbers span { color: #5c6773ab; }
|
||||
.line-numbers .line-highlighted {
|
||||
background-color: rgba(255, 236, 164, 0.06) !important;
|
||||
padding-right: 4px;
|
||||
border-right: 1px solid #ffb44c;
|
||||
background-color: rgba(255, 236, 164, 0.06) !important;
|
||||
padding-right: 4px;
|
||||
border-right: 1px solid #ffb44c;
|
||||
}
|
||||
|
||||
.docblock h1, .docblock h2, .docblock h3, .docblock h4, .docblock h5 {
|
||||
@ -168,31 +169,31 @@ pre {
|
||||
.content span.keyword, .content a.keyword { color: #de5249; }
|
||||
|
||||
.content span.externcrate, .content span.mod, .content a.mod {
|
||||
color: #acccf9;
|
||||
color: #acccf9;
|
||||
}
|
||||
.content span.struct, .content a.struct {
|
||||
color: #ffa0a5;
|
||||
color: #ffa0a5;
|
||||
}
|
||||
.content span.enum, .content a.enum {
|
||||
color: #99e0c9;
|
||||
color: #99e0c9;
|
||||
}
|
||||
.content span.trait, .content a.trait {
|
||||
color: #39AFD7;
|
||||
color: #39AFD7;
|
||||
}
|
||||
.content span.type, .content a.type {
|
||||
color: #cfbcf5;
|
||||
color: #cfbcf5;
|
||||
}
|
||||
.content span.fn, .content a.fn, .content span.method,
|
||||
.content a.method, .content span.tymethod,
|
||||
.content a.tymethod, .content .fnname {
|
||||
color: #fdd687;
|
||||
color: #fdd687;
|
||||
}
|
||||
.content span.attr, .content a.attr, .content span.derive,
|
||||
.content a.derive, .content span.macro, .content a.macro {
|
||||
color: #a37acc;
|
||||
color: #a37acc;
|
||||
}
|
||||
|
||||
pre.rust .comment, pre.rust .doccomment {
|
||||
pre.rust .comment, pre.rust .doccomment {
|
||||
color: #788797;
|
||||
font-style: italic;
|
||||
}
|
||||
@ -228,14 +229,24 @@ a {
|
||||
}
|
||||
|
||||
.search-input {
|
||||
color: #ffffff;
|
||||
background-color: #141920;
|
||||
box-shadow: 0 0 0 1px #424c57,0 0 0 2px transparent;
|
||||
transition: box-shadow 150ms ease-in-out;
|
||||
color: #ffffff;
|
||||
background-color: #141920;
|
||||
box-shadow: 0 0 0 1px #424c57,0 0 0 2px transparent;
|
||||
transition: box-shadow 150ms ease-in-out;
|
||||
}
|
||||
|
||||
#crate-search+.search-input:focus {
|
||||
box-shadow: 0 0 0 1px #148099,0 0 0 2px transparent;
|
||||
box-shadow: 0 0 0 1px #148099,0 0 0 2px transparent;
|
||||
color: #ffffff;
|
||||
background-color: #141920;
|
||||
box-shadow: none;
|
||||
transition: box-shadow 150ms ease-in-out;
|
||||
border-radius: 4px;
|
||||
margin-left: 8px;
|
||||
}
|
||||
|
||||
#crate-search+.search-input:focus {
|
||||
box-shadow: 0px 6px 20px 0px black;
|
||||
}
|
||||
|
||||
.search-focus:disabled {
|
||||
@ -249,7 +260,7 @@ a {
|
||||
.stab.unstable,
|
||||
.stab.deprecated,
|
||||
.stab.portability {
|
||||
color: #c5c5c5;
|
||||
color: #c5c5c5;
|
||||
background: #314559 !important;
|
||||
border-style: none !important;
|
||||
border-radius: 4px;
|
||||
@ -262,10 +273,10 @@ a {
|
||||
}
|
||||
|
||||
#help > div {
|
||||
background: #14191f;
|
||||
box-shadow: 0px 6px 20px 0px black;
|
||||
border: none;
|
||||
border-radius: 4px;
|
||||
background: #14191f;
|
||||
box-shadow: 0px 6px 20px 0px black;
|
||||
border: none;
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
.since {
|
||||
@ -288,14 +299,14 @@ pre.rust .question-mark {
|
||||
color: #ff9011;
|
||||
}
|
||||
pre.rust .self {
|
||||
color: #36a3d9;
|
||||
font-style: italic;
|
||||
color: #36a3d9;
|
||||
font-style: italic;
|
||||
}
|
||||
pre.rust .attribute {
|
||||
color: #e6e1cf;
|
||||
color: #e6e1cf;
|
||||
}
|
||||
pre.rust .attribute .ident, pre.rust .attribute .op {
|
||||
color: #e6e1cf;
|
||||
color: #e6e1cf;
|
||||
}
|
||||
|
||||
.example-wrap > pre.line-number {
|
||||
@ -304,15 +315,15 @@ pre.rust .attribute .ident, pre.rust .attribute .op {
|
||||
}
|
||||
|
||||
a.test-arrow {
|
||||
font-size: 100%;
|
||||
color: #788797;
|
||||
border-radius: 4px;
|
||||
background-color: rgba(255, 255, 255, 0);
|
||||
font-size: 100%;
|
||||
color: #788797;
|
||||
border-radius: 4px;
|
||||
background-color: rgba(255, 255, 255, 0);
|
||||
}
|
||||
|
||||
a.test-arrow:hover {
|
||||
background-color: rgba(242, 151, 24, 0.05);
|
||||
color: #ffb44c;
|
||||
background-color: rgba(242, 151, 24, 0.05);
|
||||
color: #ffb44c;
|
||||
}
|
||||
|
||||
.toggle-label {
|
||||
@ -377,9 +388,9 @@ pre.ignore:hover, .information:hover + pre.ignore {
|
||||
}
|
||||
|
||||
.tooltip .tooltiptext {
|
||||
background-color: #314559;
|
||||
color: #c5c5c5;
|
||||
border: 1px solid #5c6773;
|
||||
background-color: #314559;
|
||||
color: #c5c5c5;
|
||||
border: 1px solid #5c6773;
|
||||
}
|
||||
|
||||
.tooltip .tooltiptext::after {
|
||||
@ -387,12 +398,12 @@ pre.ignore:hover, .information:hover + pre.ignore {
|
||||
}
|
||||
|
||||
.important-traits-tooltiptext {
|
||||
background-color: #314559;
|
||||
border-color: #5c6773;
|
||||
background-color: #314559;
|
||||
border-color: #5c6773;
|
||||
}
|
||||
|
||||
#titles > div.selected {
|
||||
background-color: #141920 !important;
|
||||
background-color: #141920 !important;
|
||||
border-bottom: 1px solid #ffb44c !important;
|
||||
border-top: none;
|
||||
}
|
||||
@ -403,7 +414,7 @@ pre.ignore:hover, .information:hover + pre.ignore {
|
||||
}
|
||||
|
||||
#titles > div:hover {
|
||||
border-bottom: 1px solid rgba(242, 151, 24, 0.3);
|
||||
border-bottom: 1px solid rgba(242, 151, 24, 0.3);
|
||||
}
|
||||
|
||||
#titles > div > div.count {
|
||||
@ -413,12 +424,13 @@ pre.ignore:hover, .information:hover + pre.ignore {
|
||||
/* rules that this theme does not need to set, here to satisfy the rule checker */
|
||||
/* note that a lot of these are partially set in some way (meaning they are set
|
||||
individually rather than as a group) */
|
||||
/* TODO: these rules should be at the bottom of the file but currently must be
|
||||
/* FIXME: these rules should be at the bottom of the file but currently must be
|
||||
above the `@media (max-width: 700px)` rules due to a bug in the css checker */
|
||||
/* see https://github.com/rust-lang/rust/pull/71237#issuecomment-618170143 */
|
||||
.content .highlighted.mod, .content .highlighted.externcrate {}
|
||||
.search-input:focus {}
|
||||
.content span.attr,.content a.attr,.block a.current.attr,.content span.derive,.content a.derive,.block a.current.derive,.content span.macro,.content a.macro,.block a.current.macro {}
|
||||
.content span.attr,.content a.attr,.block a.current.attr,.content span.derive,.content a.derive,
|
||||
.block a.current.derive,.content span.macro,.content a.macro,.block a.current.macro {}
|
||||
.content .highlighted.trait {}
|
||||
.content span.struct,.content a.struct,.block a.current.struct {}
|
||||
#titles>div:hover,#titles>div.selected {}
|
||||
@ -433,16 +445,20 @@ pre.rust .lifetime {}
|
||||
.content .highlighted.fn,.content .highlighted.method,.content .highlighted.tymethod {}
|
||||
h2,h3:not(.impl):not(.method):not(.type):not(.tymethod),h4:not(.method):not(.type):not(.tymethod) {}
|
||||
.content span.enum,.content a.enum,.block a.current.enum {}
|
||||
.content span.constant,.content a.constant,.block a.current.constant,.content span.static,.content a.static,.block a.current.static {}
|
||||
.content span.constant,.content a.constant,.block a.current.constant,.content span.static,
|
||||
.content a.static,.block a.current.static {}
|
||||
.content span.keyword,.content a.keyword,.block a.current.keyword {}
|
||||
pre.rust .comment {}
|
||||
.content .highlighted.enum {}
|
||||
.content .highlighted.struct {}
|
||||
.content .highlighted.keyword {}
|
||||
.content span.traitalias,.content a.traitalias,.block a.current.traitalias {}
|
||||
.content span.fn,.content a.fn,.block a.current.fn,.content span.method,.content a.method,.block a.current.method,.content span.tymethod,.content a.tymethod,.block a.current.tymethod,.content .fnname {}
|
||||
.content span.fn,.content a.fn,.block a.current.fn,.content span.method,.content a.method,
|
||||
.block a.current.method,.content span.tymethod,.content a.tymethod,.block a.current.tymethod,
|
||||
.content .fnname {}
|
||||
pre.rust .kw {}
|
||||
pre.rust .self,pre.rust .bool-val,pre.rust .prelude-val,pre.rust .attribute,pre.rust .attribute .ident {}
|
||||
pre.rust .self,pre.rust .bool-val,pre.rust .prelude-val,pre.rust .attribute,
|
||||
pre.rust .attribute .ident {}
|
||||
.content span.foreigntype,.content a.foreigntype,.block a.current.foreigntype {}
|
||||
pre.rust .doccomment {}
|
||||
.stab.deprecated {}
|
||||
@ -483,11 +499,11 @@ kbd {
|
||||
|
||||
#theme-picker, #settings-menu {
|
||||
border-color: #5c6773;
|
||||
background-color: #0f1419;
|
||||
background-color: #0f1419;
|
||||
}
|
||||
|
||||
#theme-picker > img, #settings-menu > img {
|
||||
filter: invert(100);
|
||||
filter: invert(100);
|
||||
}
|
||||
|
||||
#theme-picker:hover, #theme-picker:focus,
|
||||
|
@ -3,13 +3,15 @@ body {
|
||||
color: #ddd;
|
||||
}
|
||||
|
||||
h1, h2, h3:not(.impl):not(.method):not(.type):not(.tymethod), h4:not(.method):not(.type):not(.tymethod) {
|
||||
h1, h2, h3:not(.impl):not(.method):not(.type):not(.tymethod),
|
||||
h4:not(.method):not(.type):not(.tymethod) {
|
||||
color: #ddd;
|
||||
}
|
||||
h1.fqn {
|
||||
border-bottom-color: #d2d2d2;
|
||||
}
|
||||
h2, h3:not(.impl):not(.method):not(.type):not(.tymethod), h4:not(.method):not(.type):not(.tymethod) {
|
||||
h2, h3:not(.impl):not(.method):not(.type):not(.tymethod),
|
||||
h4:not(.method):not(.type):not(.tymethod) {
|
||||
border-bottom-color: #d2d2d2;
|
||||
}
|
||||
|
||||
|
@ -5,13 +5,15 @@ body {
|
||||
color: black;
|
||||
}
|
||||
|
||||
h1, h2, h3:not(.impl):not(.method):not(.type):not(.tymethod), h4:not(.method):not(.type):not(.tymethod) {
|
||||
h1, h2, h3:not(.impl):not(.method):not(.type):not(.tymethod),
|
||||
h4:not(.method):not(.type):not(.tymethod) {
|
||||
color: black;
|
||||
}
|
||||
h1.fqn {
|
||||
border-bottom-color: #D5D5D5;
|
||||
}
|
||||
h2, h3:not(.impl):not(.method):not(.type):not(.tymethod), h4:not(.method):not(.type):not(.tymethod) {
|
||||
h2, h3:not(.impl):not(.method):not(.type):not(.tymethod),
|
||||
h4:not(.method):not(.type):not(.tymethod) {
|
||||
border-bottom-color: #DDDDDD;
|
||||
}
|
||||
|
||||
|
@ -119,6 +119,7 @@ fn contains_ignore_directive(can_contain: bool, contents: &str, check: &str) ->
|
||||
// Update `can_contain` when changing this
|
||||
if contents.contains(&format!("// ignore-tidy-{}", check))
|
||||
|| contents.contains(&format!("# ignore-tidy-{}", check))
|
||||
|| contents.contains(&format!("/* ignore-tidy-{} */", check))
|
||||
{
|
||||
Directive::Ignore(false)
|
||||
} else {
|
||||
@ -136,15 +137,37 @@ macro_rules! suppressible_tidy_err {
|
||||
};
|
||||
}
|
||||
|
||||
pub fn is_in(full_path: &Path, parent_folder_to_find: &str, folder_to_find: &str) -> bool {
|
||||
if let Some(parent) = full_path.parent() {
|
||||
if parent.file_name().map_or_else(
|
||||
|| false,
|
||||
|f| {
|
||||
f.to_string_lossy() == folder_to_find
|
||||
&& parent
|
||||
.parent()
|
||||
.and_then(|f| f.file_name())
|
||||
.map_or_else(|| false, |f| f == parent_folder_to_find)
|
||||
},
|
||||
) {
|
||||
true
|
||||
} else {
|
||||
is_in(parent, parent_folder_to_find, folder_to_find)
|
||||
}
|
||||
} else {
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
pub fn check(path: &Path, bad: &mut bool) {
|
||||
super::walk(path, &mut super::filter_dirs, &mut |entry, contents| {
|
||||
let file = entry.path();
|
||||
let filename = file.file_name().unwrap().to_string_lossy();
|
||||
let extensions = [".rs", ".py", ".js", ".sh", ".c", ".cpp", ".h", ".md"];
|
||||
let extensions = [".rs", ".py", ".js", ".sh", ".c", ".cpp", ".h", ".md", ".css"];
|
||||
if extensions.iter().all(|e| !filename.ends_with(e)) || filename.starts_with(".#") {
|
||||
return;
|
||||
}
|
||||
|
||||
let is_style_file = filename.ends_with(".css");
|
||||
let under_rustfmt = filename.ends_with(".rs") &&
|
||||
// This list should ideally be sourced from rustfmt.toml but we don't want to add a toml
|
||||
// parser to tidy.
|
||||
@ -161,6 +184,10 @@ pub fn check(path: &Path, bad: &mut bool) {
|
||||
// currently), just the long error code explanation ones.
|
||||
return;
|
||||
}
|
||||
if is_style_file && !is_in(file, "src", "librustdoc") {
|
||||
// We only check CSS files in rustdoc.
|
||||
return;
|
||||
}
|
||||
|
||||
if contents.is_empty() {
|
||||
tidy_error!(bad, "{}: empty file", file.display());
|
||||
@ -172,8 +199,9 @@ pub fn check(path: &Path, bad: &mut bool) {
|
||||
COLS
|
||||
};
|
||||
|
||||
let can_contain =
|
||||
contents.contains("// ignore-tidy-") || contents.contains("# ignore-tidy-");
|
||||
let can_contain = contents.contains("// ignore-tidy-")
|
||||
|| contents.contains("# ignore-tidy-")
|
||||
|| contents.contains("/* ignore-tidy-");
|
||||
// Enable testing ICE's that require specific (untidy)
|
||||
// file formats easily eg. `issue-1234-ignore-tidy.rs`
|
||||
if filename.contains("ignore-tidy") {
|
||||
@ -208,12 +236,15 @@ pub fn check(path: &Path, bad: &mut bool) {
|
||||
&format!("line longer than {} chars", max_columns)
|
||||
);
|
||||
}
|
||||
if line.contains('\t') {
|
||||
if !is_style_file && line.contains('\t') {
|
||||
suppressible_tidy_err!(err, skip_tab, "tab character");
|
||||
}
|
||||
if line.ends_with(' ') || line.ends_with('\t') {
|
||||
suppressible_tidy_err!(err, skip_end_whitespace, "trailing whitespace");
|
||||
}
|
||||
if is_style_file && line.starts_with(' ') {
|
||||
err("CSS files use tabs for indent");
|
||||
}
|
||||
if line.contains('\r') {
|
||||
suppressible_tidy_err!(err, skip_cr, "CR character");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user