Skip to content

Commit

Permalink
add jsdoc all over the place
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexandre Masselot committed Aug 1, 2014
1 parent 9116df5 commit 12c6192
Show file tree
Hide file tree
Showing 23 changed files with 2,459 additions and 2,206 deletions.
16 changes: 13 additions & 3 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,17 @@ module.exports = function(grunt) {
ui: 'bdd',
require: [
'should',
],
},
]
}
}
},
jsdoc : {
dist : {
src: ['src/js/**/*.js'],
options: {
destination: 'examples/doc',
private:false
}
}
}

Expand All @@ -152,12 +161,13 @@ module.exports = function(grunt) {
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-jsdoc');

// Default task(s).
grunt.registerTask('build_x', ['requirejs', 'concat:concat_copyright']);
grunt.registerTask('default', ['build']);
grunt.registerTask('test', ['mocha-server']);

grunt.registerTask('build', ['build_x', 'copy:dist', 'copy:dist-examples']);
grunt.registerTask('build', ['build_x', 'copy:dist', 'copy:dist-examples', 'jsdoc']);

};
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,11 @@ Via jasmine, either in the browser ([test/index.html](test/index.html)) or comma
####Continuous integration
test, distribution etc. can be launched in a CI environment via grunt tasks <code>grunt test, build...</code>

####Build code documentation
JsDoc3 annotations were used to document the library. To generate the doc (in examples/doc directory):

grunt jsdoc

###Authors
This library was initiated by
Alexandre Masselot (masselot.alexandre@gene.com) & Kiran Mukhyala (mukhyala.kiran@gene.com) within Genentech Bioinformatics & Computational Biology Department.
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"grunt-contrib-concat": "~0.3.0",
"grunt-cli": "~0.1.11",
"grunt-contrib-copy": "~0.4.1",
"grunt-contrib-clean": "~0.5.0"
"grunt-contrib-clean": "~0.5.0",
"grunt-jsdoc": "^0.5.6"
}
}
38 changes: 22 additions & 16 deletions src/js/collections/FeatureLayerCollection.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,23 @@
/*
* Copyright (c) 2013, Genentech Inc.
* Authors: Alexandre Masselot, Kiran Mukhyala, Bioinformatics & Computational Biology
*/
define(['backbone', '../models/PositionedFeature'], function(bb, PositionedFeature) {
return bb.Collection.extend({
model : PositionedFeature,
group : function() {
var self = this;
return _.groupBy(self.models, function(ft) {
return (ft.groupSet ? (ft.groupSet + '/:') : '') + ft.category;
define(
/**
@exports FeatureLayerCollection
@author Alexandre Masselot
@author Kiran Mukhyala
@copyright 2013, Bioinformatics & Computational Biology Department, Genentech Inc.
*/
['backbone', '../models/FeatureLayer'], function (bb, FeatureLayer) {
/**
* a collection of FeatureLayer, follows backbone collection mechanisms
* @constructor
* @augments Backbone.Collection
*/
var FeatureLayerCollection = bb.Collection.extend(
/**
* @lends module:FeatureLayerCollection~FeatureLayerCollection.prototype
*/
{
model: FeatureLayer

})
}
})

})
});
return FeatureLayerCollection;
});
7 changes: 0 additions & 7 deletions src/js/collections/PositionedFeatureCollection.js

This file was deleted.

56 changes: 39 additions & 17 deletions src/js/models/FeatureLayer.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,40 @@
/*
* Copyright (c) 2013, Genentech Inc.
* Authors: Alexandre Masselot, Kiran Mukhyala, Bioinformatics & Computational Biology
*/
define(['underscore', 'backbone'], function(_, bb) {
var FeatureLayer = bb.Model.extend({
defaults : {
visible : true
},
initialize : function(options) {
},
type : function() {
return this.get('type') || this.get('name');
}
});

return FeatureLayer;
});
define(
/**
@exports FeatureLayer
@author Alexandre Masselot
@author Kiran Mukhyala
@copyright 2013, Bioinformatics & Computational Biology Department, Genentech Inc.
*/
['underscore', 'backbone'], function (_, bb) {

/**
* FeatureLayer regroups all the PositionedFeature of a same type
* @constructor
* @augments Backbone.Model
*
* @param {Map} options
* @param {String} options.type is only compulsory member
* @param {boolean} options.visible is the layer to be shown. Default is true
*/
var FeatureLayer = bb.Model.extend(
/**
* @lends module:FeatureLayer~FeatureLayer.prototype
*/
{
defaults: {
visible: true
},
initialize: function (options) {
},
/**
* The object type, based on the type or name attribute
*
* @return {String} the type key
*/
type: function () {
return this.get('type') || this.get('name');
}
});
return FeatureLayer;
});
42 changes: 29 additions & 13 deletions src/js/models/PositionedFeature.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,30 @@
/*
* Copyright (c) 2013, Genentech Inc.
* Authors: Alexandre Masselot, Kiran Mukhyala, Bioinformatics & Computational Biology
*/
define(['underscore'], function(_) {
var PositionedFeature = function(options) {
var self = this;
_.each(['start', 'end', 'type', 'category', 'description', 'displayTrack', 'text', 'groupSet'], function(name) {
self[name] = options[name]
})
}

return PositionedFeature;
});
define(
/**
@exports PositionedFeature
@author Alexandre Masselot
@author Kiran Mukhyala
@copyright 2013, Bioinformatics & Computational Biology Department, Genentech Inc.
*/
['underscore'], function (_) {
/**
* @class PositionedFeature, corresponding to the basic component to be displayed. There is no limit among the feature member. However, a few a given by default
* @constructor
* @param {Map} options
* @param {int} options.start [compulsory] the starting position, (first one is 0)
* @param {int} options.end [compulsory] the ending position
* @param {String} options.type [compulsory] will be used to define how to draw the feature
* @param {String} options.category [compulsory] all the feature below the same category are regrouped together
* @param {String} options.groupSet a super category
* @param {String} options.text a description to be displayed by default
*
*/
var PositionedFeature = function (options) {
var self = this;
_.each(['start', 'end', 'type', 'category', 'description', 'displayTrack', 'text', 'groupSet'], function (name) {
self[name] = options[name]
})
}

return PositionedFeature;
});
116 changes: 73 additions & 43 deletions src/js/models/SeqEntry.js
Original file line number Diff line number Diff line change
@@ -1,47 +1,77 @@
/*
* Copyright (c) 2013, Genentech Inc.
* Authors: Alexandre Masselot, Kiran Mukhyala, Bioinformatics & Computational Biology
*/
define(['underscore', 'backbone'], function(_, Backbone) {
var SeqEntry = Backbone.Model.extend({
defaults : {
define(
/**
@exports SeqEntry
@author Alexandre Masselot
@author Kiran Mukhyala
@copyright 2013, Bioinformatics & Computational Biology Department, Genentech Inc.
*/
['underscore', 'backbone'], function (_, Backbone) {
/**
* A SeqEntry object holds the sequence and the list of PositionedFeature
* @constructor
* @augments Backbone.Model
*
* @param {Map} options
* @param {String} options.sequence is the layer to be shown. Default is true
* @param {Array} options.features an array of object (will be mapped into PositionedFeature)
*/
var SeqEntry = Backbone.Model.extend(
/**
* @lends module:SeqEntry~SeqEntry.prototype
*/
{
defaults: {

},
initialize : function() {
this.set('features', []);
},
length : function() {
var seq = this.get('sequence');
return (seq === undefined) ? 0 : seq.length
},
addFeatures : function(feats, options) {
var self = this;
options = options || {};
},
initialize: function () {
this.set('features', []);
},
/**
*
* @return {integer} sequence length
*/
length: function () {
var seq = this.get('sequence');
return (seq === undefined) ? 0 : seq.length
},
/**
* Add san array or a single feature to the seq entry. A 'change' event will be triggered by default. The Backbone view will be binded to such changes
* @param {Array|Object} feats
* @param {Map} options
* @param {boolean} options.triggerChange defines is a 'change' event is to be fired (default is true)
* @return {SeqEntry}
*/
addFeatures: function (feats, options) {
var self = this;
options = options || {};

var triggerChange = options.triggerChange || (options.triggerChange === undefined);
var triggerChange = options.triggerChange || (options.triggerChange === undefined);

if (_.isArray(feats)) {
_.each(feats, function(ft) {
ft.start = parseInt(ft.start);
ft.end = parseInt(ft.end);
self.get('features').push(ft);
})
if (triggerChange)
self.trigger('change');
return self;
}
self.get('features').push(feats);
if (triggerChange)
self.trigger('change');
return self;
},
clear : function() {
this.get('features').length = 0
this.trigger('change');
return this;
if (_.isArray(feats)) {
_.each(feats, function (ft) {
ft.start = parseInt(ft.start);
ft.end = parseInt(ft.end);
self.get('features').push(ft);
})
if (triggerChange)
self.trigger('change');
return self;
}
self.get('features').push(feats);
if (triggerChange)
self.trigger('change');
return self;
},
/**
* Removes all the features (and fire a 'change' event
* @return {SeqEntry}
*/
clear: function () {
this.get('features').length = 0
this.trigger('change');
return this;

}
//urlRoot:'das/json'
})
return SeqEntry;
})
}
});
return SeqEntry;
});
Loading

0 comments on commit 12c6192

Please sign in to comment.