diff --git a/clippy_lints/src/utils/internal_lints/metadata_collector.rs b/clippy_lints/src/utils/internal_lints/metadata_collector.rs index 3eccc89cdeb8..c9234a85dd2a 100644 --- a/clippy_lints/src/utils/internal_lints/metadata_collector.rs +++ b/clippy_lints/src/utils/internal_lints/metadata_collector.rs @@ -114,6 +114,8 @@ const DEPRECATED_LINT_TYPE: [&str; 3] = ["clippy_lints", "deprecated_lints", "Cl /// The index of the applicability name of `paths::APPLICABILITY_VALUES` const APPLICABILITY_NAME_INDEX: usize = 2; +/// This applicability will be set for unresolved applicability values. +const APPLICABILITY_UNRESOLVED_STR: &str = "Unresolved"; declare_clippy_lint! { /// **What it does:** Collects metadata about clippy lints for the website. @@ -192,7 +194,7 @@ impl Drop for MetadataCollector { let mut lints = std::mem::take(&mut self.lints).into_sorted_vec(); lints .iter_mut() - .for_each(|x| x.applicability = applicability_info.remove(&x.id)); + .for_each(|x| x.applicability = Some(applicability_info.remove(&x.id).unwrap_or_default())); // Outputting if Path::new(OUTPUT_FILE).exists() { @@ -208,7 +210,7 @@ struct LintMetadata { id: String, id_span: SerializableSpan, group: String, - level: &'static str, + level: String, docs: String, /// This field is only used in the output and will only be /// mapped shortly before the actual output. @@ -221,7 +223,7 @@ impl LintMetadata { id, id_span, group, - level, + level: level.to_string(), docs, applicability: None, } @@ -269,14 +271,16 @@ impl Serialize for ApplicabilityInfo { where S: Serializer, { - let index = self.applicability.unwrap_or_default(); - let mut s = serializer.serialize_struct("ApplicabilityInfo", 2)?; s.serialize_field("is_multi_part_suggestion", &self.is_multi_part_suggestion)?; - s.serialize_field( - "applicability", - &paths::APPLICABILITY_VALUES[index][APPLICABILITY_NAME_INDEX], - )?; + if let Some(index) = self.applicability { + s.serialize_field( + "applicability", + &paths::APPLICABILITY_VALUES[index][APPLICABILITY_NAME_INDEX], + )?; + } else { + s.serialize_field("applicability", APPLICABILITY_UNRESOLVED_STR)?; + } s.end() } } @@ -486,6 +490,13 @@ fn extract_attr_docs_or_lint(cx: &LateContext<'_>, item: &Item<'_>) -> Option, item: &Item<'_>) -> Option { let attrs = cx.tcx.hir().attrs(item.hir_id()); let mut lines = attrs.iter().filter_map(ast::Attribute::doc_str); @@ -510,7 +521,12 @@ fn extract_attr_docs(cx: &LateContext<'_>, item: &Item<'_>) -> Option { continue; } } - docs.push_str(line); + // This removes the leading space that the macro translation introduces + if let Some(stripped_doc) = line.strip_prefix(' ') { + docs.push_str(stripped_doc); + } else if !line.is_empty() { + docs.push_str(line); + } } Some(docs) } diff --git a/util/gh-pages/index.html b/util/gh-pages/index.html index 0174d3ffcbc2..48421150a549 100644 --- a/util/gh-pages/index.html +++ b/util/gh-pages/index.html @@ -1,10 +1,17 @@ + - ALL the Clippy Lints + Clippy Lints @@ -22,15 +29,95 @@ .panel-heading { cursor: pointer; } - .panel-title { display: flex; } + .panel-title { display: flex; flex-wrap: wrap;} .panel-title .label { display: inline-block; } - .panel-title-name { flex: 1; } + .panel-title-name { flex: 1; min-width: 400px;} .panel-title-name span { vertical-align: bottom; } .panel .panel-title-name .anchor { display: none; } .panel:hover .panel-title-name .anchor { display: inline;} + .label { + padding-top: 0.3em; + padding-bottom: 0.3em; + } + + .label-lint-group { + min-width: 8em; + } + .label-lint-level { + min-width: 4em; + } + + .label-lint-level-allow { + background-color: #5cb85c; + } + .label-lint-level-warn { + background-color: #f0ad4e; + } + .label-lint-level-deny { + background-color: #d9534f; + } + .label-lint-level-none { + background-color: #777777; + opacity: 0.5; + } + + .label-group-deprecated { + opacity: 0.5; + } + + .label-doc-folding { + color: #000; + background-color: #fff; + border: 1px solid var(--theme-popup-border); + } + .label-doc-folding:hover { + background-color: #e6e6e6; + } + + .lint-doc-md > h3 { + border-top: 1px solid var(--theme-popup-border); + padding: 10px 15px; + margin: 0 -15px; + font-size: 18px; + } + .lint-doc-md > h3:first-child { + border-top: none; + padding-top: 0px; + } + + @media (max-width:749px) { + .lint-additional-info-container { + display: flex; + flex-flow: column; + } + .lint-additional-info-item + .lint-additional-info-item { + border-top: 1px solid var(--theme-popup-border); + } + } + @media (min-width:750px) { + .lint-additional-info-container { + display: flex; + flex-flow: row; + } + .lint-additional-info-item + .lint-additional-info-item { + border-left: 1px solid var(--theme-popup-border); + } + } + + .lint-additional-info-item { + display: inline-flex; + min-width: 200px; + flex-grow: 1; + padding: 9px 5px 5px 15px; + } + + .label-applicability { + background-color: #777777; + margin: auto 5px; + }