Skip to content

Commit 03f05b3

Browse files
author
David Joy
committed
docs: adding an export-removing plugin to jsdoc to improve doc output
1 parent 1c3d580 commit 03f05b3

File tree

4 files changed

+76
-2009
lines changed

4 files changed

+76
-2009
lines changed

docs/removeExport.js

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/**
2+
* JSDoc plugin.
3+
*
4+
* Modifies the source code to remove the "export" keyword before JS doc sees it. This removes
5+
* "exports." prefixes from documented members.
6+
*
7+
* @module plugins/exportKiller
8+
*/
9+
exports.handlers = {
10+
beforeParse(e) {
11+
e.source = e.source.replace(/(\nexport function)/g, $ => {
12+
return `\nfunction`;
13+
});
14+
e.source = e.source.replace(/(\nexport const)/g, $ => {
15+
return `\nconst`;
16+
});
17+
e.source = e.source.replace(/(\nexport default)/g, $ => {
18+
return `\n`;
19+
});
20+
e.source = e.source.replace(/(\nexport async function)/g, $ => {
21+
return `\nasync function`;
22+
});
23+
}
24+
};

jsdoc.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
"excludePattern": "(node_modules/|docs)"
1010
},
1111
"plugins": [
12-
"plugins/markdown"
12+
"plugins/markdown",
13+
"docs/removeExport"
1314
],
1415
"templates": {
1516
"cleverLinks": false,

0 commit comments

Comments
 (0)