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,34 +801,30 @@ 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| {
812- if let JsDocTag :: Deprecated { doc } = tag {
813- Some ( render_markdown (
814- render_ctx,
815- doc. as_deref ( ) . unwrap_or_default ( ) ,
816- false ,
817- ) )
818- } else {
819- None
820- }
821- } ) ;
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+ } ) ;
822817
823- if let Some ( examples) = jsdoc_examples ( render_ctx, & decl . js_doc ) {
824- sections. push ( examples) ;
825- }
818+ if let Some ( examples) = jsdoc_examples ( render_ctx, js_doc) {
819+ sections. push ( examples) ;
820+ }
826821
827- let html = jsdoc_body_to_html ( render_ctx, & decl . js_doc , summary) ;
822+ let html = jsdoc_body_to_html ( render_ctx, js_doc, summary) ;
828823
829- ( deprecated, html)
830- } else {
831- ( None , None )
832- } ;
824+ ( deprecated, html)
825+ } else {
826+ ( None , None )
827+ } ;
833828
834829 if render_symbols {
835830 let partitions_by_kind = super :: partition:: partition_nodes_by_kind (
@@ -896,6 +891,7 @@ mod test {
896891 use crate :: interface:: InterfaceDef ;
897892 use crate :: js_doc:: JsDoc ;
898893 use crate :: node:: DeclarationKind ;
894+ use crate :: node:: Document ;
899895
900896 struct EmptyResolver ;
901897
@@ -984,26 +980,52 @@ mod test {
984980 IndexMap :: from ( [
985981 (
986982 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( ) ,
983+ Document {
984+ module_doc : Default :: default ( ) ,
985+ symbols : vec ! [
986+ Symbol :: interface(
987+ "foo" . into( ) ,
988+ false ,
989+ Location :: default ( ) ,
990+ DeclarationKind :: Export ,
991+ JsDoc :: default ( ) ,
992+ InterfaceDef {
993+ def_name: None ,
994+ extends: vec![ ] ,
995+ constructors: vec![ ] ,
996+ methods: vec![ ] ,
997+ properties: vec![ ] ,
998+ call_signatures: vec![ ] ,
999+ index_signatures: vec![ ] ,
1000+ type_params: Box :: new( [ ] ) ,
1001+ } ,
1002+ ) ,
1003+ Symbol :: interface(
1004+ "bar" . into( ) ,
1005+ false ,
1006+ Location :: default ( ) ,
1007+ DeclarationKind :: Export ,
1008+ JsDoc :: default ( ) ,
1009+ InterfaceDef {
1010+ def_name: None ,
1011+ extends: vec![ ] ,
1012+ constructors: vec![ ] ,
1013+ methods: vec![ ] ,
1014+ properties: vec![ ] ,
1015+ call_signatures: vec![ ] ,
1016+ index_signatures: vec![ ] ,
1017+ type_params: Box :: new( [ ] ) ,
1018+ } ,
1019+ ) ,
1020+ ] ,
1021+ } ,
1022+ ) ,
1023+ (
1024+ ModuleSpecifier :: parse ( "file:///b.ts" ) . unwrap ( ) ,
1025+ Document {
1026+ module_doc : Default :: default ( ) ,
1027+ symbols : vec ! [ Symbol :: interface(
1028+ "baz" . into( ) ,
10071029 false ,
10081030 Location :: default ( ) ,
10091031 DeclarationKind :: Export ,
@@ -1018,28 +1040,8 @@ mod test {
10181040 index_signatures: vec![ ] ,
10191041 type_params: Box :: new( [ ] ) ,
10201042 } ,
1021- ) ,
1022- ] ,
1023- ) ,
1024- (
1025- ModuleSpecifier :: parse ( "file:///b.ts" ) . unwrap ( ) ,
1026- vec ! [ Symbol :: interface(
1027- "baz" . into( ) ,
1028- false ,
1029- Location :: default ( ) ,
1030- DeclarationKind :: Export ,
1031- JsDoc :: default ( ) ,
1032- InterfaceDef {
1033- def_name: None ,
1034- extends: vec![ ] ,
1035- constructors: vec![ ] ,
1036- methods: vec![ ] ,
1037- properties: vec![ ] ,
1038- call_signatures: vec![ ] ,
1039- index_signatures: vec![ ] ,
1040- type_params: Box :: new( [ ] ) ,
1041- } ,
1042- ) ] ,
1043+ ) ] ,
1044+ } ,
10431045 ) ,
10441046 ] ) ,
10451047 None ,
0 commit comments