Skip to content

Commit 4bd2c67

Browse files
committed
proper format docs, remove extra indent & append ; at enf of fn
1 parent 0255088 commit 4bd2c67

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

crates/doc/src/builder.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ use rayon::prelude::*;
1212
use solar::interface::source_map::FileName;
1313
use std::{
1414
cmp::Ordering,
15-
fmt::Debug,
1615
fs,
1716
path::{Path, PathBuf},
1817
};

crates/doc/src/parser/item.rs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,20 @@ impl ParseItem {
8181
///
8282
/// The parameter should be the full source file where this parse item originated from.
8383
pub fn with_code(mut self, source: &str) -> Self {
84-
self.code = source[self.source.range()].to_string();
84+
let mut code = source[self.source.range()].to_string();
85+
86+
// Special function case, add `;` at the end of definition;
87+
if let ParseSource::Function(_) = self.source {
88+
code.push(';');
89+
}
90+
91+
// Remove extra indent from docs.
92+
self.code = code
93+
.lines()
94+
.map(|line| line.strip_prefix(" ").unwrap_or(line))
95+
.collect::<Vec<_>>()
96+
.join("\n");
97+
8598
self
8699
}
87100

0 commit comments

Comments
 (0)