-
-
Notifications
You must be signed in to change notification settings - Fork 78
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
implement struct_now_doc_hidden lint
- Loading branch information
Showing
7 changed files
with
118 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
SemverQuery( | ||
id: "struct_now_doc_hidden", | ||
human_readable_name: "pub struct is now #[doc(hidden)]", | ||
description: "A pub struct is now hidden from documentation effectively removing it from the crate's public api.", | ||
required_update: Major, | ||
reference_link: Some("https://doc.rust-lang.org/rustdoc/write-documentation/the-doc-attribute.html#hidden"), | ||
query: r#" | ||
{ | ||
CrateDiff { | ||
baseline { | ||
item { | ||
... on Struct { | ||
visibility_limit @filter(op: "=", value: ["$public"]) | ||
struct_type @output @tag | ||
importable_path { | ||
path @output @tag | ||
public_api @filter(op: "=", value: ["$true"]) | ||
} | ||
} | ||
} | ||
} | ||
current { | ||
item { | ||
... on Struct { | ||
visibility_limit @filter(op: "=", value: ["$public"]) | ||
struct_name: name @output | ||
struct_type @filter(op: "=", value: ["%struct_type"]) | ||
importable_path { | ||
path @filter(op: "=", value: ["%path"]) | ||
public_api @filter(op: "!=", value: ["$true"]) | ||
} | ||
span_: span @optional { | ||
filename @output | ||
begin_line @output | ||
} | ||
} | ||
} | ||
} | ||
} | ||
}"#, | ||
arguments: { | ||
"public": "public", | ||
"true": true, | ||
}, | ||
error_message: "A publicly visible struct is now hidden via #[doc(hidden)].", | ||
per_result_error_template: Some("Struct {{struct_name}} in file {{span_filename}}:{{span_begin_line}}"), | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
[package] | ||
publish = false | ||
name = "struct_now_doc_hidden" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
[dependencies] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
struct StayingKnown; | ||
|
||
#[doc(hidden)] | ||
pub struct Example; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
[package] | ||
publish = false | ||
name = "struct_now_doc_hidden" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
[dependencies] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
struct StayingKnown; | ||
|
||
pub struct Example; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
{ | ||
"./test_crates/struct_now_doc_hidden/": [ | ||
{ | ||
"path": List([ | ||
String("struct_now_doc_hidden"), | ||
String("Example"), | ||
]), | ||
"span_begin_line": Uint64(4), | ||
"span_filename": String("src/lib.rs"), | ||
"struct_name": String("Example"), | ||
"struct_type": String("unit"), | ||
}, | ||
], | ||
"./test_crates/type_hidden_from_public_api/": [ | ||
{ | ||
"path": List([ | ||
String("type_hidden_from_public_api"), | ||
String("ExamplePlainStruct"), | ||
]), | ||
"span_begin_line": Uint64(2), | ||
"span_filename": String("src/lib.rs"), | ||
"struct_name": String("ExamplePlainStruct"), | ||
"struct_type": String("plain"), | ||
}, | ||
{ | ||
"path": List([ | ||
String("type_hidden_from_public_api"), | ||
String("ExampleTupleStruct"), | ||
]), | ||
"span_begin_line": Uint64(7), | ||
"span_filename": String("src/lib.rs"), | ||
"struct_name": String("ExampleTupleStruct"), | ||
"struct_type": String("tuple"), | ||
}, | ||
{ | ||
"path": List([ | ||
String("type_hidden_from_public_api"), | ||
String("ExampleUnitStruct"), | ||
]), | ||
"span_begin_line": Uint64(10), | ||
"span_filename": String("src/lib.rs"), | ||
"struct_name": String("ExampleUnitStruct"), | ||
"struct_type": String("unit"), | ||
}, | ||
], | ||
} |