Skip to content

Commit 02c8aed

Browse files
committed
fmt
1 parent fc1fdc5 commit 02c8aed

12 files changed

Lines changed: 100 additions & 93 deletions

File tree

examples/ddoc/main.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,8 @@ async fn run() -> anyhow::Result<()> {
223223
});
224224

225225
if let Some(filter) = filter {
226-
merged_doc.symbols = find_nodes_by_name_recursively(merged_doc.symbols, &filter);
226+
merged_doc.symbols =
227+
find_nodes_by_name_recursively(merged_doc.symbols, &filter);
227228
}
228229

229230
if json {

src/diagnostics.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -402,8 +402,7 @@ impl DiagnosticDocNodeVisitor<'_, '_> {
402402
| DeclarationDef::Namespace(..)
403403
| DeclarationDef::TypeAlias(..)
404404
| DeclarationDef::Variable(..) => true,
405-
DeclarationDef::Import(..)
406-
| DeclarationDef::Reference(..) => false,
405+
DeclarationDef::Import(..) | DeclarationDef::Reference(..) => false,
407406
}
408407
}
409408

src/html/jsdoc.rs

Lines changed: 44 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -801,31 +801,30 @@ impl ModuleDocCtx {
801801

802802
let mut sections = Vec::with_capacity(7);
803803

804-
let (deprecated, html) = if let Some(js_doc) =
805-
render_ctx.ctx.module_docs.get(short_path)
806-
{
807-
let deprecated = js_doc.tags.iter().find_map(|tag| {
808-
if let JsDocTag::Deprecated { doc } = tag {
809-
Some(render_markdown(
810-
render_ctx,
811-
doc.as_deref().unwrap_or_default(),
812-
false,
813-
))
814-
} else {
815-
None
816-
}
817-
});
804+
let (deprecated, html) =
805+
if let Some(js_doc) = render_ctx.ctx.module_docs.get(short_path) {
806+
let deprecated = js_doc.tags.iter().find_map(|tag| {
807+
if let JsDocTag::Deprecated { doc } = tag {
808+
Some(render_markdown(
809+
render_ctx,
810+
doc.as_deref().unwrap_or_default(),
811+
false,
812+
))
813+
} else {
814+
None
815+
}
816+
});
818817

819-
if let Some(examples) = jsdoc_examples(render_ctx, js_doc) {
820-
sections.push(examples);
821-
}
818+
if let Some(examples) = jsdoc_examples(render_ctx, js_doc) {
819+
sections.push(examples);
820+
}
822821

823-
let html = jsdoc_body_to_html(render_ctx, js_doc, summary);
822+
let html = jsdoc_body_to_html(render_ctx, js_doc, summary);
824823

825-
(deprecated, html)
826-
} else {
827-
(None, None)
828-
};
824+
(deprecated, html)
825+
} else {
826+
(None, None)
827+
};
829828

830829
if render_symbols {
831830
let partitions_by_kind = super::partition::partition_nodes_by_kind(
@@ -1011,13 +1010,13 @@ mod test {
10111010
def_name: None,
10121011
extends: vec![],
10131012
constructors: vec![],
1014-
methods: vec![],
1015-
properties: vec![],
1016-
call_signatures: vec![],
1017-
index_signatures: vec![],
1018-
type_params: Box::new([]),
1019-
},
1020-
),
1013+
methods: vec![],
1014+
properties: vec![],
1015+
call_signatures: vec![],
1016+
index_signatures: vec![],
1017+
type_params: Box::new([]),
1018+
},
1019+
),
10211020
],
10221021
},
10231022
),
@@ -1026,22 +1025,22 @@ mod test {
10261025
Document {
10271026
module_doc: Default::default(),
10281027
symbols: vec![Symbol::interface(
1029-
"baz".into(),
1030-
false,
1031-
Location::default(),
1032-
DeclarationKind::Export,
1033-
JsDoc::default(),
1034-
InterfaceDef {
1035-
def_name: None,
1036-
extends: vec![],
1037-
constructors: vec![],
1038-
methods: vec![],
1039-
properties: vec![],
1040-
call_signatures: vec![],
1041-
index_signatures: vec![],
1042-
type_params: Box::new([]),
1043-
},
1044-
)],
1028+
"baz".into(),
1029+
false,
1030+
Location::default(),
1031+
DeclarationKind::Export,
1032+
JsDoc::default(),
1033+
InterfaceDef {
1034+
def_name: None,
1035+
extends: vec![],
1036+
constructors: vec![],
1037+
methods: vec![],
1038+
properties: vec![],
1039+
call_signatures: vec![],
1040+
index_signatures: vec![],
1041+
type_params: Box::new([]),
1042+
},
1043+
)],
10451044
},
10461045
),
10471046
]),

src/html/pages.rs

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -254,16 +254,9 @@ impl IndexCtx {
254254
.doc_nodes
255255
.iter()
256256
.map(|(short_path, _nodes)| {
257-
let doc = ctx
258-
.module_docs
259-
.get(short_path)
260-
.and_then(|js_doc| {
261-
crate::html::jsdoc::jsdoc_body_to_html(
262-
&render_ctx,
263-
js_doc,
264-
true,
265-
)
266-
});
257+
let doc = ctx.module_docs.get(short_path).and_then(|js_doc| {
258+
crate::html::jsdoc::jsdoc_body_to_html(&render_ctx, js_doc, true)
259+
});
267260

268261
let title = short_path.display_name();
269262

src/html/symbols/mod.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -584,8 +584,9 @@ impl SymbolInnerCtx {
584584
},
585585
))
586586
}
587-
DeclarationDef::Import(..)
588-
| DeclarationDef::Reference(..) => unreachable!(),
587+
DeclarationDef::Import(..) | DeclarationDef::Reference(..) => {
588+
unreachable!()
589+
}
589590
});
590591

591592
let references = decl

src/html/usage.rs

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -185,19 +185,15 @@ fn get_identifier_for_file(
185185
) -> String {
186186
let maybe_identifier =
187187
if let Some(file) = ctx.get_current_resolve().get_file() {
188-
ctx
189-
.ctx
190-
.module_docs
191-
.get(file)
192-
.and_then(|js_doc| {
193-
js_doc.tags.iter().find_map(|tag| {
194-
if let JsDocTag::Module { name } = tag {
195-
name.as_ref().map(|name| name.to_string())
196-
} else {
197-
None
198-
}
199-
})
188+
ctx.ctx.module_docs.get(file).and_then(|js_doc| {
189+
js_doc.tags.iter().find_map(|tag| {
190+
if let JsDocTag::Module { name } = tag {
191+
name.as_ref().map(|name| name.to_string())
192+
} else {
193+
None
194+
}
200195
})
196+
})
201197
} else if let Some(context_name) = custom_file_identifier {
202198
Some(context_name.to_string())
203199
} else {

src/node.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,9 @@ impl Default for Symbol {
362362
declaration_kind: DeclarationKind::Private,
363363
location: Location::default(),
364364
js_doc: JsDoc::default(),
365-
def: DeclarationDef::Reference(ReferenceDef { target: Default::default() }),
365+
def: DeclarationDef::Reference(ReferenceDef {
366+
target: Default::default(),
367+
}),
366368
}],
367369
}
368370
}

src/parser.rs

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,10 @@ use crate::Location;
4646
use crate::diagnostics::DiagnosticsCollector;
4747
use crate::diagnostics::DocDiagnostic;
4848
use crate::js_doc::JsDoc;
49-
use crate::node::{DeclarationDef, Document};
5049
use crate::node::DeclarationKind;
5150
use crate::node::NamespaceDef;
5251
use crate::node::ReferenceDef;
52+
use crate::node::{DeclarationDef, Document};
5353
use crate::ts_type::PropertyDef;
5454
use crate::ts_type::TsTypeDef;
5555
use crate::ts_type::TsTypeDefKind;
@@ -450,7 +450,9 @@ impl<'a> DocParser<'a> {
450450
match module {
451451
Module::Js(_) | Module::Json(_) | Module::Wasm(_) => {
452452
let module_info = self.get_module_info(module.specifier())?;
453-
let mut document = self.get_symbols_for_module_info(module_info)?.unwrap_or_default();
453+
let mut document = self
454+
.get_symbols_for_module_info(module_info)?
455+
.unwrap_or_default();
454456
let exports = module_info.exports(&self.root_symbol);
455457
for (export_name, export) in exports.resolved {
456458
let export = export.as_resolved_export();
@@ -529,7 +531,9 @@ impl<'a> DocParser<'a> {
529531

530532
Ok(document)
531533
}
532-
Module::Npm(_) | Module::Node(_) | Module::External(_) => Ok(Default::default()),
534+
Module::Npm(_) | Module::Node(_) | Module::External(_) => {
535+
Ok(Default::default())
536+
}
533537
}
534538
}
535539

@@ -1081,15 +1085,17 @@ impl<'a> DocParser<'a> {
10811085
module_info: ModuleInfoRef,
10821086
) -> Result<Option<Document>, DocError> {
10831087
match module_info {
1084-
ModuleInfoRef::Json(module) => Ok(
1085-
parse_json_module_symbol(
1086-
module.specifier(),
1087-
module.text_info().text_str(),
1088-
)
1089-
),
1088+
ModuleInfoRef::Json(module) => Ok(parse_json_module_symbol(
1089+
module.specifier(),
1090+
module.text_info().text_str(),
1091+
)),
10901092
ModuleInfoRef::Esm(module_info) => {
1091-
if let Some(mut document) = self.get_document_for_module_info_body(module_info) {
1092-
document.symbols.extend(self.get_symbols_for_module_imports(module_info)?);
1093+
if let Some(mut document) =
1094+
self.get_document_for_module_info_body(module_info)
1095+
{
1096+
document
1097+
.symbols
1098+
.extend(self.get_symbols_for_module_imports(module_info)?);
10931099

10941100
Ok(Some(document))
10951101
} else {
@@ -1105,7 +1111,8 @@ impl<'a> DocParser<'a> {
11051111
) -> Option<Document> {
11061112
let mut symbols = Vec::new();
11071113
// check to see if there is a module level JSDoc for the source file
1108-
let module_doc = if let Some(module_js_doc) = module_js_doc_for_source(module_info.source())
1114+
let module_doc = if let Some(module_js_doc) =
1115+
module_js_doc_for_source(module_info.source())
11091116
{
11101117
if let Some((js_doc, _range)) = module_js_doc {
11111118
js_doc

src/printer.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,8 @@ use crate::display::display_generator;
88
use crate::js_doc::JsDoc;
99
use crate::js_doc::JsDocTag;
1010
use crate::node::DeclarationDef;
11-
use crate::node::Document;
12-
use crate::node::DocNodeKind;
1311
use crate::node::DeclarationKind;
12+
use crate::node::Document;
1413
use crate::node::Symbol;
1514

1615
use deno_terminal::colors;

src/tests.rs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,10 @@ export function fooFn(a: number) {
349349
let actual = serde_json::to_value(&entries).unwrap();
350350
assert_eq!(actual, expected_json);
351351

352-
let doc = crate::node::Document { module_doc: Default::default(), symbols: entries };
352+
let doc = crate::node::Document {
353+
module_doc: Default::default(),
354+
symbols: entries,
355+
};
353356
assert!(
354357
DocPrinter::new(&doc, false, false)
355358
.to_string()
@@ -440,7 +443,10 @@ export { Hello } from "./reexport.ts";
440443
let actual = serde_json::to_value(&entries).unwrap();
441444
assert_eq!(actual, expected_json);
442445

443-
let doc = crate::node::Document { module_doc: Default::default(), symbols: entries };
446+
let doc = crate::node::Document {
447+
module_doc: Default::default(),
448+
symbols: entries,
449+
};
444450
let output = DocPrinter::new(&doc, false, false).to_string();
445451
assert!(output.contains("class Hello"));
446452
assert!(output.contains("interface Hello"));
@@ -501,7 +507,10 @@ async fn deep_reexports() {
501507
let actual = serde_json::to_value(&entries).unwrap();
502508
assert_eq!(actual, expected_json);
503509

504-
let doc = crate::node::Document { module_doc: Default::default(), symbols: entries };
510+
let doc = crate::node::Document {
511+
module_doc: Default::default(),
512+
symbols: entries,
513+
};
505514
assert!(
506515
DocPrinter::new(&doc, false, false)
507516
.to_string()

0 commit comments

Comments
 (0)