Skip to content

Commit 12fa93a

Browse files
committed
fixing documentation
1 parent 10795fe commit 12fa93a

File tree

7 files changed

+118
-25
lines changed

7 files changed

+118
-25
lines changed

app/components/location/locationDirective.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
/**
2+
* @ngdoc directive
3+
* @name location
4+
* @plm
5+
*
6+
* @description
7+
* A directive for rendering an icon with label underneath and a tooltip
8+
*
9+
*/
110
Components.directive('location', function () {
211
return {
312
restrict: 'E', //E = element, A = attribute, C = class, M = comment

app/components/skycon/skyconDirective.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
/**
2+
* @ngdoc directive
3+
* @name skycon
4+
*
5+
* @description
6+
* A directive for rendering an icon from skycons
7+
*/
18
Components.directive('skycon', function () {
29
return {
310
restrict: 'E', //E = element, A = attribute, C = class, M = comment

app/forecast/forecast.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
/**
2+
* @ngdoc controller
3+
* @name ForecastCtrl
4+
*
5+
* @description
6+
* A controller that loads the data for a location making it available for the view
7+
*/
18
'use strict';
29

310
angular.module('darkskyForecast.forecast', ['ngRoute'])

app/main/locationsService.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,23 @@
1+
/**
2+
* @ngdoc service
3+
* @name locationsService
4+
*
5+
* @description
6+
* A service used for fetching the list of available locations from a .json file.
7+
* Might later be used to fetch the list from a server.
8+
*/
19
'use strict';
210

311
angular.module('darkskyForecast.main')
412
.service('locationsService', function ($q, $http) {
13+
14+
/**
15+
* @ngdoc function
16+
* @name getLocations
17+
*
18+
* @returns {Array} list of locations
19+
*
20+
*/
521
this.getLocations = function () {
622
var deferred = $q.defer();
723

app/main/main.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
/**
2+
* @ngdoc controller
3+
* @name MainCtrl
4+
*
5+
* @description
6+
* A controller for fetching the coordinates and the current
7+
* weather for a selected location and storing them in the local storage
8+
*/
19
'use strict';
210

311
angular.module('darkskyForecast.main', ['ngRoute'])
@@ -17,6 +25,15 @@ angular.module('darkskyForecast.main', ['ngRoute'])
1725
$scope.locations = locations;
1826
})
1927

28+
/**
29+
* @ngdoc function
30+
* @name displayWeather
31+
* @description A function that fetches the coordinates and the current weather for a
32+
* selected location and stores them in the local storage
33+
*
34+
* @param {Number} index the clicked location index
35+
*
36+
*/
2037
$scope.displayWeather = function (index) {
2138
var locationDetails = $scope.locations[index];
2239
var location = locationDetails.id;

app/services/coordinatesService.js

Lines changed: 47 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,53 @@
1+
/**
2+
* @ngdoc overview
3+
* @name service.coordService
4+
*/
15
'use strict';
26

37
angular.module('service.coordService', [])
4-
.service('coordService', function ($q, $http, GOOGLE_API) {
5-
this.getCoords = function (location) {
6-
var deferred = $q.defer();
78

8-
$http({
9-
method: 'GET',
10-
timeout: 300000,
11-
url: GOOGLE_API.URL,
12-
params: {
13-
'address': location,
14-
'key': GOOGLE_API.KEY
15-
}
16-
})
17-
.then(function (data) {
18-
if (parseInt(data.status) === 200) {
19-
deferred.resolve(data.data.results[0].geometry.location);
20-
} else {
21-
deferred.reject(data.status);
22-
}
9+
/**
10+
* @ngdoc method
11+
* @methodOf service.coordService.coordService
12+
* @name coordService
13+
*
14+
* @description
15+
* A service used for fetching the coordinates of a location via http.
16+
*/
17+
.service('coordService', function ($q, $http, GOOGLE_API) {
2318

24-
})
25-
.catch(function (data) {
26-
deferred.reject(data.error_message);
27-
});
19+
/**
20+
* @ngdoc function
21+
* @name getCoords
22+
*
23+
* @param {String} location the location name
24+
* @returns {Object} object containing the latitude and longitude
25+
*
26+
*/
27+
this.getCoords = function (location) {
28+
var deferred = $q.defer();
2829

29-
return deferred.promise;
30-
}
31-
});
30+
$http({
31+
method: 'GET',
32+
timeout: 300000,
33+
url: GOOGLE_API.URL,
34+
params: {
35+
'address': location,
36+
'key': GOOGLE_API.KEY
37+
}
38+
})
39+
.then(function (data) {
40+
if (parseInt(data.status) === 200) {
41+
deferred.resolve(data.data.results[0].geometry.location);
42+
} else {
43+
deferred.reject(data.status);
44+
}
45+
46+
})
47+
.catch(function (data) {
48+
deferred.reject(data.error_message);
49+
});
50+
51+
return deferred.promise;
52+
}
53+
});

app/services/forecastService.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,23 @@
1+
/**
2+
* @ngdoc function
3+
* @name forecastService
4+
*
5+
* @description
6+
* A service used for fetching the current weather data via http.
7+
*/
18
'use strict';
29

310
angular.module('service.forecastService', [])
411
.service('forecastService', function ($q, $http, $sce, DARKSKY_API) {
512

13+
/**
14+
* @ngdoc function
15+
* @name getWeather
16+
*
17+
* @param {Object} coords an object with lat (latitude) and lng (longitude) parameters
18+
* @returns {Object} object containing current weather data
19+
*
20+
*/
621
this.getWeather = function (coords) {
722
var deferred = $q.defer();
823

0 commit comments

Comments
 (0)