normalize_docstring

Function normalize_docstring 

Source
pub fn normalize_docstring(doc: &str) -> String
Expand description

Normalize a docstring by trimming outer whitespace and dedenting.

Implements Python’s inspect.cleandoc() behavior:

  1. Trim leading/trailing whitespace from the entire string
  2. Find minimum indentation of non-empty lines (skip first line)
  3. Remove that indentation from all lines

§Examples

let doc = r#"
    First line
    Second line
        Indented line
"#;
let normalized = normalize_docstring(doc);
assert_eq!(normalized, "First line\nSecond line\n    Indented line");