Skip to content
This repository was archived by the owner on Jan 19, 2019. It is now read-only.

Commit c61cc81

Browse files
committed
Docs: Improved detail and accuracy of JSDoc blocks
1 parent 918a9cc commit c61cc81

File tree

2 files changed

+44
-43
lines changed

2 files changed

+44
-43
lines changed

Makefile.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ function splitCommandResultToLines(result) {
105105

106106
/**
107107
* Returns a list of sorted, valid semtantic-verisioning git tags
108-
* @returns {array} The version tags
108+
* @returns {string[]} The version tags
109109
*/
110110
function getVersionTags() {
111111
var tags = splitCommandResultToLines(exec("git tag", { silent: true }).output);

lib/ast-converter.js

+43-42
Original file line numberDiff line numberDiff line change
@@ -116,44 +116,44 @@ TOKEN_TO_TEXT[SyntaxKind.AtToken] = "@";
116116
TOKEN_TO_TEXT[SyntaxKind.InKeyword] = "in";
117117

118118
/**
119-
* Returns true if the given node is a valid ESTree class member
120-
* @param {object} node AST node
121-
* @returns {boolean} is valid class member
119+
* Returns true if the given TSNode is a valid ESTree class member
120+
* @param {TSNode} node TypeScript AST node
121+
* @returns {boolean} is valid ESTree class member
122122
*/
123123
function isESTreeClassMember(node) {
124124
return node.kind !== SyntaxKind.PropertyDeclaration && node.kind !== SyntaxKind.SemicolonClassElement;
125125
}
126126

127127
/**
128-
* Returns true if the given token is a comma
129-
* @param {object} token the syntax token
128+
* Returns true if the given TSToken is a comma
129+
* @param {TSToken} token the TypeScript token
130130
* @returns {boolean} is comma
131131
*/
132132
function isComma(token) {
133133
return token.kind === SyntaxKind.CommaToken;
134134
}
135135

136136
/**
137-
* Returns true if the given operator is the assignment operator
138-
* @param {object} operator the operator
137+
* Returns true if the given TSToken is the assignment operator
138+
* @param {TSToken} operator the operator token
139139
* @returns {boolean} is assignment
140140
*/
141141
function isAssignmentOperator(operator) {
142142
return ASSIGNMENT_OPERATORS.indexOf(operator.kind) > -1;
143143
}
144144

145145
/**
146-
* Returns true if the given operator is a logical operator
147-
* @param {object} operator the operator
146+
* Returns true if the given TSToken is a logical operator
147+
* @param {TSToken} operator the operator token
148148
* @returns {boolean} is a logical operator
149149
*/
150150
function isLogicalOperator(operator) {
151151
return LOGICAL_OPERATORS.indexOf(operator.kind) > -1;
152152
}
153153

154154
/**
155-
* Returns the binary expression type of the given operator
156-
* @param {object} operator the operator
155+
* Returns the binary expression type of the given TSToken
156+
* @param {TSToken} operator the operator token
157157
* @returns {string} the binary expression type
158158
*/
159159
function getBinaryExpressionType(operator) {
@@ -169,10 +169,10 @@ function getBinaryExpressionType(operator) {
169169
/**
170170
* Returns line and column data for the given start and end positions,
171171
* for the given AST
172-
* @param {object} start start data
173-
* @param {object} end end data
174-
* @param {object} ast the AST object
175-
* @returns {object} the loc data
172+
* @param {Object} start start data
173+
* @param {Object} end end data
174+
* @param {Object} ast the AST object
175+
* @returns {Object} the loc data
176176
*/
177177
function getLocFor(start, end, ast) {
178178
var startLoc = ast.getLineAndCharacterOfPosition(start),
@@ -191,11 +191,11 @@ function getLocFor(start, end, ast) {
191191
}
192192

193193
/**
194-
* Returns line and column data for the given node or token,
194+
* Returns line and column data for the given ESTreeNode or ESTreeToken,
195195
* for the given AST
196-
* @param {object} nodeOrToken the node or token
197-
* @param {object} ast the AST object
198-
* @returns {object} the loc data
196+
* @param {ESTreeToken|ESTreeNode} nodeOrToken the ESTreeNode or ESTreeToken
197+
* @param {Object} ast the AST object
198+
* @returns {Object} the loc data
199199
*/
200200
function getLoc(nodeOrToken, ast) {
201201
return getLocFor(nodeOrToken.getStart(), nodeOrToken.end, ast);
@@ -216,11 +216,11 @@ function getLoc(nodeOrToken, ast) {
216216
}
217217

218218
/**
219-
* Fixes the exports of the given node
220-
* @param {object} node the node
221-
* @param {object} result result
222-
* @param {[type]} ast the AST
223-
* @returns {object} the node with fixed exports
219+
* Fixes the exports of the given TSNode
220+
* @param {TSNode} node the TSNode
221+
* @param {Object} result result
222+
* @param {Object} ast the AST
223+
* @returns {TSNode} the TSNode with fixed exports
224224
*/
225225
function fixExports(node, result, ast) {
226226
// check for exports
@@ -255,8 +255,8 @@ function fixExports(node, result, ast) {
255255

256256
/**
257257
* Extends and formats a given error object
258-
* @param {object} error the error object
259-
* @returns {object} converted error object
258+
* @param {Object} error the error object
259+
* @returns {Object} converted error object
260260
*/
261261
function convertError(error) {
262262

@@ -271,8 +271,8 @@ function convertError(error) {
271271
}
272272

273273
/**
274-
* Returns the type of a given token
275-
* @param {object} token the token
274+
* Returns the type of a given ESTreeToken
275+
* @param {ESTreeToken} token the ESTreeToken
276276
* @returns {string} the token type
277277
*/
278278
function getTokenType(token) {
@@ -327,10 +327,10 @@ function getTokenType(token) {
327327
}
328328

329329
/**
330-
* Extends and formats a given token, for a given AST
331-
* @param {object} token the token
332-
* @param {object} ast the AST object
333-
* @returns {object} the converted token
330+
* Extends and formats a given ESTreeToken, for a given AST
331+
* @param {ESTreeToken} token the ESTreeToken
332+
* @param {Object} ast the AST object
333+
* @returns {ESTreeToken} the converted ESTreeToken
334334
*/
335335
function convertToken(token, ast) {
336336

@@ -355,8 +355,8 @@ function convertToken(token, ast) {
355355

356356
/**
357357
* Converts all tokens for the given AST
358-
* @param {object} ast the AST object
359-
* @returns {array} the converted tokens
358+
* @param {Object} ast the AST object
359+
* @returns {ESTreeToken[]} the converted ESTreeTokens
360360
*/
361361
function convertTokens(ast) {
362362
var token = ast.getFirstToken(),
@@ -386,10 +386,10 @@ module.exports = function(ast, extra) {
386386
}
387387

388388
/**
389-
* Converts node
390-
* @param {object} node the node
391-
* @param {object} parent the parent node
392-
* @returns {object} the converted node
389+
* Converts a TypeScript node into an ESTree node
390+
* @param {TSNode} node the TSNode
391+
* @param {TSNode} parent the parent TSNode
392+
* @returns {ESTreeNode} the converted ESTreeNode
393393
*/
394394
function convert(node, parent) {
395395

@@ -405,7 +405,8 @@ module.exports = function(ast, extra) {
405405
};
406406

407407
/**
408-
* Copies the result object
408+
* Copies the result object into an ESTree node with just a type property.
409+
* This is used only for leaf nodes that have no other properties.
409410
* @returns {void}
410411
*/
411412
function simplyCopy() {
@@ -415,9 +416,9 @@ module.exports = function(ast, extra) {
415416
}
416417

417418
/**
418-
* Converts child node
419-
* @param {object} child the child node
420-
* @returns {object} the converted child node
419+
* Converts a TypeScript node into an ESTree node.
420+
* @param {TSNode} child the child TSNode
421+
* @returns {ESTreeNode} the converted ESTree node
421422
*/
422423
function convertChild(child) {
423424
return convert(child, node);

0 commit comments

Comments
 (0)