MCPcopy Create free account
hub / github.com/csskit/csskit / convert_inherited

Function convert_inherited

crates/csskit_spec_generator/src/codegen.rs:227–242  ·  view source on GitHub ↗

Convert the "inherited" field from spec into a DeclarationMetadata attribute

(inherited: &str)

Source from the content-addressed store, hash-verified

225
226/// Convert the "inherited" field from spec into a DeclarationMetadata attribute
227fn convert_inherited(inherited: &str) -> Option<TokenStream> {
228 let normalized = inherited.replace('\n', " ").to_lowercase();
229 match normalized.as_str() {
230 "no" => None,
231 "yes" => Some(quote! { inherits }),
232 // "n/a" means not applicable - treat as Unknown
233 "n/a" => Some(quote! { inherits = Unknown }),
234 // "no (but see prose)" means complex inheritance rules - treat as no
235 s if s.starts_with("no") && s.contains("prose") => None,
236 // Catch-all for complex cases like "see individual properties"
237 _ => {
238 eprintln!("Warning: Unknown inherits value: {}", inherited);
239 Some(quote! { inherits = Unknown })
240 }
241 }
242}
243
244/// Convert the "percentages" field from spec into a DeclarationMetadata attribute
245fn convert_percentages(percentages: &str) -> Option<TokenStream> {

Callers 1

generate_property_typeFunction · 0.85

Calls 3

replaceMethod · 0.80
as_strMethod · 0.45
containsMethod · 0.45

Tested by

no test coverage detected