-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11362 from rwjblue/enforce-documentation-access-s…
…pecifics [DOC beta] Enforce public/private declaration for API docs.
- Loading branch information
Showing
162 changed files
with
1,189 additions
and
444 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
var assert = require('assert'); | ||
|
||
function isDocComment(comment) { | ||
return comment.value[0] === '*'; | ||
} | ||
|
||
function isModuleOnlyComment(comment) { | ||
return comment.value.match(/^\*\n\s*@module.+\n(?:\s*@submodule.+\n)?$/); | ||
} | ||
|
||
function includesAccessDeclaration(comment) { | ||
return comment.value.match(/\n\s*(@private|@public)\s/); | ||
} | ||
|
||
function RequireCommentsToIncludeAccess() { } | ||
|
||
RequireCommentsToIncludeAccess.prototype = { | ||
configure: function(value) { | ||
assert( | ||
value === true, | ||
this.getOptionName() + ' option requires a true value or should be removed' | ||
); | ||
}, | ||
|
||
getOptionName: function() { | ||
return 'requireCommentsToIncludeAccess'; | ||
}, | ||
|
||
check: function(file, errors) { | ||
file.iterateTokensByType('Block', function(comment) { | ||
if (isDocComment(comment) && !isModuleOnlyComment(comment) && !includesAccessDeclaration(comment)) { | ||
errors.add('You must supply `@public` or `@private` for block comments.', comment.loc.end); | ||
} | ||
}); | ||
} | ||
}; | ||
|
||
module.exports = RequireCommentsToIncludeAccess; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.