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

Function convert_applies_to

crates/csskit_spec_generator/src/codegen.rs:305–329  ·  view source on GitHub ↗

Convert the "applies to" field from spec into a DeclarationMetadata attribute

(applies_to: &str)

Source from the content-addressed store, hash-verified

303
304/// Convert the "applies to" field from spec into a DeclarationMetadata attribute
305fn convert_applies_to(applies_to: &str) -> Option<TokenStream> {
306 let result = match applies_to.replace('\n', " ").to_lowercase().as_str() {
307 "n/a" => return None,
308 "absolutely positioned boxes" => quote! { applies_to = AbsPos },
309 "all elements and text" => quote! { applies_to = Elements | Text },
310 "all elements and pseudo-elements" => quote! { applies_to = Elements | PseudoElements },
311 "all elements."
312 | "all elements"
313 | "all enabled elements"
314 | "all elements (but see prose)"
315 | "all elements, but not pseudo-elements"
316 | "all elements, but see prose" => {
317 quote! { applies_to = Elements }
318 }
319 "text" => quote! { applies_to = Text },
320 "block containers" | "block-level boxes" | "block-level elements" | "block container elements" => {
321 quote! { applies_to = Block }
322 }
323 "flex containers" => quote! { applies_to = Flex },
324 "grid containers" => quote! { applies_to = Grid },
325 "floats" => quote! { applies_to = Float },
326 _ => quote! { applies_to = Unknown },
327 };
328 Some(result)
329}
330
331/// Convert the "animation type" field from spec into a DeclarationMetadata attribute
332fn convert_animation_type(animation_type: &str) -> Option<TokenStream> {

Callers 1

generate_property_typeFunction · 0.85

Calls 2

replaceMethod · 0.80
as_strMethod · 0.45

Tested by

no test coverage detected