mirror of
https://github.com/oceanprotocol-archive/squid-js.git
synced 2024-02-02 15:31:51 +01:00
Matthias Kretschmann
5e569f5f5d
* initializing the TypeDoc app changed with typedoc v0.16+ * adapt the script to generate the spec used in our docs to the new syntax
57 lines
1.5 KiB
JavaScript
Executable File
57 lines
1.5 KiB
JavaScript
Executable File
#!/usr/bin/env node
|
|
|
|
/* eslint-disable security/detect-non-literal-fs-filename */
|
|
|
|
const fs = require('fs')
|
|
const TypeDoc = require('typedoc')
|
|
const typescript = require('typescript')
|
|
const ora = require('ora')
|
|
const squidJsPackage = require('../package.json')
|
|
|
|
const { description, version } = squidJsPackage
|
|
|
|
// Setup our paths, relative to project root
|
|
const outPath = './dist/squid-js.json'
|
|
const files = ['./src/squid.ts']
|
|
|
|
// specifically point to tsconfig, otherwise TypeDoc fails
|
|
const config = typescript.findConfigFile('./tsconfig.js', typescript.sys.fileExists)
|
|
|
|
const generateJson = () => {
|
|
const spinnerTypedoc = ora('Generating TypeDoc json...').start()
|
|
|
|
// Setup our TypeDoc app
|
|
const app = new TypeDoc.Application()
|
|
app.options.addReader(new TypeDoc.TSConfigReader())
|
|
app.options.addReader(new TypeDoc.TypeDocReader())
|
|
|
|
app.bootstrap({
|
|
tsconfig: config
|
|
})
|
|
|
|
const src = app.expandInputFiles(files)
|
|
const project = app.convert(src)
|
|
|
|
// Generate the JSON file
|
|
app.generateJson(project, outPath)
|
|
|
|
// Parse and modify json output
|
|
const jsonOrig = JSON.parse(fs.readFileSync(outPath, 'utf8'))
|
|
|
|
const jsonFinal = {
|
|
info: {
|
|
title: 'Squid-js',
|
|
description,
|
|
version,
|
|
sourceUrl: 'https://github.com/oceanprotocol/squid-js/blob/master/'
|
|
},
|
|
...jsonOrig
|
|
}
|
|
|
|
fs.writeFileSync(outPath, JSON.stringify(jsonFinal, null, 4))
|
|
|
|
spinnerTypedoc.succeed('Generated TypeDoc json.')
|
|
}
|
|
|
|
generateJson()
|