Skip to content

Commit 0e32a6c

Browse files
authored
Merge pull request #210 from docsbydoxdox/hotfix/api-scope-tag-support
[hotfix] Added api scope tag support.
2 parents f5c376e + 17908c6 commit 0e32a6c

File tree

4 files changed

+76
-2
lines changed

4 files changed

+76
-2
lines changed

packages/doxdox-parser-custom/src/__snapshots__/index.test.ts.snap

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1182,3 +1182,47 @@ exports[`custom parser parse parse example jsdoc headers (function methods) 1`]
11821182
"path": "./test/mocks/function.js",
11831183
}
11841184
`;
1185+
1186+
exports[`custom parser tag tests public/private scope 1`] = `
1187+
{
1188+
"methods": [
1189+
{
1190+
"description": "",
1191+
"fullName": "privateMethod()",
1192+
"name": "privateMethod",
1193+
"params": [],
1194+
"private": true,
1195+
"returns": [],
1196+
"slug": "test-mocks-scope-js-privatemethod",
1197+
},
1198+
{
1199+
"description": "",
1200+
"fullName": "privateMethod()",
1201+
"name": "privateMethod",
1202+
"params": [],
1203+
"private": true,
1204+
"returns": [],
1205+
"slug": "test-mocks-scope-js-privatemethod",
1206+
},
1207+
{
1208+
"description": "",
1209+
"fullName": "publicMethod()",
1210+
"name": "publicMethod",
1211+
"params": [],
1212+
"private": false,
1213+
"returns": [],
1214+
"slug": "test-mocks-scope-js-publicmethod",
1215+
},
1216+
{
1217+
"description": "",
1218+
"fullName": "publicMethod()",
1219+
"name": "publicMethod",
1220+
"params": [],
1221+
"private": false,
1222+
"returns": [],
1223+
"slug": "test-mocks-scope-js-publicmethod",
1224+
},
1225+
],
1226+
"path": "./test/mocks/scope.js",
1227+
}
1228+
`;

packages/doxdox-parser-custom/src/index.test.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,14 @@ describe('custom parser', () => {
2727
});
2828
});
2929

30+
describe('tag tests', () => {
31+
it('public/private scope', async () => {
32+
await expect(
33+
parse(process.cwd(), './test/mocks/scope.js')
34+
).resolves.toMatchSnapshot();
35+
});
36+
});
37+
3038
describe('parse example from JSDoc documentation https://jsdoc.app/', () => {
3139
// JSDoc Example from https://jsdoc.app/
3240
it('parse amd-module', async () => {

packages/doxdox-parser-custom/src/index.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,11 @@ export const parseString = async (
100100
const returnTags = method.comment.tags.filter(({ tag }) =>
101101
/return$/.test(tag)
102102
);
103-
const privateScopeTags = method.comment.tags.filter(({ tag }) =>
104-
/private$/.test(tag)
103+
104+
const privateScopeTags = method.comment.tags.filter(
105+
({ tag, name }) =>
106+
/private$/.test(tag) ||
107+
(tag === 'api' && /private$/.test(name))
105108
);
106109

107110
const params = paramTags.map(({ name, description, type }) => ({
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/**
2+
* @public
3+
*/
4+
function publicMethod() {}
5+
6+
/**
7+
* @api public
8+
*/
9+
function publicMethod() {}
10+
11+
/**
12+
* @private
13+
*/
14+
function privateMethod() {}
15+
16+
/**
17+
* @api private
18+
*/
19+
function privateMethod() {}

0 commit comments

Comments
 (0)