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:
parent
1f427aa3fe
commit
a86b5e435d
1
.gitignore
vendored
1
.gitignore
vendored
@ -7,3 +7,4 @@ yarn-error.log
|
|||||||
.DS_Store
|
.DS_Store
|
||||||
.env
|
.env
|
||||||
.env.*
|
.env.*
|
||||||
|
data/squid-js.json
|
||||||
|
21927
data/squid-js.json
21927
data/squid-js.json
File diff suppressed because it is too large
Load Diff
@ -5,8 +5,8 @@
|
|||||||
"author": "Ocean Protocol <devops@oceanprotocol.com>",
|
"author": "Ocean Protocol <devops@oceanprotocol.com>",
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "gatsby build",
|
"build": "npm run typedoc && gatsby build",
|
||||||
"start": "gatsby develop",
|
"start": "npm run typedoc && gatsby develop",
|
||||||
"ssr": "npm run build && serve -s public/",
|
"ssr": "npm run build && serve -s public/",
|
||||||
"format:js": "prettier --write '**/*.{js,jsx}'",
|
"format:js": "prettier --write '**/*.{js,jsx}'",
|
||||||
"format:css": "prettier-stylelint --write --quiet 'src/**/*.{css,scss}'",
|
"format:css": "prettier-stylelint --write --quiet 'src/**/*.{css,scss}'",
|
||||||
@ -19,7 +19,8 @@
|
|||||||
"lint:yml": "prettier '**/*.{yml,yaml}' --list-different",
|
"lint:yml": "prettier '**/*.{yml,yaml}' --list-different",
|
||||||
"lint": "run-p --continue-on-error lint:js lint:css lint:md lint:yml",
|
"lint": "run-p --continue-on-error lint:js lint:css lint:md lint:yml",
|
||||||
"test": "npm run lint",
|
"test": "npm run lint",
|
||||||
"deploy": "./scripts/deploy.sh"
|
"deploy": "./scripts/deploy.sh",
|
||||||
|
"typedoc": "node ./scripts/typedoc.js"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@oceanprotocol/art": "^2.1.0",
|
"@oceanprotocol/art": "^2.1.0",
|
||||||
|
62
scripts/typedoc.js
Normal file
62
scripts/typedoc.js
Normal 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
|
||||||
|
}
|
@ -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
|
|
Loading…
Reference in New Issue
Block a user