@@ -255,6 +255,54 @@ interface FunctionDefinition {
255255}
256256
257257async function generateFunctions ( sdk : ActionSdk ) : Promise < string > {
258+ function getParamInfo ( signature : string , paramName : string ) : { optional : boolean ; type : string | null } {
259+ const paramsMatch = signature . match ( / \( ( .* ) \) / s) ;
260+ if ( ! paramsMatch ) {
261+ return { optional : false , type : null } ;
262+ }
263+
264+ const params = paramsMatch [ 1 ] . split ( "," ) ;
265+
266+ for ( const param of params ) {
267+ const trimmed = param . trim ( ) ;
268+
269+ // Match: name?: type OR name: type
270+ const match = trimmed . match ( new RegExp ( `${ paramName } \s*(\\?)?\\s*:\\s*(.+)` ) ) ;
271+ if ( match ) {
272+ const isOptional = match [ 1 ] === "?" ;
273+ const type = match [ 2 ] . trim ( ) ;
274+
275+ return {
276+ optional : isOptional ,
277+ type
278+ } ;
279+ }
280+ }
281+
282+ return { optional : false , type : null } ;
283+ }
284+
285+ function generateMarkdownTable ( headers : string [ ] , rows : string [ ] [ ] ) {
286+ const headerRow = `| ${ headers . join ( ' | ' ) } |` ;
287+ const separator = `| ${ headers . map ( ( ) => '---' ) . join ( ' | ' ) } |` ;
288+ const bodyRows = rows . map ( row => `| ${ row . join ( ' | ' ) } |` ) ;
289+
290+ return [ headerRow , separator , ...bodyRows ] . join ( '\n' ) ;
291+ }
292+ function getLinkFromType ( typeName ?: string ) {
293+ if ( ! typeName || ! typeName . startsWith ( "GLS_" ) ) return typeName
294+ switch ( typeName ) { // Some edge cases
295+ case "SHIPMENT_UNIT_SERVICE" : {
296+ typeName = "SHIPMENT_UNIT$Service"
297+ break
298+ }
299+ }
300+ const normalizedName = typeName . toLowerCase ( )
301+ . replace ( / - / g, "_" )
302+ . replace ( / \$ / g, "" ) ;
303+ return `[${ typeName } ](./types.mdx#${ normalizedName } )`
304+ }
305+
258306 async function loadFunctions ( modules : Record < string , ( ) => Promise < unknown > > ) {
259307 for ( const path in modules ) {
260308
@@ -343,9 +391,33 @@ All shipment functions accept a common set of parameters in addition to their ty
343391 displayMessages : definition . displayMessage
344392 }
345393
394+ const headers = [ "Parameter" , "Name" , "Type" , "Required" , "Description" ]
395+
396+ let rows = [ ]
397+
398+ definition . parameters . forEach ( param => {
399+ const paramInfo = getParamInfo ( definition . signature , param . runtimeName ) ;
400+
401+ paramInfo . type = getLinkFromType ( paramInfo . type ) ;
402+
403+ rows . push ( [
404+ param . runtimeName ,
405+ param . name [ 0 ] . content ,
406+ paramInfo . type ?. replace ( / \| / g, "\\|" ) || "Unknown" ,
407+ paramInfo . optional ? "No" : "Yes" ,
408+ param . description [ 0 ] . content
409+ ] )
410+ } )
411+
346412 generatedDoc += `
347413### \`${ definition . runtimeName } \`
348414
415+ ${ generateMarkdownTable ( headers , rows ) }
416+
417+ Return Type: ${ getLinkFromType ( definition . signature . split ( "):" ) [ 1 ] . trim ( ) ) }
418+
419+ #
420+
349421${ definition . documentation ?. at ( 0 ) . content || "" }
350422
351423<FunctionCard definition={
0 commit comments