( code: &str, properties: &[&PropertyDefinition], should_comment_out: &HashSet<String>, )
| 190 | } |
| 191 | |
| 192 | fn 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 |
| 227 | fn convert_inherited(inherited: &str) -> Option<TokenStream> { |
no test coverage detected