mirror of
https://github.com/denoland/deno.git
synced 2024-12-27 17:49:08 -05:00
fix(doc): remove JSDoc comment truncation (#6031)
This commit is contained in:
parent
d8c681d37a
commit
a4567e0e01
1 changed files with 7 additions and 11 deletions
|
@ -35,7 +35,7 @@ pub fn format_details(node: doc::DocNode) -> String {
|
|||
|
||||
let js_doc = node.js_doc.clone();
|
||||
if let Some(js_doc) = js_doc {
|
||||
details.push_str(&format_jsdoc(js_doc, false, 1));
|
||||
details.push_str(&format_jsdoc(js_doc, 1));
|
||||
}
|
||||
details.push_str("\n");
|
||||
|
||||
|
@ -92,7 +92,7 @@ fn format_(doc_nodes: Vec<doc::DocNode>, indent: i64) -> String {
|
|||
for node in sorted {
|
||||
output.push_str(&format_signature(&node, indent));
|
||||
if let Some(js_doc) = node.js_doc {
|
||||
output.push_str(&format_jsdoc(js_doc, true, indent));
|
||||
output.push_str(&format_jsdoc(js_doc, indent));
|
||||
}
|
||||
output.push_str("\n");
|
||||
if DocNodeKind::Namespace == node.kind {
|
||||
|
@ -308,19 +308,15 @@ fn add_indent(string: String, indent: i64) -> String {
|
|||
}
|
||||
|
||||
// TODO: this should use some sort of markdown to console parser.
|
||||
fn format_jsdoc(jsdoc: String, truncated: bool, indent: i64) -> String {
|
||||
let mut lines = jsdoc.split("\n\n").map(|line| line.replace("\n", " "));
|
||||
fn format_jsdoc(jsdoc: String, indent: i64) -> String {
|
||||
let lines = jsdoc.split("\n\n").map(|line| line.replace("\n", " "));
|
||||
|
||||
let mut js_doc = String::new();
|
||||
|
||||
if truncated {
|
||||
let first_line = lines.next().unwrap_or_else(|| "".to_string());
|
||||
js_doc.push_str(&add_indent(format!("{}\n", first_line), indent + 1));
|
||||
} else {
|
||||
for line in lines {
|
||||
js_doc.push_str(&add_indent(format!("{}\n", line), indent + 1));
|
||||
}
|
||||
for line in lines {
|
||||
js_doc.push_str(&add_indent(format!("{}\n", line), indent + 1));
|
||||
}
|
||||
|
||||
format!("{}", colors::gray(js_doc))
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue