diff --git a/.jsdoc-conf.json b/.jsdoc-conf.json new file mode 100644 index 0000000..199fe52 --- /dev/null +++ b/.jsdoc-conf.json @@ -0,0 +1,36 @@ +{ + "plugins": [], + "recurseDepth": 10, + "source": { + "includePattern": ".+\\.js(doc|x)?$", + "excludePattern": "(^|\\/|\\\\)_", + "include": [ + "." + ], + "exclude": [ + "node_modules" + ] + }, + "sourceType": "module", + "tags": { + "allowUnknownTags": true, + "dictionaries": [ + "jsdoc", + "closure" + ] + }, + "templates": { + "cleverLinks": false, + "monospaceLinks": false + }, + "opts": { + "template": "./node_modules/postman-jsdoc-theme", + "encoding": "utf8", + "destination": "./out/docs", + "recurse": true + }, + "markdown": { + "parser": "gfm", + "hardwrap": false + } +} \ No newline at end of file diff --git a/dashboard/package.json b/dashboard/package.json index 43fe7c3..46d1981 100644 --- a/dashboard/package.json +++ b/dashboard/package.json @@ -15,7 +15,8 @@ "coverage": "npm run coverage:unit && npm run coverage:integration", "coverage:unit": "npm run test:unit && codecov", "coverage:integration": "npm run test:integration && codecov", - "dev": "nodemon ./server/index.js" + "dev": "nodemon ./server/index.js", + "build-docs": "jsdoc --configure ../.jsdoc-conf.json" }, "author": "elit-altum", "license": "Apache-2.0", @@ -38,6 +39,7 @@ "eslint-plugin-node": "^11.1.0", "eslint-plugin-prettier": "^3.4.0", "eslint-plugin-promise": "^5.1.0", + "jsdoc": "^3.6.10", "mocha": "^8.4.0", "mock-require": "^3.0.3", "nodemon": "^2.0.7", @@ -45,4 +47,4 @@ "prettier": "^2.3.0", "sinon": "^11.1.1" } -} +} \ No newline at end of file diff --git a/frontend/package.json b/frontend/package.json index 4f02bac..90fa028 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -12,7 +12,8 @@ "coverage:unit": "exit 0", "coverage:integration": "exit 0", "dev": "next .", - "build": "next build . && next export ." + "build": "next build . && next export .", + "build-docs": "jsdoc --configure ../.jsdoc-conf.json" }, "author": "elit-altum", "license": "Apache-2.0", @@ -46,9 +47,10 @@ "eslint-plugin-promise": "^5.1.0", "eslint-plugin-react": "^7.24.0", "eslint-plugin-react-hooks": "^4.2.0", + "jsdoc": "^3.6.10", "nodemon": "^2.0.7", "postcss": "^8.3.5", "prettier": "^2.3.0", "tailwindcss": "^2.2.4" } -} +} \ No newline at end of file diff --git a/npm/build-docs.js b/npm/build-docs.js new file mode 100644 index 0000000..93119ca --- /dev/null +++ b/npm/build-docs.js @@ -0,0 +1,37 @@ +const fs = require('fs'); +const join = require('path').join; +const cp = require('child_process'); +const os = require('os'); +const async = require('async'); +const packageDirs = ['reporter', 'dashboard', 'frontend']; + +function buildDocs(modPath, done) { + // ensure path has package.json + if (!fs.existsSync(join(modPath, 'package.json'))) { + return; + } + + console.log(`\nBuilding js-docs in ${modPath}\n`); + + // npm binary based on OS + var npmCmd = os.platform().startsWith('win') ? 'npm.cmd' : 'npm'; + + cp.spawn(npmCmd, ['run', 'build-docs'], { + env: process.env, + cwd: modPath, + stdio: 'inherit', + }).on('exit', (code) => { + if (code) { + // eslint-disable-next-line prettier/prettier,max-len + done(new Error(`Error while building. Process exited with code ${code}`)); + } + + done(); + }); +} + +async.mapLimit(packageDirs, 1, buildDocs, (err) => { + if (err) { + throw err; + } +}); diff --git a/package.json b/package.json index 9b020f4..f5490d0 100644 --- a/package.json +++ b/package.json @@ -12,7 +12,8 @@ "coverage": "node npm/coverage.js", "dev:dashboard": "nodemon ./dashboard/server/index.js", "dev:client": "next ./frontend", - "build": "node npm/build.js" + "build": "node npm/build.js", + "build-docs": "node npm/build-docs.js" }, "keywords": [ "newman", @@ -39,7 +40,9 @@ "eslint-plugin-node": "^11.1.0", "eslint-plugin-prettier": "^3.4.0", "eslint-plugin-promise": "^5.1.0", + "jsdoc": "^3.6.10", "nodemon": "^2.0.12", + "postman-jsdoc-theme": "^0.0.3", "prettier": "^2.3.0" }, "dependencies": { diff --git a/reporter/package.json b/reporter/package.json index 2992767..17d23c9 100644 --- a/reporter/package.json +++ b/reporter/package.json @@ -14,7 +14,8 @@ "test:integration": "exit 0", "coverage": "npm run coverage:unit && npm run coverage:integration", "coverage:unit": "npm run test:unit && codecov", - "coverage:integration": "exit 0" + "coverage:integration": "exit 0", + "build-docs": "jsdoc --configure ../.jsdoc-conf.json" }, "author": "elit-altum", "license": "Apache-2.0", @@ -35,10 +36,11 @@ "eslint-plugin-node": "^11.1.0", "eslint-plugin-prettier": "^3.4.0", "eslint-plugin-promise": "^5.1.0", + "jsdoc": "^3.6.10", "mocha": "^8.4.0", "mock-require": "^3.0.3", "nyc": "^15.1.0", "prettier": "^2.3.0", "sinon": "^11.1.1" } -} +} \ No newline at end of file