Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: setup jsdoc for documentation #58

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions .jsdoc-conf.json
Original file line number Diff line number Diff line change
@@ -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
}
}
6 changes: 4 additions & 2 deletions dashboard/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -38,11 +39,12 @@
"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",
"nyc": "^15.1.0",
"prettier": "^2.3.0",
"sinon": "^11.1.1"
}
}
}
6 changes: 4 additions & 2 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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"
}
}
}
37 changes: 37 additions & 0 deletions npm/build-docs.js
Original file line number Diff line number Diff line change
@@ -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;
}
});
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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": {
Expand Down
6 changes: 4 additions & 2 deletions reporter/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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"
}
}
}