@@ -23,18 +23,27 @@ editLink: false
2323 * @param pages The pages to write.
2424 */
2525export async function writePages ( pages : RawApiDocsPage [ ] ) : Promise < void > {
26- await Promise . all ( pages . map ( writePage ) ) ;
26+ const registryHints : Record < string , string > = Object . fromEntries (
27+ pages . flatMap ( ( page ) =>
28+ page . methods . map ( ( method ) => [ method . name , page . camelTitle ] )
29+ )
30+ ) ;
31+ await Promise . all ( pages . map ( ( page ) => writePage ( page , registryHints ) ) ) ;
2732}
2833
2934/**
3035 * Writes the api docs page and data for the given module to the correct location.
3136 *
3237 * @param page The page to write.
38+ * @param registryHints Hints for accessing SMF via module registry.
3339 */
34- async function writePage ( page : RawApiDocsPage ) : Promise < void > {
40+ async function writePage (
41+ page : RawApiDocsPage ,
42+ registryHints : Record < string , string > = { }
43+ ) : Promise < void > {
3544 try {
3645 await writePageMarkdown ( page ) ;
37- await writePageData ( page ) ;
46+ await writePageData ( page , registryHints ) ;
3847 } catch ( error ) {
3948 throw new Error ( `Error writing page ${ page . title } ` , { cause : error } ) ;
4049 }
@@ -98,20 +107,29 @@ async function writePageMarkdown(page: RawApiDocsPage): Promise<void> {
98107 * Writes the api docs data for the given module to correct location.
99108 *
100109 * @param page The page to write.
110+ * @param registryHints Hints for accessing SMF via module registry.
101111 */
102- async function writePageData ( page : RawApiDocsPage ) : Promise < void > {
112+ async function writePageData (
113+ page : RawApiDocsPage ,
114+ registryHints : Record < string , string > = { }
115+ ) : Promise < void > {
103116 const { camelTitle, methods } = page ;
104117 const pageData : Record < string , ApiDocsMethod > = Object . fromEntries (
105118 await Promise . all (
106119 methods . map ( async ( method ) => [ method . name , await toMethodData ( method ) ] )
107120 )
108121 ) ;
122+ const priorizedRegistryHints = {
123+ ...registryHints ,
124+ // own module > other modules
125+ ...Object . fromEntries ( methods . map ( ( method ) => [ method . name , camelTitle ] ) ) ,
126+ } ;
109127
110128 const refreshFunctions : Record < string , string > = Object . fromEntries (
111129 await Promise . all (
112130 methods . map ( async ( method ) => [
113131 method . name ,
114- await toRefreshFunction ( method ) ,
132+ await toRefreshFunction ( method , priorizedRegistryHints ) ,
115133 ] )
116134 )
117135 ) ;
@@ -213,12 +231,13 @@ export function extractSummaryDefault(description: string): string | undefined {
213231}
214232
215233export async function toRefreshFunction (
216- method : RawApiDocsMethod
234+ method : RawApiDocsMethod ,
235+ registryHints : Record < string , string > = { }
217236) : Promise < string > {
218237 const { name, signatures } = method ;
219238 const signatureData = required ( signatures . at ( - 1 ) , 'method signature' ) ;
220239 const { examples } = signatureData ;
221240
222241 const exampleCode = examples . join ( '\n' ) ;
223- return await toRefreshableCode ( name , exampleCode ) ;
242+ return await toRefreshableCode ( name , exampleCode , registryHints ) ;
224243}
0 commit comments