MCPcopy Create free account
hub / github.com/astral-sh/ruff / add_iter

Method add_iter

crates/ruff_python_formatter/src/string/docstring.rs:272–288  ·  view source on GitHub ↗

Print all of the lines in the given iterator to this printer's formatter. Note that callers may treat the first line specially, such that the iterator given contains all lines except for the first.

(
        &mut self,
        mut lines: std::iter::Peekable<std::str::Split<'src, char>>,
    )

Source from the content-addressed store, hash-verified

270 /// Note that callers may treat the first line specially, such that the
271 /// iterator given contains all lines except for the first.
272 fn add_iter(
273 &mut self,
274 mut lines: std::iter::Peekable<std::str::Split<'src, char>>,
275 ) -> FormatResult<()> {
276 while let Some(line) = lines.next() {
277 let line = InputDocstringLine {
278 line,
279 offset: self.offset,
280 next: lines.peek().copied(),
281 };
282 // We know that the normalized string has \n line endings.
283 self.offset += line.line.text_len() + "\n".text_len();
284 self.add_one(line)?;
285 }
286 self.code_example.finish(&mut self.action_queue);
287 self.run_action_queue()
288 }
289
290 /// Adds the given line to this printer.
291 ///

Callers 1

formatFunction · 0.80

Calls 6

add_oneMethod · 0.80
run_action_queueMethod · 0.80
nextMethod · 0.45
peekMethod · 0.45
text_lenMethod · 0.45
finishMethod · 0.45

Tested by

no test coverage detected