Skip to content
This repository has been archived by the owner on Jul 29, 2019. It is now read-only.

Adds missing jsdoc and adds lint rule require-jsdoc to build process #3354

Merged
merged 2 commits into from
Aug 9, 2017
Merged
Show file tree
Hide file tree
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
10 changes: 10 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,16 @@
"no-unreachable": 1,
"no-useless-escape": 0,
"no-console": 0,
"require-jsdoc": ["error", {
"require": {
"FunctionDeclaration": true,
"MethodDefinition": false,
"ClassDeclaration": false,
"ArrowFunctionExpression": false
}

}],
// "valid-jsdoc": 2
// To flag presence of console.log without breaking linting:
//"no-console": ["warn", { allow: ["warn", "error"] }],
}
Expand Down
2 changes: 1 addition & 1 deletion lib/DataSet.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ var Queue = require('./Queue');
* - {number} delay Delay in ms, null by default
* - {number} max Maximum number of entries in the queue, Infinity by default
* @constructor DataSet
* // TODO: add a DataSet constructor DataSet(data, options)
*/
// TODO: add a DataSet constructor DataSet(data, options)
function DataSet (data, options) {
// correctly read optional arguments
if (data && !Array.isArray(data)) {
Expand Down
5 changes: 5 additions & 0 deletions lib/graph3d/Graph3d.js
Original file line number Diff line number Diff line change
Expand Up @@ -2007,6 +2007,11 @@ Graph3d.prototype._insideTriangle = function (point, triangle) {
b = triangle[1],
c = triangle[2];

/**
*
* @param {Number} x
* @returns {Number}
*/
function sign (x) {
return x > 0 ? 1 : x < 0 ? -1 : 0;
}
Expand Down
24 changes: 20 additions & 4 deletions lib/graph3d/Settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,11 @@ function setDefaults(src, dst) {
dst.eye = new Point3d(0, 0, -1); // TODO: set eye.z about 3/4 of the width of the window?
}


/**
*
* @param options {Object}
* @param dst
*/
function setOptions(options, dst) {
if (options === undefined) {
return;
Expand Down Expand Up @@ -342,7 +346,11 @@ function checkStyleNumber(style) {
return valid;
}


/**
*
* @param {String | Number} style
* @param dst
*/
function setStyle(style, dst) {
if (style === undefined) {
return; // Nothing to do
Expand Down Expand Up @@ -398,7 +406,11 @@ function setBackgroundColor(backgroundColor, dst) {
dst.frame.style.borderStyle = 'solid';
}


/**
*
* @param {String | Object} dataColor
* @param dst
*/
function setDataColor(dataColor, dst) {
if (dataColor === undefined) {
return; // Nothing to do
Expand All @@ -425,7 +437,11 @@ function setDataColor(dataColor, dst) {
}
}


/**
*
* @param {Object} cameraPosition
* @param dst
*/
function setCameraPosition(cameraPosition, dst) {
var camPos = cameraPosition;
if (camPos === undefined) {
Expand Down
2 changes: 2 additions & 0 deletions lib/module/uuid.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* eslint-disable require-jsdoc */

var _rng;

var globalVar = typeof window !== 'undefined'
Expand Down
2 changes: 1 addition & 1 deletion lib/network/dotparser.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,12 @@ function nextPreview() {
return dot.charAt(index + 1);
}

var regexAlphaNumeric = /[a-zA-Z_0-9.:#]/;
/**
* Test whether given character is alphabetic or numeric
* @param {String} c
* @return {Boolean} isAlphaNumeric
*/
var regexAlphaNumeric = /[a-zA-Z_0-9.:#]/;
function isAlphaNumeric(c) {
return regexAlphaNumeric.test(c);
}
Expand Down
7 changes: 6 additions & 1 deletion lib/network/gephiParser.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@

/**
*
* @param {json} gephiJSON
* @param {obj} optionsObj
* @returns {{nodes: Array, edges: Array}}
*/
function parseGephi(gephiJSON, optionsObj) {
var edges = [];
var nodes = [];
Expand Down
22 changes: 20 additions & 2 deletions lib/timeline/Core.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,10 @@ Core.prototype._create = function (container) {
me.emit('release', event);
}.bind(this));

/**
*
* @param {WheelEvent} event
*/
function onMouseWheel(event) {
if (this.isActive()) {
this.emit('mousewheel', event);
Expand Down Expand Up @@ -222,7 +226,7 @@ Core.prototype._create = function (container) {
animation: false,
byUser: true,
event: event
}
};
this.range.setRange(newStart, newEnd, options);
}
}
Expand All @@ -237,6 +241,10 @@ Core.prototype._create = function (container) {
this.dom.centerContainer.attachEvent("onmousewheel", onMouseWheel.bind(this));
}

/**
*
* @param {scroll} event
*/
function onMouseScrollSide(event) {
if (!me.options.verticalScroll) return;
event.preventDefault();
Expand All @@ -253,6 +261,11 @@ Core.prototype._create = function (container) {

var itemAddedToTimeline = false;

/**
*
* @param {dragover} event
* @returns {boolean}
*/
function handleDragOver(event) {
if (event.preventDefault) {
event.preventDefault(); // Necessary. Allows us to drop.
Expand All @@ -269,6 +282,11 @@ Core.prototype._create = function (container) {
return false;
}

/**
*
* @param {drop} event
* @returns {boolean}
*/
function handleDrop(event) {
// prevent redirect to blank page - Firefox
if(event.preventDefault) { event.preventDefault(); }
Expand Down Expand Up @@ -1035,7 +1053,7 @@ Core.prototype._setDOM = function () {
dom.center.style.left = '0';
dom.left.style.left = '0';
dom.right.style.left = '0';
}
};

// TODO: deprecated since version 1.1.0, remove some day
Core.prototype.repaint = function () {
Expand Down
4 changes: 3 additions & 1 deletion lib/timeline/Range.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,9 @@ function validateDirection (direction) {
Range.prototype.startRolling = function() {
var me = this;


/**
* Updates the current time.
*/
function update () {
me.stopRolling();
me.rolling = true;
Expand Down
25 changes: 25 additions & 0 deletions lib/timeline/TimeStep.js
Original file line number Diff line number Diff line change
Expand Up @@ -613,10 +613,20 @@ TimeStep.prototype.getClassName = function() {
var step = this.step;
var classNames = [];

/**
*
* @param {Number} value
* @returns {String}
*/
function even(value) {
return (value / step % 2 == 0) ? ' vis-even' : ' vis-odd';
}

/**
*
* @param {Date} date
* @returns {String}
*/
function today(date) {
if (date.isSame(new Date(), 'day')) {
return ' vis-today';
Expand All @@ -630,14 +640,29 @@ TimeStep.prototype.getClassName = function() {
return '';
}

/**
*
* @param {Date} date
* @returns {String}
*/
function currentWeek(date) {
return date.isSame(new Date(), 'week') ? ' vis-current-week' : '';
}

/**
*
* @param {Date} date
* @returns {String}
*/
function currentMonth(date) {
return date.isSame(new Date(), 'month') ? ' vis-current-month' : '';
}

/**
*
* @param {Date} date
* @returns {String}
*/
function currentYear(date) {
return date.isSame(new Date(), 'year') ? ' vis-current-year' : '';
}
Expand Down
11 changes: 10 additions & 1 deletion lib/timeline/Timeline.js
Original file line number Diff line number Diff line change
Expand Up @@ -429,11 +429,20 @@ Timeline.prototype.fit = function (options) {
}
};


/**
*
* @param {vis.Item} item
* @returns {Number}
*/
function getStart(item) {
return util.convert(item.data.start, 'Date').valueOf()
}

/**
*
* @param {vis.Item} item
* @returns {Number}
*/
function getEnd(item) {
var end = item.data.end != undefined ? item.data.end : item.data.start;
return util.convert(end, 'Date').valueOf();
Expand Down
5 changes: 4 additions & 1 deletion lib/timeline/component/CurrentTime.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,10 @@ CurrentTime.prototype.redraw = function() {
CurrentTime.prototype.start = function() {
var me = this;

function update () {
/**
* Updates the current time.
*/
function update () {
me.stop();

// determine interval to refresh
Expand Down
5 changes: 4 additions & 1 deletion lib/timeline/component/CustomTime.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ var locales = require('../locales');
* @constructor CustomTime
* @extends Component
*/

function CustomTime (body, options) {
this.body = body;

Expand Down Expand Up @@ -78,6 +77,10 @@ CustomTime.prototype._create = function() {
drag.style.height = '100%';
drag.style.width = '20px';

/**
*
* @param {WheelEvent} e
*/
function onMouseWheel (e) {
this.body.range._onMouseWheel(e);
}
Expand Down
13 changes: 12 additions & 1 deletion lib/timeline/component/DataScale.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,15 @@

/**
*
* @param {number} start
* @param {number} end
* @param {boolean} autoScaleStart
* @param {boolean} autoScaleEnd
* @param {number} containerHeight
* @param {number} majorCharHeight
* @param {boolean} zeroAlign
* @param {function} formattingFunction
* @constructor
*/
function DataScale(start, end, autoScaleStart, autoScaleEnd, containerHeight, majorCharHeight, zeroAlign = false, formattingFunction=false) {
this.majorSteps = [1, 2, 5, 10];
this.minorSteps = [0.25, 0.5, 1, 2];
Expand Down
6 changes: 6 additions & 0 deletions lib/timeline/component/graph2d_types/bar.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
var DOMutil = require('../../../DOMutil');
var Points = require('./points');

/**
*
* @param {vis.Group.id} groupId
* @param {Object} options // TODO: Describe options
* @constructor
*/
function Bargraph(groupId, options) { // eslint-disable-line no-unused-vars
}

Expand Down
8 changes: 7 additions & 1 deletion lib/timeline/component/graph2d_types/line.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
var DOMutil = require('../../../DOMutil');

/**
*
* @param {Number | String} groupId
* @param {Object} options // TODO: Describe options
* @constructor
*/
function Line(groupId, options) { // eslint-disable-line no-unused-vars
}

Expand All @@ -18,7 +24,7 @@ Line.calcPath = function (dataset, group) {
return d;
}
}
}
};

Line.drawIcon = function (group, x, y, iconWidth, iconHeight, framework) {
var fillHeight = iconHeight * 0.5;
Expand Down
22 changes: 20 additions & 2 deletions lib/timeline/component/graph2d_types/points.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
var DOMutil = require('../../../DOMutil');

/**
*
* @param {Number | String} groupId
* @param {Object} options // TODO: Describe options
*
* @constructor
*/
function Points(groupId, options) { // eslint-disable-line no-unused-vars
}

Expand Down Expand Up @@ -43,6 +50,12 @@ Points.drawIcon = function (group, x, y, iconWidth, iconHeight, framework) {
DOMutil.drawPoint(x + 0.5 * iconWidth, y, getGroupTemplate(group), framework.svgElements, framework.svg);
};

/**
*
* @param {vis.Group} group
* @param {any} callbackResult
* @returns {{style: *, styles: (*|string), size: *, className: *}}
*/
function getGroupTemplate(group, callbackResult) {
callbackResult = (typeof callbackResult === 'undefined') ? {} : callbackResult;
return {
Expand All @@ -53,6 +66,12 @@ function getGroupTemplate(group, callbackResult) {
};
}

/**
*
* @param {Object} framework | SVG DOM element
* @param {vis.Group} group
* @returns {function}
*/
function getCallback(framework, group) {
var callback = undefined;
// check for the graph2d onRender
Expand All @@ -67,5 +86,4 @@ function getCallback(framework, group) {
return callback;
}


module.exports = Points;
module.exports = Points;
Loading