mirror of
https://github.com/documentationjs/documentation.git
synced 2026-01-25 14:26:29 +00:00
35 lines
931 B
JavaScript
35 lines
931 B
JavaScript
'use strict';
|
|
|
|
var shouldSkipInference = require('./should_skip_inference');
|
|
|
|
/**
|
|
* Given a string with a pattern that might infer access level, like `^_`,
|
|
* create an inference method.
|
|
*
|
|
* @param {?string} pattern regexp-compatible pattern
|
|
* @returns {Function} inference method
|
|
* @private
|
|
*/
|
|
function inferAccessWithPattern(pattern) {
|
|
var re = pattern && new RegExp(pattern);
|
|
|
|
/**
|
|
* Infers access (only private atm) from the name.
|
|
*
|
|
* @name inferAccess
|
|
* @param {Object} comment parsed comment
|
|
* @returns {Object} comment with access inferred
|
|
*/
|
|
return shouldSkipInference(function inferAccess(comment) {
|
|
// This needs to run after inferName beacuse we infer the access based on
|
|
// the name.
|
|
if (re && comment.name && comment.access === undefined && re.test(comment.name)) {
|
|
comment.access = 'private';
|
|
}
|
|
|
|
return comment;
|
|
});
|
|
}
|
|
|
|
module.exports = inferAccessWithPattern;
|