Skip to content

Commit

Permalink
Update src/main.rs
Browse files Browse the repository at this point in the history
Co-authored-by: pennae <82953136+pennae@users.noreply.github.com>
  • Loading branch information
infinisil and pennae authored Jul 20, 2023
1 parent e6ab792 commit 9618bf4
Showing 1 changed file with 4 additions and 15 deletions.
19 changes: 4 additions & 15 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,23 +175,12 @@ fn retrieve_doc_item(node: &AttrpathValue) -> Option<DocItem> {

/// Dedent everything but the first line, whose indentation gets fully removed all the time
fn process_doc(raw: &str) -> Option<String> {
let result = if let Some((first, rest)) = raw.split_once('\n') {
let mut result = String::new();
result.push_str(first.trim());
result.push('\n');
result.push_str(&dedent(rest));
result
} else {
raw.trim().to_owned()
let result: Cow<str> = match raw.split_once('\n') {
Some((first, rest)) => format!("{}\n{}", first.trim(), dedent(rest)).into(),
None => raw.into(),
};

let result = result.trim().to_owned();

if result.is_empty() {
None
} else {
Some(result)
}
Some(result.trim().to_owned()).filter(|s| !s.is_empty())
}

/// Dumb, mutable, hacky doc comment "parser".
Expand Down

0 comments on commit 9618bf4

Please sign in to comment.