Fix typos
This commit is contained in:
parent
44b61c5534
commit
5fb87250dd
|
@ -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"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -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 = ¶meter.name;
|
let name_string = ¶meter.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)
|
||||||
|
|
|
@ -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 {
|
||||||
|
|
|
@ -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]
|
||||||
|
|
|
@ -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(
|
||||||
|
|
|
@ -7,7 +7,7 @@ TokenTree {
|
||||||
"A",
|
"A",
|
||||||
),
|
),
|
||||||
content: [
|
content: [
|
||||||
Asterix(
|
Asterisk(
|
||||||
"B",
|
"B",
|
||||||
),
|
),
|
||||||
],
|
],
|
|
@ -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
|
||||||
|
|
|
@ -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
Loading…
Reference in New Issue
Block a user