diff options
| author | Laurenz <laurmaedje@gmail.com> | 2022-12-21 00:16:07 +0100 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2022-12-21 00:26:20 +0100 |
| commit | ee732468c7487c81aa6470571077988b75d36ebb (patch) | |
| tree | e0361bb75b8bbc3359b711f4009e165459d66248 /macros/src/func.rs | |
| parent | 15cd273c82a96128a63781981a4405fcd2b1e846 (diff) | |
Document text category
Diffstat (limited to 'macros/src/func.rs')
| -rw-r--r-- | macros/src/func.rs | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/macros/src/func.rs b/macros/src/func.rs index 73522f0e..1f6bb626 100644 --- a/macros/src/func.rs +++ b/macros/src/func.rs @@ -109,15 +109,13 @@ pub fn section(docs: &mut String, title: &str, level: usize) -> Option<String> { /// Parse the example section. pub fn example(docs: &mut String, level: usize) -> Option<String> { - Some( - section(docs, "Example", level)? - .lines() - .skip_while(|line| !line.contains("```")) - .skip(1) - .take_while(|line| !line.contains("```")) - .collect::<Vec<_>>() - .join("\n"), - ) + let section = section(docs, "Example", level)?; + let mut s = unscanny::Scanner::new(§ion); + let count = s.eat_while('`').len(); + let term = "`".repeat(count); + let text = s.eat_until(term.as_str()).trim(); + s.expect(term.as_str()); + Some(text.into()) } /// Parse the parameter section. |
