(code: &str, base_url: &str, properties: &[&PropertyDefinition])
| 139 | } |
| 140 | |
| 141 | fn 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 | |
| 168 | fn add_blank_lines_between_properties(code: &str) -> String { |
| 169 | let lines: Vec<&str> = code.lines().collect(); |
no test coverage detected