1 | const { walk } = require('./walk');
|
2 |
|
3 | /**
|
4 | * Exclude given access levels from the generated documentation: this allows
|
5 | * users to write documentation for non-public members by using the
|
6 | * `@private` tag.
|
7 | *
|
8 | * @param {Array<string>} [levels=['public', 'undefined', 'protected']] included access levels.
|
9 | * @param {Array<Object>} comments parsed comments (can be nested)
|
10 | * @returns {Array<Object>} filtered comments
|
11 | */
|
12 | function filterAccess(levels, comments) {
|
13 | function filter(comment) {
|
14 | return (
|
15 | comment.kind === 'note' ||
|
16 | (!comment.ignore && levels.indexOf(String(comment.access)) !== -1)
|
17 | );
|
18 | }
|
19 |
|
20 | function recurse(comment) {
|
21 | for (const scope in comment.members) {
|
22 | comment.members[scope] = comment.members[scope].filter(filter);
|
23 | }
|
24 | }
|
25 |
|
26 | return walk(comments.filter(filter), recurse);
|
27 | }
|
28 |
|
29 | module.exports = filterAccess;
|