From a07ab00a5675f9fde4ac1ba4e20e6385b9b644bb Mon Sep 17 00:00:00 2001 From: noncomputable Date: Tue, 31 Jul 2018 15:42:21 -0400 Subject: [PATCH] updates jsdocs --- package.json | 1 + src/agents.js | 17 ++++++++--------- src/buildings.js | 10 ---------- src/jsdocs.js | 38 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 47 insertions(+), 19 deletions(-) create mode 100644 src/jsdocs.js diff --git a/package.json b/package.json index 0015d1a..9500a29 100644 --- a/package.json +++ b/package.json @@ -6,6 +6,7 @@ "test": "echo \"Error: no test specified\" && exit 1", "bundle": "npx webpack", "prepublish": "npm run bundle", + "make-docs": "jsdoc src site/docs/DOCS.md -d site/docs", "publish-pages": "gh-pages -d site" }, "main": "src/index.js", diff --git a/src/agents.js b/src/agents.js index fd0af6b..f79182c 100644 --- a/src/agents.js +++ b/src/agents.js @@ -10,14 +10,7 @@ encodeLatLng = require('./routing').encodeLatLng; /* Here we define agentify, the agent base class, and all other functions and definitions they rely on. */ /** - * @typedef {Feature} Point - * @property {Array} geometry.coordinates - This should be a single array with 2 elements: the point's coordinates. - * - * An extension of {@link Feature} for points. - */ - -/** - * Callback that gives a feature with appropriate geometry and properties to represent an agent. + * User-defined callback that gives a feature with appropriate geometry and properties to represent an agent. * * @callback agentFeatureMaker * @param {number} i - A number used to determine the agent's coordinates and other properties. @@ -29,6 +22,7 @@ encodeLatLng = require('./routing').encodeLatLng; /** * A standard featureMaker callback, which sets an agent's location as the center of a unit on the map. * + * @memberof Agentmap * @type {agentFeatureMaker} */ function seqUnitAgentMaker(i){ @@ -88,6 +82,7 @@ function agentify(count, agentFeatureMaker) { /** * The main class representing individual agents, using Leaflet class system. + * @private * * @class Agent */ @@ -95,7 +90,8 @@ let Agent = L.Layer.extend({}); /** * Constructor for the Agent class, using Leaflet class system. - * + * + * @name Agent * @constructor * @param {Array} latLng - A pair of coordinates to place the agent at. * @param {Object} options - An array of options for the agent, namely its layer. @@ -423,6 +419,7 @@ Agent.moveDirectly = function(animation_interval, intermediary_interval, steps_i //Intermediary movements. for (let i = 0; i < steps_inbetween; ++i) { move(intermediary_interval); + if (state.traveling === false) { return; } @@ -454,6 +451,8 @@ Agent.update = function(animation_interval, intermediary_interval, steps_inbetwe /** * Returns an agent object. + * + * @memberof Agentmap */ function agent(feature, options, agentmap) { return new L.A.Agent(feature, options, agentmap); diff --git a/src/buildings.js b/src/buildings.js index 74667a1..b658e10 100644 --- a/src/buildings.js +++ b/src/buildings.js @@ -9,16 +9,6 @@ getPathFinder = require('./routing').getPathFinder; /* Here we define buildingify and all other functions and definitions it relies on. */ -/** - * @typedef {object} Feature - * @property {string} type - Should be Feature. - * @property {object} properties - Non-geometric properties describing the map feature. - * @property {object} geometry - Specification of the feature's geometry. - * @property {string} geometry.type - The feature's GeoJSON geometry type - * @property {Array} geometry.coordinates - The coordinates specifying the feature's geometry. - * @see {@link http://geojson.org/} - */ - /** * Generate and setup the desired map features (e.g. streets, houses). * diff --git a/src/jsdocs.js b/src/jsdocs.js new file mode 100644 index 0000000..0a3c628 --- /dev/null +++ b/src/jsdocs.js @@ -0,0 +1,38 @@ +/* Extra JSDocs that aren't particular to any module */ + +/** + * Represents a latitude/longitude pair. Preferably an instance of L.LatLng: + * {@link https://leafletjs.com/reference-1.3.2.html#latlng}. + * + * @typedef {object} LatLng + * @property {number} lat - A decimal latitude. + * @property {number} lng - A decimal longitude. + * @property {Place} [new_place] - A place (unit or street) associated with this LatLng. + */ + +/** + * A GeoJSON feature object. + * + * @typedef {object} Feature + * @property {string} type - Should be "Feature". + * @property {object} properties - Non-geometric properties of the feature. + * @property {object} geometry - Geometric properties of the feature (a GeoJSON spec of the feature's geometry). + * @property {string} geometry.type - The feature's GeoJSON geometry type. + * @property {Array} geometry.coordinates - The coordinates specifying the feature's geometry. + * @see {@link http://geojson.org/} + */ + +/** + * A GeoJSON {@link Feature} specifically for individual points. + * + * @typedef {Feature} Point + * @property {Array} geometry.coordinates - A single array with 2 elements: [longitude, latitude]. + */ + +/** + * A place representing either a unit or a street. + * + * @typedef {object} Place + * @property {number} [street] - The ID of a street in the agentmap's street layer group. + * @property {number} [unit] - The ID of a unit in the agentmap's unit layer group. + */