Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 17 additions & 7 deletions website/jsdocs/jsdocs.js
Original file line number Diff line number Diff line change
Expand Up @@ -209,13 +209,21 @@ function sanitizeTypehint(string) {

/**
* @param {object} node
* @param {object} docNode Node used for location/docblock purposes
* @param {object} state
* @param {string} source
* @param {array<object>} commentsForFile
* @param {array<string>} linesForFile
* @return {object}
*/
function getFunctionData(node, state, source, commentsForFile, linesForFile) {
function getFunctionData(
node,
docNode,
state,
source,
commentsForFile,
linesForFile
) {
var params = [];
var typechecks = commentsForFile.typechecks;
var typehintsFromBlock = null;
Expand Down Expand Up @@ -287,9 +295,9 @@ function getFunctionData(node, state, source, commentsForFile, linesForFile) {
});
}
return {
line: node.loc.start.line,
line: docNode.loc.start.line,
source: source.substring.apply(source, node.range),
docblock: getDocBlock(node, commentsForFile, linesForFile),
docblock: getDocBlock(docNode, commentsForFile, linesForFile),
modifiers: [],
params: params,
tparams: tparams,
Expand Down Expand Up @@ -320,7 +328,7 @@ function getObjectData(node, state, source, scopeChain,

switch (property.value.type) {
case Syntax.FunctionExpression:
var methodData = getFunctionData(property.value, state, source,
var methodData = getFunctionData(property.value, property, state, source,
commentsForFile, linesForFile);
methodData.name = property.key.name || property.key.value;
methodData.source = source.substring.apply(source, property.range);
Expand All @@ -335,7 +343,8 @@ function getObjectData(node, state, source, scopeChain,
if (expr) {
if (expr.type === Syntax.FunctionDeclaration) {
var functionData =
getFunctionData(expr, state, source, commentsForFile, linesForFile);
getFunctionData(expr, property, state, source, commentsForFile,
linesForFile);
functionData.name = property.key.name || property.key.value;
functionData.modifiers.push('static');
methods.push(functionData);
Expand Down Expand Up @@ -389,7 +398,7 @@ function getClassData(node, state, source, commentsForFile, linesForFile) {
if (bodyItem.type === Syntax.MethodDefinition) {
if (bodyItem.value.type === Syntax.FunctionExpression) {
var methodData =
getFunctionData(bodyItem.value, state, source,
getFunctionData(bodyItem.value, bodyItem, state, source,
commentsForFile, linesForFile);
methodData.name = bodyItem.key.name;
methodData.source = source.substring.apply(source, bodyItem.range);
Expand Down Expand Up @@ -529,7 +538,8 @@ function parseSource(source) {
break;
case Syntax.FunctionDeclaration:
case Syntax.FunctionExpression:
data = getFunctionData(definition, _state, source, ast.comments, lines);
data = getFunctionData(definition, definition, _state, source,
ast.comments, lines);
data.type = 'function';
break;
default:
Expand Down