mirror of
https://github.com/Myriad-Dreamin/tinymist.git
synced 2025-08-03 17:58:17 +00:00
fix: enclose fallback docs in code block (#828)
This commit is contained in:
parent
52a8d0e678
commit
5ce0a8feba
2 changed files with 20 additions and 7 deletions
|
@ -162,7 +162,20 @@ impl<'a> DocsChecker<'a> {
|
|||
Ok(c) => Ok(c),
|
||||
Err(e) => {
|
||||
let e = e.replace("`", "\\`");
|
||||
let fallback_docs = eco_format!("```\nfailed to parse docs: {e}\n```\n\n{docs}");
|
||||
let max_consecutive_backticks = docs
|
||||
.chars()
|
||||
.fold((0, 0), |(max, count), c| {
|
||||
if c == '`' {
|
||||
(max.max(count + 1), count + 1)
|
||||
} else {
|
||||
(max, 0)
|
||||
}
|
||||
})
|
||||
.0;
|
||||
let backticks = "`".repeat((max_consecutive_backticks + 1).max(3));
|
||||
let fallback_docs = eco_format!(
|
||||
"```\nfailed to parse docs: {e}\n```\n\n{backticks}typ\n{docs}\n{backticks}\n"
|
||||
);
|
||||
Err(DocString {
|
||||
docs: Some(fallback_docs),
|
||||
var_bounds: HashMap::new(),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue