1
0
mirror of https://github.com/oceanprotocol/docs.git synced 2024-11-26 19:49:26 +01:00

automate typedoc json generation for squid-js

This commit is contained in:
Matthias Kretschmann 2019-01-22 13:52:44 +01:00
parent 1f427aa3fe
commit a86b5e435d
Signed by: m
GPG Key ID: 606EEEF3C479A91F
5 changed files with 67 additions and 21937 deletions

1
.gitignore vendored
View File

@ -7,3 +7,4 @@ yarn-error.log
.DS_Store
.env
.env.*
data/squid-js.json

File diff suppressed because it is too large Load Diff

View File

@ -5,8 +5,8 @@
"author": "Ocean Protocol <devops@oceanprotocol.com>",
"license": "Apache-2.0",
"scripts": {
"build": "gatsby build",
"start": "gatsby develop",
"build": "npm run typedoc && gatsby build",
"start": "npm run typedoc && gatsby develop",
"ssr": "npm run build && serve -s public/",
"format:js": "prettier --write '**/*.{js,jsx}'",
"format:css": "prettier-stylelint --write --quiet 'src/**/*.{css,scss}'",
@ -19,7 +19,8 @@
"lint:yml": "prettier '**/*.{yml,yaml}' --list-different",
"lint": "run-p --continue-on-error lint:js lint:css lint:md lint:yml",
"test": "npm run lint",
"deploy": "./scripts/deploy.sh"
"deploy": "./scripts/deploy.sh",
"typedoc": "node ./scripts/typedoc.js"
},
"dependencies": {
"@oceanprotocol/art": "^2.1.0",

62
scripts/typedoc.js Normal file
View File

@ -0,0 +1,62 @@
#!/usr/bin/env node
/* eslint-disable no-console */
const fs = require('fs')
const typedoc = require('typedoc')
const typescript = require('typescript')
const squidJsPackage = require('../external/squid-js/package.json')
const { exec } = require('child_process')
const { description, version } = squidJsPackage
// Setup our paths, relative to project root
const outPath = './data/squid-js.json'
const files = ['./external/squid-js/src/squid.ts']
// specifically point to tsconfig, otherwise TypeDoc fails
const config = typescript.findConfigFile(
'./external/squid-js',
typescript.sys.fileExists
)
// npm install for squid-js
console.log('Installing submodule dependencies...')
const install = exec(
'cd ./external/squid-js && npm i && git checkout package-lock.json'
)
install.on('exit', () => {
generateJson()
})
const generateJson = () => {
console.log('Generating TypeDoc json...')
// Setup our TypeDoc app
const app = new typedoc.Application({
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')) // eslint-disable-line
const jsonFinal = {
info: {
title: 'Squid-js',
description,
version,
sourceUrl:
'https://github.com/oceanprotocol/squid-js/tree/develop/src/'
},
...jsonOrig
}
fs.writeFileSync(outPath, JSON.stringify(jsonFinal, null, 4)) // eslint-disable-line
}

View File

@ -1,7 +0,0 @@
./node_modules/typedoc/bin/typedoc \
--json ./external/squid-js/squid-js.json ./external/squid-js/src/squid.ts \
--excludePrivate \
--excludeExternals \
--excludeProtected \
--target ES6