-
-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #71 from kube-rs/refactor
Add support for enum renames and refactor analyzer interface
- Loading branch information
Showing
4 changed files
with
242 additions
and
161 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
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 |
---|---|---|
@@ -1,42 +1,62 @@ | ||
#[macro_use] extern crate log; | ||
|
||
/// Output struct from analysis | ||
#[derive(Default, Debug)] | ||
pub struct OutputStruct { | ||
// The short name of the struct (kind + capitalized suffix) | ||
pub name: String, | ||
pub level: u8, | ||
pub members: Vec<OutputMember>, | ||
pub docs: Option<String>, | ||
pub is_enum: bool, | ||
} | ||
|
||
/// Output member belonging to an OutputStruct | ||
#[derive(Default, Debug)] | ||
pub struct OutputMember { | ||
pub name: String, | ||
pub type_: String, | ||
pub serde_annot: Vec<String>, | ||
pub docs: Option<String>, | ||
} | ||
|
||
impl OutputStruct { | ||
pub fn uses_btreemaps(&self) -> bool { | ||
self.members.iter().any(|m| m.type_.contains("BTreeMap")) | ||
} | ||
|
||
pub fn uses_datetime(&self) -> bool { | ||
self.members.iter().any(|m| m.type_.contains("DateTime")) | ||
} | ||
|
||
pub fn uses_date(&self) -> bool { | ||
self.members.iter().any(|m| m.type_.contains("NaiveDate")) | ||
} | ||
|
||
pub fn uses_int_or_string(&self) -> bool { | ||
self.members.iter().any(|m| m.type_.contains("IntOrString")) | ||
} | ||
} | ||
|
||
mod analyzer; | ||
pub use analyzer::analyze; | ||
mod output; | ||
pub use output::{Container, Member, Output}; | ||
|
||
// synced from https://doc.rust-lang.org/reference/keywords.html feb 2022 | ||
pub const KEYWORDS: [&str; 52] = [ | ||
"as", | ||
"break", | ||
"const", | ||
"continue", | ||
"crate", | ||
"else", | ||
"enum", | ||
"extern", | ||
"false", | ||
"fn", | ||
"for", | ||
"if", | ||
"impl", | ||
"in", | ||
"let", | ||
"loop", | ||
"match", | ||
"mod", | ||
"move", | ||
"mut", | ||
"pub", | ||
"ref", | ||
"return", | ||
"self", | ||
"Self", | ||
"static", | ||
"struct", | ||
"super", | ||
"trait", | ||
"true", | ||
"type", | ||
"unsafe", | ||
"use", | ||
"where", | ||
"while", | ||
"async", | ||
"await", | ||
"dyn", | ||
"abstract", | ||
"become", | ||
"box", | ||
"do", | ||
"final", | ||
"macro", | ||
"override", | ||
"priv", | ||
"typeof", | ||
"unsized", | ||
"virtual", | ||
"yield", | ||
"try", | ||
"macro_rules", | ||
]; |
Oops, something went wrong.