Add a (multi-line) documentation comment.
(&mut self, contents: impl AsRef<str>)
| 169 | |
| 170 | /// Add a (multi-line) documentation comment. |
| 171 | pub fn doc_comment(&mut self, contents: impl AsRef<str>) { |
| 172 | assert!(matches!(self.lang, Language::Rust)); |
| 173 | parse_multiline(contents.as_ref()) |
| 174 | .iter() |
| 175 | .map(|l| { |
| 176 | if l.is_empty() { |
| 177 | "///".into() |
| 178 | } else { |
| 179 | format!("/// {l}") |
| 180 | } |
| 181 | }) |
| 182 | .for_each(|s| self.line(s.as_str())); |
| 183 | } |
| 184 | |
| 185 | /// Add a brace-delimited block that begins with `start`: i.e., `<start> { |
| 186 | /// <f()> }`. This properly indents the contents of the block. |