11use super :: render_context:: RenderContext ;
22use super :: util:: * ;
3- use crate :: DeclarationDef ;
43use crate :: html:: ShortPath ;
54use crate :: js_doc:: JsDoc ;
65use crate :: js_doc:: JsDocTag ;
@@ -802,13 +801,10 @@ impl ModuleDocCtx {
802801
803802 let mut sections = Vec :: with_capacity ( 7 ) ;
804803
805- let ( deprecated, html) = if let Some ( decl) =
806- module_doc_nodes. iter ( ) . find_map ( |n| {
807- n. declarations
808- . iter ( )
809- . find ( |decl| matches ! ( decl. def, DeclarationDef :: ModuleDoc ) )
810- } ) {
811- let deprecated = decl. js_doc . tags . iter ( ) . find_map ( |tag| {
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| {
812808 if let JsDocTag :: Deprecated { doc } = tag {
813809 Some ( render_markdown (
814810 render_ctx,
@@ -820,11 +816,11 @@ impl ModuleDocCtx {
820816 }
821817 } ) ;
822818
823- if let Some ( examples) = jsdoc_examples ( render_ctx, & decl . js_doc ) {
819+ if let Some ( examples) = jsdoc_examples ( render_ctx, js_doc) {
824820 sections. push ( examples) ;
825821 }
826822
827- let html = jsdoc_body_to_html ( render_ctx, & decl . js_doc , summary) ;
823+ let html = jsdoc_body_to_html ( render_ctx, js_doc, summary) ;
828824
829825 ( deprecated, html)
830826 } else {
@@ -896,6 +892,7 @@ mod test {
896892 use crate :: interface:: InterfaceDef ;
897893 use crate :: js_doc:: JsDoc ;
898894 use crate :: node:: DeclarationKind ;
895+ use crate :: node:: Document ;
899896
900897 struct EmptyResolver ;
901898
@@ -984,46 +981,51 @@ mod test {
984981 IndexMap :: from ( [
985982 (
986983 ModuleSpecifier :: parse ( "file:///a.ts" ) . unwrap ( ) ,
987- vec ! [
988- Symbol :: interface(
989- "foo" . into( ) ,
990- false ,
991- Location :: default ( ) ,
992- DeclarationKind :: Export ,
993- JsDoc :: default ( ) ,
994- InterfaceDef {
995- def_name: None ,
996- extends: vec![ ] ,
997- constructors: vec![ ] ,
998- methods: vec![ ] ,
999- properties: vec![ ] ,
1000- call_signatures: vec![ ] ,
1001- index_signatures: vec![ ] ,
1002- type_params: Box :: new( [ ] ) ,
1003- } ,
1004- ) ,
1005- Symbol :: interface(
1006- "bar" . into( ) ,
1007- false ,
1008- Location :: default ( ) ,
1009- DeclarationKind :: Export ,
1010- JsDoc :: default ( ) ,
1011- InterfaceDef {
1012- def_name: None ,
1013- extends: vec![ ] ,
1014- constructors: vec![ ] ,
984+ Document {
985+ module_doc : Default :: default ( ) ,
986+ symbols : vec ! [
987+ Symbol :: interface(
988+ "foo" . into( ) ,
989+ false ,
990+ Location :: default ( ) ,
991+ DeclarationKind :: Export ,
992+ JsDoc :: default ( ) ,
993+ InterfaceDef {
994+ def_name: None ,
995+ extends: vec![ ] ,
996+ constructors: vec![ ] ,
997+ methods: vec![ ] ,
998+ properties: vec![ ] ,
999+ call_signatures: vec![ ] ,
1000+ index_signatures: vec![ ] ,
1001+ type_params: Box :: new( [ ] ) ,
1002+ } ,
1003+ ) ,
1004+ Symbol :: interface(
1005+ "bar" . into( ) ,
1006+ false ,
1007+ Location :: default ( ) ,
1008+ DeclarationKind :: Export ,
1009+ JsDoc :: default ( ) ,
1010+ InterfaceDef {
1011+ def_name: None ,
1012+ extends: vec![ ] ,
1013+ constructors: vec![ ] ,
10151014 methods: vec![ ] ,
10161015 properties: vec![ ] ,
10171016 call_signatures: vec![ ] ,
10181017 index_signatures: vec![ ] ,
10191018 type_params: Box :: new( [ ] ) ,
10201019 } ,
10211020 ) ,
1022- ] ,
1021+ ] ,
1022+ } ,
10231023 ) ,
10241024 (
10251025 ModuleSpecifier :: parse ( "file:///b.ts" ) . unwrap ( ) ,
1026- vec ! [ Symbol :: interface(
1026+ Document {
1027+ module_doc : Default :: default ( ) ,
1028+ symbols : vec ! [ Symbol :: interface(
10271029 "baz" . into( ) ,
10281030 false ,
10291031 Location :: default ( ) ,
@@ -1040,6 +1042,7 @@ mod test {
10401042 type_params: Box :: new( [ ] ) ,
10411043 } ,
10421044 ) ] ,
1045+ } ,
10431046 ) ,
10441047 ] ) ,
10451048 None ,
0 commit comments