@@ -7,6 +7,7 @@ const alternateUrl = 'https://qcalendar.netlify.app'
77interface Api {
88 components : Component [ ]
99 directives : Directive [ ]
10+ utils : Util [ ]
1011}
1112
1213interface Component {
@@ -29,6 +30,21 @@ interface Directive {
2930 }
3031}
3132
33+ interface Util {
34+ name : string
35+ api : {
36+ meta : Meta
37+ methods : Record < string , Method >
38+ }
39+ }
40+
41+ interface Method {
42+ addedIn ?: string
43+ desc : string
44+ params ?: Record < string , ParamApi > | null
45+ returns : ReturnApi
46+ }
47+
3248interface EventApi {
3349 params ?: Record < string , ParamApi >
3450 desc : string
@@ -62,10 +78,18 @@ interface ValueApi {
6278
6379interface ParamApi {
6480 type : string
81+ tsType ?: string
6582 desc : string
83+ required ?: boolean
6684 examples ?: string [ ]
6785}
6886
87+ interface ReturnApi {
88+ type : string
89+ tsType ?: string
90+ desc : string
91+ }
92+
6993interface ScopeApi {
7094 type : string
7195 desc : string
@@ -215,7 +239,7 @@ export function generate({ api, compact = false }: { api: Api; compact?: boolean
215239 module : 'qcalendar' ,
216240 symbol : name ,
217241 } ,
218- required : false , // Directive is never required
242+ required : false ,
219243 description : `${ name } - QCalendar directive` ,
220244 'doc-url' : meta . docsUrl || alternateUrl ,
221245 }
@@ -234,6 +258,30 @@ export function generate({ api, compact = false }: { api: Api; compact?: boolean
234258 }
235259 return result
236260 } ) ,
261+
262+ // Add utils section
263+ utils : api . utils . map ( ( { api : { meta, methods } , name } ) => ( {
264+ name,
265+ methods : Object . entries ( methods ) . map ( ( [ methodName , method ] ) => ( {
266+ name : methodName ,
267+ addedIn : method . addedIn ,
268+ description : method . desc ,
269+ params :
270+ method . params &&
271+ Object . entries ( method . params ) . map ( ( [ paramName , param ] ) => ( {
272+ name : paramName ,
273+ type : resolveType ( param ) ,
274+ description : getDescription ( param ) ,
275+ 'doc-url' : meta . docsUrl || alternateUrl ,
276+ } ) ) ,
277+ returns : {
278+ type : resolveType ( method . returns ) ,
279+ description : getDescription ( method . returns ) ,
280+ 'doc-url' : meta . docsUrl || alternateUrl ,
281+ } ,
282+ } ) ) ,
283+ 'doc-url' : meta . docsUrl || alternateUrl ,
284+ } ) ) ,
237285 } ,
238286 } ,
239287 } )
0 commit comments