Skip to content

Instantly share code, notes, and snippets.

@stephentuso
Last active November 28, 2017 15:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stephentuso/93d2d133a93c232bb8fe0a66be439e7a to your computer and use it in GitHub Desktop.
Save stephentuso/93d2d133a93c232bb8fe0a66be439e7a to your computer and use it in GitHub Desktop.
This includes undocumented functions in the docs - ideally everything would be properly documented, but this is a quick fix if you have a huge number of undocumented functions
'use strict'
exports.handlers = {
symbolFound: function (e) {
let params = e.code.paramnames
let filename = e.filename.split('doc-stage/')[1].split('.js')[0]
if (filename === 'module.exports' || filename === 'exports') {
return
}
let type = e.astnode.type
if (type === 'Property') {
if (e.code.node.params) {
params = e.code.node.params.map(n => n.name)
}
// Only auto document properties that are functions
if (!params) {
return
}
}
if (type === 'MethodDefinition' || type === 'FunctionExpression' || type === 'Property') {
if (e.comment !== '@undocumented') return
let name = e.code.node.key && e.code.node.key.name
if (name && name.startsWith('_')) return
e.comment = '/**\n* Undocumented - view source for details'
e.comment += '\n * @memberOf ' + filename
e.comment += '\n * @inheritDoc'
if (params) {
for (let i = 0; i < params.length; i++) {
e.comment += '\n* @param ' + params[i]
}
}
e.comment += '\n**/'
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment