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

Function fix_formatting

crates/csskit_spec_generator/src/codegen.rs:141–166  ·  view source on GitHub ↗
(code: &str, base_url: &str, properties: &[&PropertyDefinition])

Source from the content-addressed store, hash-verified

139}
140
141fn fix_formatting(code: &str, base_url: &str, properties: &[&PropertyDefinition]) -> String {
142 let mut result = String::new();
143 let base_url_no_slash = base_url.trim_end_matches('/');
144
145 for line in code.lines() {
146 let mut fixed_line = line.to_string();
147
148 if fixed_line.starts_with("///") && !fixed_line.starts_with("/// ") {
149 fixed_line = fixed_line.replacen("///", "/// ", 1);
150 }
151
152 if fixed_line.contains(base_url_no_slash) {
153 for prop in properties {
154 let property_id = if prop.name == "--*" { "defining-variables" } else { &prop.name };
155 let wrong = format!("{}#{}", base_url_no_slash, property_id);
156 let correct = format!("{}#{}", base_url, property_id);
157 fixed_line = fixed_line.replace(&wrong, &correct);
158 }
159 }
160
161 result.push_str(&fixed_line);
162 result.push('\n');
163 }
164
165 result
166}
167
168fn add_blank_lines_between_properties(code: &str) -> String {
169 let lines: Vec<&str> = code.lines().collect();

Callers 1

generate_spec_moduleFunction · 0.85

Calls 2

replaceMethod · 0.80
containsMethod · 0.45

Tested by

no test coverage detected