scripts/generate-documentation.js
async function buildMarkdown() {
  const docs = await documentation.build([filename], { shallow: true })
  const functions = docs[0].members.instance.filter(x => x.kind === 'function')

  for (const fn of functions) {
    if (typeof calls[fn.name] === 'function') {
      const res = await calls[fn.name]()
      const tables = buildReturnTables(res, `${fn.name}()`)

      fn.description.children.push({
        type: 'paragraph',
        children: [
          {
            type: 'strong',
            children: [
              {
                type: 'text',
                value: 'Returns'
              }
            ]
          }
        ]
      })

      for (const table of tables) {
        // Add table title
        fn.description.children.push({
          type: 'paragraph',
          children: [
            {
              type: 'inlineCode',
              value: table.name
            }
          ]
        })

        // Add table
        fn.description.children.push({
          type: 'table',
          align: ['left', 'left'],
          children: [{
            type: 'tableRow',
            children: [
              {
                type: 'tableCell',
                children: [{
                  type: 'text',
                  value: 'Property'
                }]
              },
              {
                type: 'tableCell',
                children: [{
                  type: 'text',
                  value: 'Type'
                }]
              },
              {
                type: 'tableCell',
                children: [{
                  type: 'text',
                  value: 'Note'
                }]
              }
            ]
          }, ...table.keys.map(key => ({
            type: 'tableRow',
            children: [
              {
                type: 'tableCell',
                children: [{
                  type: 'inlineCode',
                  value: key.name
                }]
              },
              {
                type: 'tableCell',
                children: [{
                  type: 'text',
                  value: key.type
                }]
              },
              {
                type: 'tableCell',
                children: [{
                  type: 'text',
                  value: notes[key.name] || ''
                }]
              }
            ]
          }))]
        })
      }
    }
  }

  const markdown = await documentation.formats.md(docs, { markdownToc: true })
  fs.writeFileSync(path.join(process.cwd(), 'API.md'), markdown)
  process.exit()
}
async function buildMarkdown() {
  const docs = await documentation.build([filename], { shallow: true })
  const functions = docs[0].members.instance.filter(x => x.kind === 'function')

  for (const fn of functions) {
    if (typeof calls[fn.name] === 'function') {
      const res = await calls[fn.name]()
      const tables = buildReturnTables(res, `${fn.name}()`)

      fn.description.children.push({
        type: 'paragraph',
        children: [
          {
            type: 'strong',
            children: [
              {
                type: 'text',
                value: 'Returns'
              }
            ]
          }
        ]
      })

      for (const table of tables) {
        // Add table title
        fn.description.children.push({
          type: 'paragraph',
          children: [
            {
              type: 'inlineCode',
              value: table.name
            }
          ]
        })

        // Add table
        fn.description.children.push({
          type: 'table',
          align: ['left', 'left'],
          children: [{
            type: 'tableRow',
            children: [
              {
                type: 'tableCell',
                children: [{
                  type: 'text',
                  value: 'Property'
                }]
              },
              {
                type: 'tableCell',
                children: [{
                  type: 'text',
                  value: 'Type'
                }]
              },
              {
                type: 'tableCell',
                children: [{
                  type: 'text',
                  value: 'Note'
                }]
              }
            ]
          }, ...table.keys.map(key => ({
            type: 'tableRow',
            children: [
              {
                type: 'tableCell',
                children: [{
                  type: 'inlineCode',
                  value: key.name
                }]
              },
              {
                type: 'tableCell',
                children: [{
                  type: 'text',
                  value: key.type
                }]
              },
              {
                type: 'tableCell',
                children: [{
                  type: 'text',
                  value: notes[key.name] || ''
                }]
              }
            ]
          }))]
        })
      }
    }
  }

  const markdown = await documentation.formats.md(docs, { markdownToc: true })
  fs.writeFileSync(path.join(process.cwd(), 'API.md'), markdown)
  process.exit()
}
async function buildMarkdown ( ) { const docs = await documentation . build ( [ filename ] , { shallow : true } ) const functions = docs [ 0 ] . members . instance . filter ( x => x . kind === 'function' ) for ( const fn of functions ) { if ( typeof calls [ fn . name ] === 'function' ) { const res = await calls [ fn . name ] ( ) const tables = buildReturnTables ( res , ` ${ fn . name } ` ) fn . description . children . push ( { type : 'paragraph' , children : [ { type : 'strong' , children : [ { type : 'text' , value : 'Returns' } ] } ] } ) for ( const table of tables ) { // Add table title fn . description . children . push ( { type : 'paragraph' , children : [ { type : 'inlineCode' , value : table . name } ] } ) // Add table fn . description . children . push ( { type : 'table' , align : [ 'left' , 'left' ] , children : [ { type : 'tableRow' , children : [ { type : 'tableCell' , children : [ { type : 'text' , value : 'Property' } ] } , { type : 'tableCell' , children : [ { type : 'text' , value : 'Type' } ] } , { type : 'tableCell' , children : [ { type : 'text' , value : 'Note' } ] } ] } , ... table . keys . map ( key => ( { type : 'tableRow' , children : [ { type : 'tableCell' , children : [ { type : 'inlineCode' , value : key . name } ] } , { type : 'tableCell' , children : [ { type : 'text' , value : key . type } ] } , { type : 'tableCell' , children : [ { type : 'text' , value : notes [ key . name ] || '' } ] } ] } ) ) ] } ) } } } const markdown = await documentation . formats . md ( docs , { markdownToc : true } ) fs . writeFileSync ( path . join ( process . cwd ( ) , 'API.md' ) , markdown ) process . exit ( ) }
Traverse through all functions inside in the wrapper and build Markdown tables
describing each endpoint return value.
Traverse through all functions inside in the wrapper and build Markdown tables describing each endpoint return value .