Skip to content

Commit

Permalink
updated plugins to work correctly by calling jsdoc twice, once to col…
Browse files Browse the repository at this point in the history
…lect symbols, once to generate docs
  • Loading branch information
jannikac authored and kewisch committed Jun 13, 2024
1 parent e94faad commit bacc31f
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ docs/recur-tester.html
tools/vzic/
tools/tzdb/
tools/libical/
tools/jsdoc-symbols-temp.json
coverage/
temp.json
10 changes: 10 additions & 0 deletions jsdoc-prepare.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"source": {
"include": "lib/ical",
"includePattern": ".js$"
},
"plugins": ["tools/jsdoc-collect-types.cjs", "node_modules/jsdoc-tsimport-plugin/index.js"],
"opts": {
"destination": "docs/api/"
}
}
2 changes: 1 addition & 1 deletion jsdoc.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"include": "lib/ical",
"includePattern": ".js$"
},
"plugins": ["plugins/markdown", "tools/jsdoc-collect-types.cjs", "tools/jsdoc-ical.cjs", "node_modules/jsdoc-tsimport-plugin/index.js"],
"plugins": ["plugins/markdown", "tools/jsdoc-ical.cjs", "node_modules/jsdoc-tsimport-plugin/index.js"],
"opts": {
"encoding": "utf8",
"readme": "README.md",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
"test-all": "npm run test-unit && npm run test-acceptance && npm run test-performance && npm run test-browser",
"build": "rollup -c",
"lint": "eslint",
"jsdoc": "rm -rf docs/api && jsdoc --configure jsdoc.json --verbose",
"jsdoc": "rm -rf docs/api && jsdoc --configure jsdoc-prepare.json && rm -rf docs/api && jsdoc --configure jsdoc.json --verbose",
"validator": "node tools/scriptutils.js replace-unpkg tools/validator.html docs/validator.html",
"recurtester": "node tools/scriptutils.js replace-unpkg tools/recur-tester.html docs/recur-tester.html",
"ghpages": "npm run jsdoc && npm run validator && npm run recurtester"
Expand Down
4 changes: 3 additions & 1 deletion tools/jsdoc-collect-types.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ exports.handlers = {
if (doclet.kind === "typedef" && doclet.scope === "static" && doclet.longname.startsWith("ICAL.")) {
typedefs.add({name: doclet.name, full: doclet.longname})
}
fs.writeFileSync("./temp.json", JSON.stringify({gIcalClasses: Array.from(gIcalClasses), typedefs: Array.from(typedefs)}));
},
processingComplete: function() {
fs.writeFileSync("./tools/jsdoc-symbols-temp.json", JSON.stringify({gIcalClasses: Array.from(gIcalClasses), typedefs: Array.from(typedefs)}));
}
};
6 changes: 5 additions & 1 deletion tools/jsdoc-ical.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
*/

const fs = require("node:fs");
const { gIcalClasses, typedefs } = JSON.parse(fs.readFileSync("./temp.json", "utf-8"));
let gIcalClasses = [];
let typedefs = [];

function addPrefix(objNames) {
if (objNames?.length) {
Expand Down Expand Up @@ -50,6 +51,9 @@ function augmentTypes(obj) {
}

exports.handlers = {
parseBegin: function() {
({ gIcalClasses, typedefs } = JSON.parse(fs.readFileSync("./tools/jsdoc-symbols-temp.json", "utf-8")));
},
newDoclet: function({ doclet }) {
if (doclet.type) {
augmentTypes(doclet.type);
Expand Down

0 comments on commit bacc31f

Please sign in to comment.