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

Function comment_out_properties

crates/csskit_spec_generator/src/codegen.rs:192–224  ·  view source on GitHub ↗
(
	code: &str,
	properties: &[&PropertyDefinition],
	should_comment_out: &HashSet<String>,
)

Source from the content-addressed store, hash-verified

190}
191
192fn comment_out_properties(
193 code: &str,
194 properties: &[&PropertyDefinition],
195 should_comment_out: &HashSet<String>,
196) -> String {
197 let lines: Vec<&str> = code.lines().collect();
198 let mut result = Vec::new();
199 let mut in_commented_property = false;
200
201 for line in lines.iter() {
202 if line.starts_with("/// Represents the style value for") {
203 in_commented_property = properties
204 .iter()
205 .any(|prop| should_comment_out.contains(&prop.name) && line.contains(&format!("`{}`", prop.name)));
206 }
207
208 if in_commented_property {
209 if line.trim().is_empty() {
210 result.push(String::new());
211 } else {
212 result.push(format!("// {}", line));
213 }
214
215 if line.starts_with("pub enum ") || line.starts_with("pub struct ") {
216 in_commented_property = false;
217 }
218 } else {
219 result.push(line.to_string());
220 }
221 }
222
223 result.join("\n")
224}
225
226/// Convert the "inherited" field from spec into a DeclarationMetadata attribute
227fn convert_inherited(inherited: &str) -> Option<TokenStream> {

Callers 1

generate_spec_moduleFunction · 0.85

Calls 4

collectMethod · 0.80
iterMethod · 0.80
containsMethod · 0.45
is_emptyMethod · 0.45

Tested by

no test coverage detected