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

Method indented_code

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

Returns the code collected in this example as a sequence of lines. The lines returned have the minimum indentation stripped from their prefix in-place. Based on the definition of minimum indentation, this implies there is at least one line in the slice returned with no whitespace prefix.

(&mut self)

Source from the content-addressed store, hash-verified

1096 /// implies there is at least one line in the slice returned with no
1097 /// whitespace prefix.
1098 fn indented_code(&mut self) -> &[CodeExampleLine<'src>] {
1099 let Some(min_indent) = self.min_indent else {
1100 return &[];
1101 };
1102 for line in &mut self.lines {
1103 line.code = if line.original.line.trim().is_empty() {
1104 ""
1105 } else {
1106 min_indent.trim_start_str(line.original.line)
1107 };
1108 }
1109 &self.lines
1110 }
1111
1112 /// Attempts to add the given line from a docstring to the reStructuredText
1113 /// code snippet being collected.

Callers 1

codeMethod · 0.80

Calls 2

trim_start_strMethod · 0.80
is_emptyMethod · 0.45

Tested by

no test coverage detected