Add placeholder doc strings for style prefixes
This commit is contained in:
parent
c8b452d411
commit
6f30d6b4d0
1 changed files with 109 additions and 26 deletions
|
@ -27,7 +27,7 @@ pub fn style_helpers(input: TokenStream) -> TokenStream {
|
||||||
fn generate_methods() -> Vec<TokenStream2> {
|
fn generate_methods() -> Vec<TokenStream2> {
|
||||||
let mut methods = Vec::new();
|
let mut methods = Vec::new();
|
||||||
|
|
||||||
for (prefix, auto_allowed, fields) in box_prefixes() {
|
for (prefix, auto_allowed, fields, prefix_doc_string) in box_prefixes() {
|
||||||
methods.push(generate_custom_value_setter(
|
methods.push(generate_custom_value_setter(
|
||||||
prefix,
|
prefix,
|
||||||
if auto_allowed {
|
if auto_allowed {
|
||||||
|
@ -38,7 +38,7 @@ fn generate_methods() -> Vec<TokenStream2> {
|
||||||
&fields,
|
&fields,
|
||||||
));
|
));
|
||||||
|
|
||||||
for (suffix, length_tokens, doc_string) in box_suffixes() {
|
for (suffix, length_tokens, suffix_doc_string) in box_suffixes() {
|
||||||
if suffix != "auto" || auto_allowed {
|
if suffix != "auto" || auto_allowed {
|
||||||
methods.push(generate_predefined_setter(
|
methods.push(generate_predefined_setter(
|
||||||
prefix,
|
prefix,
|
||||||
|
@ -46,7 +46,7 @@ fn generate_methods() -> Vec<TokenStream2> {
|
||||||
&fields,
|
&fields,
|
||||||
&length_tokens,
|
&length_tokens,
|
||||||
false,
|
false,
|
||||||
doc_string,
|
&format!("{prefix_doc_string}\n\n{suffix_doc_string}"),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -57,7 +57,7 @@ fn generate_methods() -> Vec<TokenStream2> {
|
||||||
&fields,
|
&fields,
|
||||||
&length_tokens,
|
&length_tokens,
|
||||||
true,
|
true,
|
||||||
doc_string,
|
&format!("{prefix_doc_string}\n\n{suffix_doc_string}"),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -103,7 +103,7 @@ fn generate_predefined_setter(
|
||||||
fields: &Vec<TokenStream2>,
|
fields: &Vec<TokenStream2>,
|
||||||
length_tokens: &TokenStream2,
|
length_tokens: &TokenStream2,
|
||||||
negate: bool,
|
negate: bool,
|
||||||
doc_string: &'static str,
|
doc_string: &str,
|
||||||
) -> TokenStream2 {
|
) -> TokenStream2 {
|
||||||
let (negation_prefix, negation_token) = if negate {
|
let (negation_prefix, negation_token) = if negate {
|
||||||
("neg_", quote! { - })
|
("neg_", quote! { - })
|
||||||
|
@ -169,19 +169,40 @@ fn generate_custom_value_setter(
|
||||||
method
|
method
|
||||||
}
|
}
|
||||||
|
|
||||||
fn box_prefixes() -> Vec<(&'static str, bool, Vec<TokenStream2>)> {
|
fn box_prefixes() -> Vec<(&'static str, bool, Vec<TokenStream2>, &'static str)> {
|
||||||
vec![
|
vec![
|
||||||
("w", true, vec![quote! { size.width }]),
|
("w", true, vec![quote! { size.width }], "todo!(docstring)"),
|
||||||
("h", true, vec![quote! { size.height }]),
|
("h", true, vec![quote! { size.height }], "todo!(docstring)"),
|
||||||
(
|
(
|
||||||
"size",
|
"size",
|
||||||
true,
|
true,
|
||||||
vec![quote! {size.width}, quote! {size.height}],
|
vec![quote! {size.width}, quote! {size.height}],
|
||||||
|
"todo!(docstring)",
|
||||||
|
),
|
||||||
|
(
|
||||||
|
"min_w",
|
||||||
|
true,
|
||||||
|
vec![quote! { min_size.width }],
|
||||||
|
"todo!(docstring)",
|
||||||
|
),
|
||||||
|
(
|
||||||
|
"min_h",
|
||||||
|
true,
|
||||||
|
vec![quote! { min_size.height }],
|
||||||
|
"todo!(docstring)",
|
||||||
|
),
|
||||||
|
(
|
||||||
|
"max_w",
|
||||||
|
true,
|
||||||
|
vec![quote! { max_size.width }],
|
||||||
|
"todo!(docstring)",
|
||||||
|
),
|
||||||
|
(
|
||||||
|
"max_h",
|
||||||
|
true,
|
||||||
|
vec![quote! { max_size.height }],
|
||||||
|
"todo!(docstring)",
|
||||||
),
|
),
|
||||||
("min_w", true, vec![quote! { min_size.width }]),
|
|
||||||
("min_h", true, vec![quote! { min_size.height }]),
|
|
||||||
("max_w", true, vec![quote! { max_size.width }]),
|
|
||||||
("max_h", true, vec![quote! { max_size.height }]),
|
|
||||||
(
|
(
|
||||||
"m",
|
"m",
|
||||||
true,
|
true,
|
||||||
|
@ -191,21 +212,34 @@ fn box_prefixes() -> Vec<(&'static str, bool, Vec<TokenStream2>)> {
|
||||||
quote! { margin.left },
|
quote! { margin.left },
|
||||||
quote! { margin.right },
|
quote! { margin.right },
|
||||||
],
|
],
|
||||||
|
"todo!(docstring)",
|
||||||
|
),
|
||||||
|
("mt", true, vec![quote! { margin.top }], "todo!(docstring)"),
|
||||||
|
(
|
||||||
|
"mb",
|
||||||
|
true,
|
||||||
|
vec![quote! { margin.bottom }],
|
||||||
|
"todo!(docstring)",
|
||||||
),
|
),
|
||||||
("mt", true, vec![quote! { margin.top }]),
|
|
||||||
("mb", true, vec![quote! { margin.bottom }]),
|
|
||||||
(
|
(
|
||||||
"my",
|
"my",
|
||||||
true,
|
true,
|
||||||
vec![quote! { margin.top }, quote! { margin.bottom }],
|
vec![quote! { margin.top }, quote! { margin.bottom }],
|
||||||
|
"todo!(docstring)",
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
"mx",
|
"mx",
|
||||||
true,
|
true,
|
||||||
vec![quote! { margin.left }, quote! { margin.right }],
|
vec![quote! { margin.left }, quote! { margin.right }],
|
||||||
|
"todo!(docstring)",
|
||||||
|
),
|
||||||
|
("ml", true, vec![quote! { margin.left }], "todo!(docstring)"),
|
||||||
|
(
|
||||||
|
"mr",
|
||||||
|
true,
|
||||||
|
vec![quote! { margin.right }],
|
||||||
|
"todo!(docstring)",
|
||||||
),
|
),
|
||||||
("ml", true, vec![quote! { margin.left }]),
|
|
||||||
("mr", true, vec![quote! { margin.right }]),
|
|
||||||
(
|
(
|
||||||
"p",
|
"p",
|
||||||
false,
|
false,
|
||||||
|
@ -215,32 +249,81 @@ fn box_prefixes() -> Vec<(&'static str, bool, Vec<TokenStream2>)> {
|
||||||
quote! { padding.left },
|
quote! { padding.left },
|
||||||
quote! { padding.right },
|
quote! { padding.right },
|
||||||
],
|
],
|
||||||
|
"todo!(docstring)",
|
||||||
|
),
|
||||||
|
(
|
||||||
|
"pt",
|
||||||
|
false,
|
||||||
|
vec![quote! { padding.top }],
|
||||||
|
"todo!(docstring)",
|
||||||
|
),
|
||||||
|
(
|
||||||
|
"pb",
|
||||||
|
false,
|
||||||
|
vec![quote! { padding.bottom }],
|
||||||
|
"todo!(docstring)",
|
||||||
),
|
),
|
||||||
("pt", false, vec![quote! { padding.top }]),
|
|
||||||
("pb", false, vec![quote! { padding.bottom }]),
|
|
||||||
(
|
(
|
||||||
"px",
|
"px",
|
||||||
false,
|
false,
|
||||||
vec![quote! { padding.left }, quote! { padding.right }],
|
vec![quote! { padding.left }, quote! { padding.right }],
|
||||||
|
"todo!(docstring)",
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
"py",
|
"py",
|
||||||
false,
|
false,
|
||||||
vec![quote! { padding.top }, quote! { padding.bottom }],
|
vec![quote! { padding.top }, quote! { padding.bottom }],
|
||||||
|
"todo!(docstring)",
|
||||||
|
),
|
||||||
|
(
|
||||||
|
"pl",
|
||||||
|
false,
|
||||||
|
vec![quote! { padding.left }],
|
||||||
|
"todo!(docstring)",
|
||||||
|
),
|
||||||
|
(
|
||||||
|
"pr",
|
||||||
|
false,
|
||||||
|
vec![quote! { padding.right }],
|
||||||
|
"todo!(docstring)",
|
||||||
|
),
|
||||||
|
("top", true, vec![quote! { inset.top }], "todo!(docstring)"),
|
||||||
|
(
|
||||||
|
"bottom",
|
||||||
|
true,
|
||||||
|
vec![quote! { inset.bottom }],
|
||||||
|
"todo!(docstring)",
|
||||||
|
),
|
||||||
|
(
|
||||||
|
"left",
|
||||||
|
true,
|
||||||
|
vec![quote! { inset.left }],
|
||||||
|
"todo!(docstring)",
|
||||||
|
),
|
||||||
|
(
|
||||||
|
"right",
|
||||||
|
true,
|
||||||
|
vec![quote! { inset.right }],
|
||||||
|
"todo!(docstring)",
|
||||||
),
|
),
|
||||||
("pl", false, vec![quote! { padding.left }]),
|
|
||||||
("pr", false, vec![quote! { padding.right }]),
|
|
||||||
("top", true, vec![quote! { inset.top }]),
|
|
||||||
("bottom", true, vec![quote! { inset.bottom }]),
|
|
||||||
("left", true, vec![quote! { inset.left }]),
|
|
||||||
("right", true, vec![quote! { inset.right }]),
|
|
||||||
(
|
(
|
||||||
"gap",
|
"gap",
|
||||||
false,
|
false,
|
||||||
vec![quote! { gap.width }, quote! { gap.height }],
|
vec![quote! { gap.width }, quote! { gap.height }],
|
||||||
|
"todo!(docstring)",
|
||||||
|
),
|
||||||
|
(
|
||||||
|
"gap_x",
|
||||||
|
false,
|
||||||
|
vec![quote! { gap.width }],
|
||||||
|
"todo!(docstring)",
|
||||||
|
),
|
||||||
|
(
|
||||||
|
"gap_y",
|
||||||
|
false,
|
||||||
|
vec![quote! { gap.height }],
|
||||||
|
"todo!(docstring)",
|
||||||
),
|
),
|
||||||
("gap_x", false, vec![quote! { gap.width }]),
|
|
||||||
("gap_y", false, vec![quote! { gap.height }]),
|
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue