@@ -56,7 +56,6 @@ export function buildSite(builds: Build[], siteConfig: SiteConfig, properties: P
56
56
57
57
const seen = new Set < string > ( ) ;
58
58
const allItems : DocItemWithContext [ ] = [ ] ;
59
- const topLevelItems : DocItemWithContext [ ] = [ ] ;
60
59
const pages : Record < string , DocItemWithContext [ ] > = { } ;
61
60
62
61
for ( let { input, output } of builds ) {
@@ -67,8 +66,7 @@ export function buildSite(builds: Build[], siteConfig: SiteConfig, properties: P
67
66
const build = { input, output, deref } ;
68
67
69
68
for ( const { ast : file } of Object . values ( output . sources ) ) {
70
- // Some files may appear in different builds but we only use one.
71
- if ( seen . has ( file . src ) ) continue ;
69
+ const isNewItem = ! seen . has ( file . src ) ;
72
70
seen . add ( file . src ) ;
73
71
74
72
for ( const topLevelItem of file . nodes ) {
@@ -80,18 +78,16 @@ export function buildSite(builds: Build[], siteConfig: SiteConfig, properties: P
80
78
__item_context : { page, item : topLevelItem as DocItemWithContext , file, build } ,
81
79
} ) ;
82
80
83
- topLevelItems . push ( withContext ) ;
84
- allItems . push ( withContext ) ;
85
-
86
81
if ( page !== undefined ) {
87
82
( pages [ page ] ??= [ ] ) . push ( withContext ) ;
88
83
}
89
84
90
85
for ( const item of findAll ( docItemTypes , topLevelItem ) ) {
86
+ if ( isNewItem ) allItems . push ( item as DocItemWithContext ) ;
91
87
if ( item === topLevelItem ) continue ;
92
88
const contract = topLevelItem . nodeType === 'ContractDefinition' ? topLevelItem : undefined ;
93
- const __item_context : DocItemContext = { page, item : item as DocItemWithContext , contract, file, build } ;
94
- allItems . push ( Object . assign ( item , { __item_context } ) ) ;
89
+ const __item_context : DocItemContext = { page, item : item as DocItemWithContext , contract, file, build } ;
90
+ Object . assign ( item , { __item_context } ) ;
95
91
}
96
92
}
97
93
}
@@ -105,7 +101,7 @@ export function buildSite(builds: Build[], siteConfig: SiteConfig, properties: P
105
101
}
106
102
107
103
return {
108
- items : topLevelItems ,
104
+ items : allItems . filter ( i => i [ DOC_ITEM_CONTEXT ] . contract === undefined ) ,
109
105
pages : Object . entries ( pages ) . map ( ( [ id , items ] ) => ( { id, items } ) ) ,
110
106
} ;
111
107
}
0 commit comments