Fix typos

This commit is contained in:
Joel Wachsler 2022-07-17 11:26:41 +00:00
parent 44b61c5534
commit 5fb87250dd
10 changed files with 166 additions and 165 deletions

View File

@ -26,7 +26,8 @@
"tamasfe.even-better-toml", "tamasfe.even-better-toml",
"serayuzgur.crates", "serayuzgur.crates",
"redhat.vscode-yaml", "redhat.vscode-yaml",
"eamodio.gitlens" "eamodio.gitlens",
"streetsidesoftware.code-spell-checker"
] ]
} }
}, },

View File

@ -111,27 +111,27 @@ fn generate_builder_field(
parameter: &parser::ReturnTypeParameter, parameter: &parser::ReturnTypeParameter,
enum_names: &HashMap<String, String>, enum_names: &HashMap<String, String>,
) -> proc_macro2::TokenStream { ) -> proc_macro2::TokenStream {
let namestr = &parameter.name; let name_string = &parameter.name;
let name = util::to_ident(&namestr.to_snake().replace("__", "_")); let name = util::to_ident(&name_string.to_snake().replace("__", "_"));
let enum_name = match enum_names.get(namestr) { let enum_name = match enum_names.get(name_string) {
Some(enum_type) => enum_type.to_owned(), Some(enum_type) => enum_type.to_owned(),
None => parameter.return_type.to_owned_type(), None => parameter.return_type.to_owned_type(),
}; };
let rtype = util::to_ident(&enum_name); let return_type = util::to_ident(&enum_name);
let rtype_as_quote = if parameter.return_type.is_list() { let return_type_as_quote = if parameter.return_type.is_list() {
quote! { std::vec::Vec<#rtype> } quote! { std::vec::Vec<#return_type> }
} else { } else {
quote! { #rtype } quote! { #return_type }
}; };
let generate_field = |field_name| { let generate_field = |field_name| {
quote! { quote! {
#[serde(rename = #namestr)] #[serde(rename = #name_string)]
pub #field_name: #rtype_as_quote pub #field_name: #return_type_as_quote
} }
}; };
// "type" is a reserved keyword in Rust, so we just add "t_" to it. // "type" is a reserved keyword in Rust, so we just add "t_" to it.
if namestr == "type" { if name_string == "type" {
generate_field(format_ident!("t_{}", name)) generate_field(format_ident!("t_{}", name))
} else { } else {
generate_field(name) generate_field(name)

View File

@ -1,7 +1,7 @@
#[derive(Debug, Clone, PartialEq, Eq)] #[derive(Debug, Clone, PartialEq, Eq)]
pub enum MdContent { pub enum MdContent {
Text(String), Text(String),
Asterix(String), Asterisk(String),
Table(Table), Table(Table),
} }
@ -39,7 +39,7 @@ impl MdContent {
pub fn inner_value_as_string(&self) -> String { pub fn inner_value_as_string(&self) -> String {
match self { match self {
MdContent::Text(text) => text.into(), MdContent::Text(text) => text.into(),
MdContent::Asterix(text) => text.into(), MdContent::Asterisk(text) => text.into(),
MdContent::Table(table) => table.raw(), MdContent::Table(table) => table.raw(),
} }
} }
@ -68,7 +68,7 @@ impl MdToken {
content: line.trim_matches('#').trim().to_string(), content: line.trim_matches('#').trim().to_string(),
}) })
} else if line.starts_with('*') { } else if line.starts_with('*') {
MdToken::Content(MdContent::Asterix( MdToken::Content(MdContent::Asterisk(
line.trim_matches('*').trim().to_string(), line.trim_matches('*').trim().to_string(),
)) ))
} else { } else {

View File

@ -113,8 +113,8 @@ mod tests {
} }
#[test] #[test]
fn should_remove_surrounding_asterix() { fn should_remove_surrounding_asterisk() {
run_test!("should_remove_surrounding_asterix"); run_test!("should_remove_surrounding_asterisk");
} }
#[test] #[test]

View File

@ -32,7 +32,7 @@ TokenTree {
Text( Text(
"", "",
), ),
Asterix( Asterisk(
"Parameters:", "Parameters:",
), ),
Text( Text(
@ -114,7 +114,7 @@ TokenTree {
Text( Text(
"", "",
), ),
Asterix( Asterisk(
"Returns:", "Returns:",
), ),
Text( Text(

View File

@ -5,7 +5,7 @@ pub fn parse_method_description(content: &[MdContent]) -> Option<String> {
.iter() .iter()
// skip until we get to the "Returns:" text // skip until we get to the "Returns:" text
.skip_while(|row| match row { .skip_while(|row| match row {
MdContent::Asterix(text) => !text.starts_with("Returns:"), MdContent::Asterisk(text) => !text.starts_with("Returns:"),
_ => true, _ => true,
}) })
// there is one space before the table // there is one space before the table

View File

@ -6,7 +6,7 @@ pub fn parse_parameters(content: &[md_parser::MdContent]) -> Option<Vec<types::T
let mut it = content let mut it = content
.iter() .iter()
.skip_while(|row| match row { .skip_while(|row| match row {
md_parser::MdContent::Asterix(content) | md_parser::MdContent::Text(content) => { md_parser::MdContent::Asterisk(content) | md_parser::MdContent::Text(content) => {
!content.starts_with("Parameters:") !content.starts_with("Parameters:")
} }
_ => true, _ => true,

File diff suppressed because it is too large Load Diff