(&self)
| 122 | } else { |
| 123 | HashMap::new() |
| 124 | }; |
| 125 | Self { doc, value_vars } |
| 126 | } |
| 127 | |
| 128 | fn write(&self) -> String { |
| 129 | let mut out = String::new(); |
| 130 | if let Some(root) = &self.doc.scene.root { |
| 131 | out.push_str("$root = "); |
| 132 | out.push('@'); |
| 133 | out.push_str(self.doc.scene.key_name_or_id(*root).as_ref()); |
| 134 | out.push('\n'); |
| 135 | } |
| 136 | |
| 137 | let mut dedupe_items = self |
| 138 | .value_vars |
| 139 | .iter() |
| 140 | .map(|(value, name)| (name.as_str(), value.as_str())) |
| 141 | .collect::<Vec<_>>(); |
| 142 | dedupe_items.sort_by(|a, b| a.0.cmp(b.0)); |
| 143 | for (name, value) in dedupe_items { |
| 144 | out.push('$'); |
| 145 | out.push_str(name); |
| 146 | out.push_str(" = "); |
| 147 | out.push_str(value); |
| 148 | out.push('\n'); |
| 149 | } |
| 150 | |
| 151 | if !out.is_empty() { |
| 152 | out.push('\n'); |
| 153 | } |
| 154 | |
| 155 | for node in self.doc.scene.nodes.iter() { |
| 156 | self.write_node(node, &mut out); |
| 157 | out.push('\n'); |
| 158 | } |
| 159 | |
| 160 | out |
no test coverage detected