Skip to content

Commit

Permalink
First step in tsdoc generation and typescript type check
Browse files Browse the repository at this point in the history
  • Loading branch information
sbrunner committed Nov 19, 2018
1 parent aca7578 commit 651c1da
Show file tree
Hide file tree
Showing 7 changed files with 83 additions and 59 deletions.
39 changes: 21 additions & 18 deletions contribs/gmf/src/raster/RasterService.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import * as angular from 'angular';

/**
* @module gmf.raster.RasterService
*/
Expand All @@ -7,7 +9,7 @@
* information at a specific coordinate.
* @constructor
* @struct
* @param {angular.$http} $http Angular http service.
* @param {angular.IHttpService} $http Angular http service.
* @param {string} gmfRasterUrl URL to a the c2cgeoportal raster service.
* @ngInject
* @ngdoc service
Expand All @@ -16,7 +18,7 @@
const exports = function($http, gmfRasterUrl) {

/**
* @type {angular.$http}
* @type {angular.IHttpService}
* @private
*/
this.$http_ = $http;
Expand All @@ -29,17 +31,26 @@ const exports = function($http, gmfRasterUrl) {
};


/**
* @enum {string}
*/
const Param = {
X: 'lon',
Y: 'lat'
};


/**
* @param {ol.Coordinate} coordinate Coordinate.
* @param {Object=} opt_params Optional parameters for the request.
* @return {angular.$q.Promise} Promise.
* @return {angular.IPromise} Promise.
* @export
*/
exports.prototype.getRaster = function(coordinate, opt_params) {

const params = opt_params || {};
params[exports.Param.X] = coordinate[0];
params[exports.Param.Y] = coordinate[1];
params[Param.X] = coordinate[0];
params[Param.Y] = coordinate[1];

return this.$http_.get(this.url_, {
params
Expand All @@ -48,7 +59,7 @@ exports.prototype.getRaster = function(coordinate, opt_params) {


/**
* @param {angular.$http.Response} resp Ajax response.
* @param {angular.IHttpResponse} resp Ajax response.
* @return {Object.<string, number>} The response object.
* @private
*/
Expand All @@ -58,19 +69,11 @@ exports.prototype.handleGetRaster_ = function(resp) {


/**
* @enum {string}
*/
exports.Param = {
X: 'lon',
Y: 'lat'
};


/**
* @type {!angular.Module}
* @type {!angular.IModule}
*/
exports.module = angular.module('gmfRaster', []);
exports.module.service('gmfRaster', exports);
const module = angular.module('gmfRaster', []);
exports['module'] = module;
module.service('gmfRaster', exports);


export default exports;
46 changes: 25 additions & 21 deletions contribs/gmf/src/raster/component.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/**
* @module gmf.raster.component
*/
import * as angular from 'angular';
import gmfRasterRasterService from 'gmf/raster/RasterService.js';
import googAsserts from 'goog/asserts.js';

Expand All @@ -13,10 +14,11 @@ import 'bootstrap/js/src/dropdown.js';


/**
* @type {!angular.Module}
*/
* @type {!angular.IModule}
* @hidden
*/
const exports = angular.module('gmfRasterComponent', [
gmfRasterRasterService.module.name,
gmfRasterRasterService['module'].name,
ngeoMiscDebounce.name,
]);

Expand All @@ -39,6 +41,7 @@ exports.value('gmfElevationwidgetTemplateUrl',


/**
* @hidden
* @param {!angular.Attributes} $attrs Attributes.
* @param {!function(!angular.Attributes): string} gmfElevationwidgetTemplateUrl Template function.
* @return {string} Template URL.
Expand Down Expand Up @@ -89,7 +92,7 @@ function gmfElevationwidgetTemplateUrl($attrs, gmfElevationwidgetTemplateUrl) {
* @ngdoc directive
* @ngname gmfElevation
*/
exports.component_ = function() {
function component() {
return {
restrict: 'A',
controller: 'GmfElevationController as ctrl',
Expand Down Expand Up @@ -117,12 +120,13 @@ exports.component_ = function() {
}.bind(ctrl));
}
};
};
}


exports.directive('gmfElevation', exports.component_);
exports.directive('gmfElevation', component);

/**
* @hidden
* @param {!angular.Scope} $scope Scope.
* @param {!angular.$filter} $filter Angular filter.
* @param {!ngeox.miscDebounce} ngeoDebounce Ngeo debounce factory
Expand All @@ -134,7 +138,7 @@ exports.directive('gmfElevation', exports.component_);
* @ngdoc controller
* @ngname gmfElevationController
*/
exports.Controller_ = function($scope, $filter, ngeoDebounce, gmfRaster, gettextCatalog) {
function Controller($scope, $filter, ngeoDebounce, gmfRaster, gettextCatalog) {

/**
* @type {!angular.$filter}
Expand Down Expand Up @@ -210,14 +214,14 @@ exports.Controller_ = function($scope, $filter, ngeoDebounce, gmfRaster, gettext
* @export
*/
this.loading = false;
};
}

/**
* Activate or deactivate the request of the raster each 500 ms on pointermove.
* @param {boolean} active true to make requests.
* @private
*/
exports.Controller_.prototype.toggleActive_ = function(active) {
Controller.prototype.toggleActive_ = function(active) {
this.elevation = undefined;
if (active) {
googAsserts.assert(this.listenerKeys_.length === 0);
Expand Down Expand Up @@ -259,7 +263,7 @@ exports.Controller_.prototype.toggleActive_ = function(active) {
* @param {ol.MapBrowserPointerEvent} e An ol map browser pointer event.
* @private
*/
exports.Controller_.prototype.pointerStop_ = function(e) {
Controller.prototype.pointerStop_ = function(e) {
if (this.inViewport_) {
this.loading = true;
const params = {
Expand All @@ -277,7 +281,7 @@ exports.Controller_.prototype.pointerStop_ = function(e) {
* @param {Object.<string, number>} resp Response of the get Raster service.
* @private
*/
exports.Controller_.prototype.getRasterSuccess_ = function(resp) {
Controller.prototype.getRasterSuccess_ = function(resp) {
googAsserts.assert(this.layer, 'A layer should be selected');
const value = resp[this.layer];
if (value !== undefined && value !== null) {
Expand All @@ -300,14 +304,14 @@ exports.Controller_.prototype.getRasterSuccess_ = function(resp) {
/**
* @private
*/
exports.Controller_.prototype.getRasterError_ = function() {
Controller.prototype.getRasterError_ = function() {
console.error('Error on getting the raster.');
this.elevation = undefined;
this.loading = false;
};


exports.controller('GmfElevationController', exports.Controller_);
exports.controller('GmfElevationController', Controller);


/**
Expand All @@ -331,7 +335,7 @@ exports.controller('GmfElevationController', exports.Controller_);
* @ngdoc component
* @ngname gmfElevationwidget
*/
exports.widgetComponent_ = {
const widgetComponent = {
controller: 'gmfElevationwidgetController as ctrl',
bindings: {
'map': '<gmfElevationwidgetMap',
Expand All @@ -341,15 +345,16 @@ exports.widgetComponent_ = {
},
templateUrl: gmfElevationwidgetTemplateUrl
};
exports.component('gmfElevationwidget', exports.widgetComponent_);
exports.component('gmfElevationwidget', widgetComponent);


/**
* @constructor
* @private
* @hidden
* @ngdoc controller
*/
exports.WidgetController_ = function() {
function WidgetController() {
/**
* @type {!ol.Map}
* @export
Expand Down Expand Up @@ -379,24 +384,23 @@ exports.WidgetController_ = function() {
* @export
*/
this.selectedElevationLayer;
};
}


exports.WidgetController_.prototype.$onInit = function() {
WidgetController.prototype.$onInit = function() {
this.selectedElevationLayer = this.layers[0];
};


exports.controller('gmfElevationwidgetController', exports.WidgetController_);
exports.controller('gmfElevationwidgetController', WidgetController);

/**
* @typedef {{
* filter: (string|undefined),
* args: (Array.<string>|undefined),
* postfix: (string|undefined),
* separator: (string|undefined)
* }}
* }} LayerConfig
*/
exports.LayerConfig;

export default exports;
5 changes: 3 additions & 2 deletions contribs/gmf/src/raster/module.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
/**
* @module gmf.raster.module
*/
import * as angular from 'angular';
import gmfRasterComponent from 'gmf/raster/component.js';
import gmfRasterRasterService from 'gmf/raster/RasterService.js';

/**
* @type {!angular.Module}
* @type {!angular.IModule}
*/
const exports = angular.module('gmfRasterModule', [
gmfRasterComponent.name,
gmfRasterRasterService.module.name,
gmfRasterRasterService['module'].name,
]);


Expand Down
6 changes: 0 additions & 6 deletions options/ngeox.js
Original file line number Diff line number Diff line change
Expand Up @@ -310,12 +310,6 @@ ngeox.IssueGetFeaturesOptions.prototype.wfsCount;
ngeox.MapFeatureOverlayGroup;


/**
* Provides a debounce function used to debounce calls to a user-provided
* function.
* @typedef {function(function(?), number, boolean):function()}
*/
ngeox.miscDebounce;


/**
Expand Down
14 changes: 12 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
"serve-ngeo-examples": "DEV_SERVER=1 TARGET=ngeo-examples webpack-dev-server --https --cert=private.crt --key=private.key --port 3000 --progress --watch --bail --debug",
"serve-gmf-examples": "DEV_SERVER=1 TARGET=gmf-examples webpack-dev-server --https --cert=private.crt --key=private.key --port 3000 --progress --watch --bail --debug",
"serve-gmf-apps": "DEV_SERVER=1 TARGET=gmf-apps webpack-dev-server --https --cert=private.crt --key=private.key --port 3000 --progress --watch --bail --debug",
"serve-api": "webpack-dev-server --mode development --content-base api/dist/ --config buildtools/webpack.api.js --https --cert=private.crt --key=private.key --port 3000 --progress --watch --bail --debug"
"serve-api": "webpack-dev-server --mode development --content-base api/dist/ --config buildtools/webpack.api.js --https --cert=private.crt --key=private.key --port 3000 --progress --watch --bail --debug",
"typecheck": "tsc --pretty",
"doc": "typedoc --module system --target ES6 --name ngeo --out apidoc src/ contribs/gmf/src/"
},
"repository": {
"type": "git",
Expand All @@ -24,14 +26,18 @@
"compile-catalog": "buildtools/compile-catalog.js"
},
"devDependencies": {
"@geoblocks/sources": "https://api.github.com/repos/geoblocks/sources/tarball/173ad0171",
"@babel/core": "7.1.6",
"@babel/plugin-syntax-object-rest-spread": "7.0.0",
"@babel/plugin-transform-spread": "7.0.0",
"@babel/preset-env": "7.1.6",
"@camptocamp/babel-plugin-angularjs-annotate": "0.8.2",
"@camptocamp/cesium": "1.51.0",
"@fortawesome/fontawesome-free": "5.5.0",
"@geoblocks/sources": "https://api.github.com/repos/geoblocks/sources/tarball/173ad0171",
"@types/angular": "1.6.51",
"@types/d3": "5.0.1",
"@types/ol": "4.6.2",
"@types/proj4": "2.3.4",
"angular": "1.7.5",
"angular-animate": "1.7.5",
"angular-dynamic-locale": "0.1.37",
Expand Down Expand Up @@ -108,6 +114,10 @@
"svg-inline-loader": "0.8.0",
"svgo": "1.1.0",
"svgo-loader": "2.2.0",
"ts-node": "7.0.1",
"tsconfig-paths": "3.6.0",
"typedoc": "0.13.0",
"typescript": "3.1.6",
"uglify-js": "3.4.9",
"uglifyjs-webpack-plugin": "2.0.1",
"url-loader": "1.1.2",
Expand Down
4 changes: 2 additions & 2 deletions src/goog.asserts.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ exports.doAssertFailure_ = function(
* Sets a custom error handler that can be used to customize the behavior of
* assertion failures, for example by turning all assertion failures into log
* messages.
* @param {function(!goog.asserts.AssertionError)} errorHandler
* @param {function(!object)} errorHandler
*/
exports.setErrorHandler = function(errorHandler) {
if (exports.ENABLE_ASSERTS) {
Expand Down Expand Up @@ -268,7 +268,7 @@ exports.assertElement = function(value, opt_message, var_args) {
* The compiler may tighten the type returned by this function.
*
* @param {?} value The value to check.
* @param {function(new: T, ...)} type A user-defined constructor.
* @param {function(new: T)} type A user-defined constructor.
* @param {string=} opt_message Error message in case of failure.
* @param {...*} var_args The items to substitute into the failure message.
* @throws {goog.asserts.AssertionError} When the value is not an instance of
Expand Down

0 comments on commit 651c1da

Please sign in to comment.