@@ -28,18 +28,30 @@ editLink: false
2828 * @param pages The pages to write.
2929 */
3030export async function writePages ( pages : RawApiDocsPage [ ] ) : Promise < void > {
31- await Promise . all ( pages . map ( writePage ) ) ;
31+ const registryHints : Record < string , string > = Object . fromEntries (
32+ pages . flatMap ( ( page ) =>
33+ page . methods . map ( ( method ) => [
34+ method . name ,
35+ `${ page . camelTitle } .${ method . name } ` ,
36+ ] )
37+ )
38+ ) ;
39+ await Promise . all ( pages . map ( ( page ) => writePage ( page , registryHints ) ) ) ;
3240}
3341
3442/**
3543 * Writes the api docs page and data for the given module to the correct location.
3644 *
3745 * @param page The page to write.
46+ * @param registryHints Hints for accessing standalone functions via module registry.
3847 */
39- async function writePage ( page : RawApiDocsPage ) : Promise < void > {
48+ async function writePage (
49+ page : RawApiDocsPage ,
50+ registryHints : Record < string , string > = { }
51+ ) : Promise < void > {
4052 try {
4153 await writePageMarkdown ( page ) ;
42- await writePageData ( page ) ;
54+ await writePageData ( page , registryHints ) ;
4355 } catch ( error ) {
4456 throw new Error ( `Error writing page ${ page . title } ` , { cause : error } ) ;
4557 }
@@ -103,20 +115,34 @@ async function writePageMarkdown(page: RawApiDocsPage): Promise<void> {
103115 * Writes the api docs data for the given module to correct location.
104116 *
105117 * @param page The page to write.
118+ * @param registryHints Hints for accessing standalone functions via module registry.
106119 */
107- async function writePageData ( page : RawApiDocsPage ) : Promise < void > {
120+ async function writePageData (
121+ page : RawApiDocsPage ,
122+ registryHints : Record < string , string > = { }
123+ ) : Promise < void > {
108124 const { camelTitle, methods } = page ;
109125 const pageData : Record < string , ApiDocsMethod > = Object . fromEntries (
110126 await Promise . all (
111127 methods . map ( async ( method ) => [ method . name , await toMethodData ( method ) ] )
112128 )
113129 ) ;
130+ const prioritizedRegistryHints = {
131+ ...registryHints ,
132+ // own module > other modules
133+ ...Object . fromEntries (
134+ methods . map ( ( method ) => [ method . name , `${ camelTitle } .${ method . name } ` ] )
135+ ) ,
136+ // utils always win
137+ getDefaultRefDate : 'defaultRefDate' ,
138+ setDefaultRefDate : 'setDefaultRefDate' ,
139+ } ;
114140
115141 const refreshFunctions : Record < string , string > = Object . fromEntries (
116142 await Promise . all (
117143 methods . map ( async ( method ) => [
118144 method . name ,
119- await toRefreshFunction ( method ) ,
145+ await toRefreshFunction ( method , prioritizedRegistryHints ) ,
120146 ] )
121147 )
122148 ) ;
@@ -218,12 +244,13 @@ export function extractSummaryDefault(description: string): string | undefined {
218244}
219245
220246export async function toRefreshFunction (
221- method : RawApiDocsMethod
247+ method : RawApiDocsMethod ,
248+ registryHints : Record < string , string > = { }
222249) : Promise < string > {
223250 const { name, signatures } = method ;
224251 const signatureData = required ( signatures . at ( - 1 ) , 'method signature' ) ;
225252 const { examples } = signatureData ;
226253
227254 const exampleCode = examples . join ( '\n' ) ;
228- return await toRefreshableCode ( name , exampleCode ) ;
255+ return await toRefreshableCode ( name , exampleCode , registryHints ) ;
229256}
0 commit comments