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

Method add_one

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

Adds the given line to this printer. Depending on what's in the line, this may or may not print the line immediately to the underlying buffer. If the line starts or is part of an existing code snippet, then the lines will get buffered until the code snippet is complete.

(&mut self, line: InputDocstringLine<'src>)

Source from the content-addressed store, hash-verified

294 /// of an existing code snippet, then the lines will get buffered until
295 /// the code snippet is complete.
296 fn add_one(&mut self, line: InputDocstringLine<'src>) -> FormatResult<()> {
297 // Just pass through the line as-is without looking for a code snippet
298 // when docstring code formatting is disabled. And also when we are
299 // formatting a code snippet so as to avoid arbitrarily nested code
300 // snippet formatting. We avoid this because it's likely quite tricky
301 // to get right 100% of the time, although perhaps not impossible. It's
302 // not clear that it's worth the effort to support.
303 if !self.f.options().docstring_code().is_enabled() || self.f.context().docstring().is_some()
304 {
305 return self.print_one(&line.as_output());
306 }
307 self.code_example.add(line, &mut self.action_queue);
308 self.run_action_queue()
309 }
310
311 /// Process any actions in this printer's queue until the queue is empty.
312 fn run_action_queue(&mut self) -> FormatResult<()> {

Callers 1

add_iterMethod · 0.80

Calls 9

docstring_codeMethod · 0.80
print_oneMethod · 0.80
as_outputMethod · 0.80
run_action_queueMethod · 0.80
is_enabledMethod · 0.45
optionsMethod · 0.45
docstringMethod · 0.45
contextMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected