Browse Source

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

* Change lint rules

* Get eslint passing with require-jsdoc
revert-3409-performance
macleodbroad-wf 7 years ago
committed by Yotam Berkowitz
parent
commit
05cbb3b72c
19 changed files with 158 additions and 18 deletions
  1. +10
    -0
      .eslintrc
  2. +1
    -1
      lib/DataSet.js
  3. +5
    -0
      lib/graph3d/Graph3d.js
  4. +20
    -4
      lib/graph3d/Settings.js
  5. +2
    -0
      lib/module/uuid.js
  6. +1
    -1
      lib/network/dotparser.js
  7. +6
    -1
      lib/network/gephiParser.js
  8. +20
    -2
      lib/timeline/Core.js
  9. +3
    -1
      lib/timeline/Range.js
  10. +25
    -0
      lib/timeline/TimeStep.js
  11. +10
    -1
      lib/timeline/Timeline.js
  12. +4
    -1
      lib/timeline/component/CurrentTime.js
  13. +4
    -1
      lib/timeline/component/CustomTime.js
  14. +12
    -1
      lib/timeline/component/DataScale.js
  15. +6
    -0
      lib/timeline/component/graph2d_types/bar.js
  16. +7
    -1
      lib/timeline/component/graph2d_types/line.js
  17. +20
    -2
      lib/timeline/component/graph2d_types/points.js
  18. +1
    -1
      lib/timeline/component/item/BackgroundItem.js
  19. +1
    -0
      lib/util.js

+ 10
- 0
.eslintrc View File

@ -19,6 +19,16 @@
"no-unreachable": 1, "no-unreachable": 1,
"no-useless-escape": 0, "no-useless-escape": 0,
"no-console": 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: // To flag presence of console.log without breaking linting:
//"no-console": ["warn", { allow: ["warn", "error"] }], //"no-console": ["warn", { allow: ["warn", "error"] }],
} }

+ 1
- 1
lib/DataSet.js View File

@ -42,8 +42,8 @@ var Queue = require('./Queue');
* - {number} delay Delay in ms, null by default * - {number} delay Delay in ms, null by default
* - {number} max Maximum number of entries in the queue, Infinity by default * - {number} max Maximum number of entries in the queue, Infinity by default
* @constructor DataSet * @constructor DataSet
* // TODO: add a DataSet constructor DataSet(data, options)
*/ */
// TODO: add a DataSet constructor DataSet(data, options)
function DataSet (data, options) { function DataSet (data, options) {
// correctly read optional arguments // correctly read optional arguments
if (data && !Array.isArray(data)) { if (data && !Array.isArray(data)) {

+ 5
- 0
lib/graph3d/Graph3d.js View File

@ -2007,6 +2007,11 @@ Graph3d.prototype._insideTriangle = function (point, triangle) {
b = triangle[1], b = triangle[1],
c = triangle[2]; c = triangle[2];
/**
*
* @param {Number} x
* @returns {Number}
*/
function sign (x) { function sign (x) {
return x > 0 ? 1 : x < 0 ? -1 : 0; return x > 0 ? 1 : x < 0 ? -1 : 0;
} }

+ 20
- 4
lib/graph3d/Settings.js View File

@ -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? 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) { function setOptions(options, dst) {
if (options === undefined) { if (options === undefined) {
return; return;
@ -342,7 +346,11 @@ function checkStyleNumber(style) {
return valid; return valid;
} }
/**
*
* @param {String | Number} style
* @param dst
*/
function setStyle(style, dst) { function setStyle(style, dst) {
if (style === undefined) { if (style === undefined) {
return; // Nothing to do return; // Nothing to do
@ -398,7 +406,11 @@ function setBackgroundColor(backgroundColor, dst) {
dst.frame.style.borderStyle = 'solid'; dst.frame.style.borderStyle = 'solid';
} }
/**
*
* @param {String | Object} dataColor
* @param dst
*/
function setDataColor(dataColor, dst) { function setDataColor(dataColor, dst) {
if (dataColor === undefined) { if (dataColor === undefined) {
return; // Nothing to do return; // Nothing to do
@ -425,7 +437,11 @@ function setDataColor(dataColor, dst) {
} }
} }
/**
*
* @param {Object} cameraPosition
* @param dst
*/
function setCameraPosition(cameraPosition, dst) { function setCameraPosition(cameraPosition, dst) {
var camPos = cameraPosition; var camPos = cameraPosition;
if (camPos === undefined) { if (camPos === undefined) {

+ 2
- 0
lib/module/uuid.js View File

@ -1,3 +1,5 @@
/* eslint-disable require-jsdoc */
var _rng; var _rng;
var globalVar = typeof window !== 'undefined' var globalVar = typeof window !== 'undefined'

+ 1
- 1
lib/network/dotparser.js View File

@ -109,12 +109,12 @@ function nextPreview() {
return dot.charAt(index + 1); return dot.charAt(index + 1);
} }
var regexAlphaNumeric = /[a-zA-Z_0-9.:#]/;
/** /**
* Test whether given character is alphabetic or numeric * Test whether given character is alphabetic or numeric
* @param {String} c * @param {String} c
* @return {Boolean} isAlphaNumeric * @return {Boolean} isAlphaNumeric
*/ */
var regexAlphaNumeric = /[a-zA-Z_0-9.:#]/;
function isAlphaNumeric(c) { function isAlphaNumeric(c) {
return regexAlphaNumeric.test(c); return regexAlphaNumeric.test(c);
} }

+ 6
- 1
lib/network/gephiParser.js View File

@ -1,4 +1,9 @@
/**
*
* @param {json} gephiJSON
* @param {obj} optionsObj
* @returns {{nodes: Array, edges: Array}}
*/
function parseGephi(gephiJSON, optionsObj) { function parseGephi(gephiJSON, optionsObj) {
var edges = []; var edges = [];
var nodes = []; var nodes = [];

+ 20
- 2
lib/timeline/Core.js View File

@ -164,6 +164,10 @@ Core.prototype._create = function (container) {
me.emit('release', event); me.emit('release', event);
}.bind(this)); }.bind(this));
/**
*
* @param {WheelEvent} event
*/
function onMouseWheel(event) { function onMouseWheel(event) {
if (this.isActive()) { if (this.isActive()) {
this.emit('mousewheel', event); this.emit('mousewheel', event);
@ -222,7 +226,7 @@ Core.prototype._create = function (container) {
animation: false, animation: false,
byUser: true, byUser: true,
event: event event: event
}
};
this.range.setRange(newStart, newEnd, options); this.range.setRange(newStart, newEnd, options);
} }
} }
@ -237,6 +241,10 @@ Core.prototype._create = function (container) {
this.dom.centerContainer.attachEvent("onmousewheel", onMouseWheel.bind(this)); this.dom.centerContainer.attachEvent("onmousewheel", onMouseWheel.bind(this));
} }
/**
*
* @param {scroll} event
*/
function onMouseScrollSide(event) { function onMouseScrollSide(event) {
if (!me.options.verticalScroll) return; if (!me.options.verticalScroll) return;
event.preventDefault(); event.preventDefault();
@ -253,6 +261,11 @@ Core.prototype._create = function (container) {
var itemAddedToTimeline = false; var itemAddedToTimeline = false;
/**
*
* @param {dragover} event
* @returns {boolean}
*/
function handleDragOver(event) { function handleDragOver(event) {
if (event.preventDefault) { if (event.preventDefault) {
event.preventDefault(); // Necessary. Allows us to drop. event.preventDefault(); // Necessary. Allows us to drop.
@ -269,6 +282,11 @@ Core.prototype._create = function (container) {
return false; return false;
} }
/**
*
* @param {drop} event
* @returns {boolean}
*/
function handleDrop(event) { function handleDrop(event) {
// prevent redirect to blank page - Firefox // prevent redirect to blank page - Firefox
if(event.preventDefault) { event.preventDefault(); } if(event.preventDefault) { event.preventDefault(); }
@ -1035,7 +1053,7 @@ Core.prototype._setDOM = function () {
dom.center.style.left = '0'; dom.center.style.left = '0';
dom.left.style.left = '0'; dom.left.style.left = '0';
dom.right.style.left = '0'; dom.right.style.left = '0';
}
};
// TODO: deprecated since version 1.1.0, remove some day // TODO: deprecated since version 1.1.0, remove some day
Core.prototype.repaint = function () { Core.prototype.repaint = function () {

+ 3
- 1
lib/timeline/Range.js View File

@ -129,7 +129,9 @@ function validateDirection (direction) {
Range.prototype.startRolling = function() { Range.prototype.startRolling = function() {
var me = this; var me = this;
/**
* Updates the current time.
*/
function update () { function update () {
me.stopRolling(); me.stopRolling();
me.rolling = true; me.rolling = true;

+ 25
- 0
lib/timeline/TimeStep.js View File

@ -613,10 +613,20 @@ TimeStep.prototype.getClassName = function() {
var step = this.step; var step = this.step;
var classNames = []; var classNames = [];
/**
*
* @param {Number} value
* @returns {String}
*/
function even(value) { function even(value) {
return (value / step % 2 == 0) ? ' vis-even' : ' vis-odd'; return (value / step % 2 == 0) ? ' vis-even' : ' vis-odd';
} }
/**
*
* @param {Date} date
* @returns {String}
*/
function today(date) { function today(date) {
if (date.isSame(new Date(), 'day')) { if (date.isSame(new Date(), 'day')) {
return ' vis-today'; return ' vis-today';
@ -630,14 +640,29 @@ TimeStep.prototype.getClassName = function() {
return ''; return '';
} }
/**
*
* @param {Date} date
* @returns {String}
*/
function currentWeek(date) { function currentWeek(date) {
return date.isSame(new Date(), 'week') ? ' vis-current-week' : ''; return date.isSame(new Date(), 'week') ? ' vis-current-week' : '';
} }
/**
*
* @param {Date} date
* @returns {String}
*/
function currentMonth(date) { function currentMonth(date) {
return date.isSame(new Date(), 'month') ? ' vis-current-month' : ''; return date.isSame(new Date(), 'month') ? ' vis-current-month' : '';
} }
/**
*
* @param {Date} date
* @returns {String}
*/
function currentYear(date) { function currentYear(date) {
return date.isSame(new Date(), 'year') ? ' vis-current-year' : ''; return date.isSame(new Date(), 'year') ? ' vis-current-year' : '';
} }

+ 10
- 1
lib/timeline/Timeline.js View File

@ -429,11 +429,20 @@ Timeline.prototype.fit = function (options) {
} }
}; };
/**
*
* @param {vis.Item} item
* @returns {Number}
*/
function getStart(item) { function getStart(item) {
return util.convert(item.data.start, 'Date').valueOf() return util.convert(item.data.start, 'Date').valueOf()
} }
/**
*
* @param {vis.Item} item
* @returns {Number}
*/
function getEnd(item) { function getEnd(item) {
var end = item.data.end != undefined ? item.data.end : item.data.start; var end = item.data.end != undefined ? item.data.end : item.data.start;
return util.convert(end, 'Date').valueOf(); return util.convert(end, 'Date').valueOf();

+ 4
- 1
lib/timeline/component/CurrentTime.js View File

@ -124,7 +124,10 @@ CurrentTime.prototype.redraw = function() {
CurrentTime.prototype.start = function() { CurrentTime.prototype.start = function() {
var me = this; var me = this;
function update () {
/**
* Updates the current time.
*/
function update () {
me.stop(); me.stop();
// determine interval to refresh // determine interval to refresh

+ 4
- 1
lib/timeline/component/CustomTime.js View File

@ -14,7 +14,6 @@ var locales = require('../locales');
* @constructor CustomTime * @constructor CustomTime
* @extends Component * @extends Component
*/ */
function CustomTime (body, options) { function CustomTime (body, options) {
this.body = body; this.body = body;
@ -78,6 +77,10 @@ CustomTime.prototype._create = function() {
drag.style.height = '100%'; drag.style.height = '100%';
drag.style.width = '20px'; drag.style.width = '20px';
/**
*
* @param {WheelEvent} e
*/
function onMouseWheel (e) { function onMouseWheel (e) {
this.body.range._onMouseWheel(e); this.body.range._onMouseWheel(e);
} }

+ 12
- 1
lib/timeline/component/DataScale.js View File

@ -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) { function DataScale(start, end, autoScaleStart, autoScaleEnd, containerHeight, majorCharHeight, zeroAlign = false, formattingFunction=false) {
this.majorSteps = [1, 2, 5, 10]; this.majorSteps = [1, 2, 5, 10];
this.minorSteps = [0.25, 0.5, 1, 2]; this.minorSteps = [0.25, 0.5, 1, 2];

+ 6
- 0
lib/timeline/component/graph2d_types/bar.js View File

@ -1,6 +1,12 @@
var DOMutil = require('../../../DOMutil'); var DOMutil = require('../../../DOMutil');
var Points = require('./points'); 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 function Bargraph(groupId, options) { // eslint-disable-line no-unused-vars
} }

+ 7
- 1
lib/timeline/component/graph2d_types/line.js View File

@ -1,5 +1,11 @@
var DOMutil = require('../../../DOMutil'); 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 function Line(groupId, options) { // eslint-disable-line no-unused-vars
} }
@ -18,7 +24,7 @@ Line.calcPath = function (dataset, group) {
return d; return d;
} }
} }
}
};
Line.drawIcon = function (group, x, y, iconWidth, iconHeight, framework) { Line.drawIcon = function (group, x, y, iconWidth, iconHeight, framework) {
var fillHeight = iconHeight * 0.5; var fillHeight = iconHeight * 0.5;

+ 20
- 2
lib/timeline/component/graph2d_types/points.js View File

@ -1,5 +1,12 @@
var DOMutil = require('../../../DOMutil'); 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 function Points(groupId, options) { // eslint-disable-line no-unused-vars
} }
@ -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); 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) { function getGroupTemplate(group, callbackResult) {
callbackResult = (typeof callbackResult === 'undefined') ? {} : callbackResult; callbackResult = (typeof callbackResult === 'undefined') ? {} : callbackResult;
return { return {
@ -53,6 +66,12 @@ function getGroupTemplate(group, callbackResult) {
}; };
} }
/**
*
* @param {Object} framework | SVG DOM element
* @param {vis.Group} group
* @returns {function}
*/
function getCallback(framework, group) { function getCallback(framework, group) {
var callback = undefined; var callback = undefined;
// check for the graph2d onRender // check for the graph2d onRender
@ -67,5 +86,4 @@ function getCallback(framework, group) {
return callback; return callback;
} }
module.exports = Points;
module.exports = Points;

+ 1
- 1
lib/timeline/component/item/BackgroundItem.js View File

@ -11,8 +11,8 @@ var RangeItem = require('./RangeItem');
* Conversion functions from time to screen and vice versa * Conversion functions from time to screen and vice versa
* @param {Object} [options] Configuration options * @param {Object} [options] Configuration options
* // TODO: describe options * // TODO: describe options
* // TODO: implement support for the BackgroundItem just having a start, then being displayed as a sort of an annotation
*/ */
// TODO: implement support for the BackgroundItem just having a start, then being displayed as a sort of an annotation
function BackgroundItem (data, conversion, options) { function BackgroundItem (data, conversion, options) {
this.props = { this.props = {
content: { content: {

+ 1
- 0
lib/util.js View File

@ -1583,6 +1583,7 @@ exports.getScrollBarWidth = function () {
return (w1 - w2); return (w1 - w2);
}; };
exports.topMost = function (pile, accessors) { exports.topMost = function (pile, accessors) {
let candidate; let candidate;
if (!Array.isArray(accessors)) { if (!Array.isArray(accessors)) {

Loading…
Cancel
Save