Skip to content

Commit d0e840f

Browse files
committed
Improve documentation of models/box
1 parent 09403c7 commit d0e840f

File tree

3 files changed

+63
-37
lines changed

3 files changed

+63
-37
lines changed

client/models/addon.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,18 @@ define([
2121
'state': "notloaded" // addons state: "notloaded", "loaded", "error"
2222
},
2323

24-
// Return base url for the addon
24+
/**
25+
* Return base url for the addon
26+
*/
2527
url: function() {
2628
var basePath = window.location.pathname;
2729
basePath = basePath.substring(0, basePath.lastIndexOf('/')+1);
2830
return basePath+"static/addons/"+this.get("name");
2931
},
3032

31-
// Load the addon
33+
/**
34+
* Load the addon
35+
*/
3236
load: function(config, imports) {
3337
var context, main, addonRequireConfig,
3438
addonRequire, that = this
@@ -82,7 +86,9 @@ define([
8286
return d.promise.timeout(5000, "This addon took to long to load (> 5seconds)");
8387
},
8488

85-
// Return version as an int
89+
/**
90+
* Return version as a number
91+
*/
8692
version: function() {
8793
return parseInt(this.get("version").replace(/\./g,""));
8894
}

client/models/box.js

Lines changed: 53 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,15 @@ define([
2121
'auth': false
2222
},
2323

24-
/*
25-
* Client interface to a codebox
26-
*/
2724
initialize: function() {
2825
Codebox.__super__.initialize.apply(this, arguments);
2926

3027
this.baseUrl = this.options.baseUrl || "";
3128

29+
/** Current authenticated user */
3230
this.user = null;
3331

34-
// Root file
32+
/** Root file */
3533
this.root = new File({
3634
'codebox': this
3735
});
@@ -40,17 +38,17 @@ define([
4038
this.root.set("name", this.get("name"));
4139
}, this);
4240

43-
// Active file
41+
/** Active file */
4442
this.activeFile = "/";
4543

46-
// Connect to events
44+
/** Connect to events stream */
4745
this.listenEvents();
4846

4947
return this;
5048
},
5149

52-
/*
53-
* Subscribe to events from codebox using socket.io
50+
/**
51+
* Subscribe to events from codebox using socket.io
5452
*/
5553
listenEvents: function() {
5654
var that = this;
@@ -86,11 +84,11 @@ define([
8684
});
8785
},
8886

89-
/*
90-
* Socket for the connection
87+
/**
88+
* Socket for the connection
9189
*
92-
* @namespace : namespace for the socket
93-
* @forceCreate : force creation of a new socket
90+
* @param {string} namespace namespace for the socket
91+
* @param {boolean} forceCreate force creation of a new socket
9492
*/
9593
socket: function(namespace, forceCreate) {
9694
if (this.baseUrl == null) {
@@ -108,8 +106,11 @@ define([
108106
return Q(socket);
109107
},
110108

111-
/*
112-
* Join the box
109+
/**
110+
* Join the box
111+
*
112+
* @param {object} authInfos argument for authentication service
113+
* @param {User} user
113114
*/
114115
auth: function(authInfo, user) {
115116
var that = this;
@@ -126,15 +127,19 @@ define([
126127
});
127128
},
128129

129-
/*
130-
* test if logged to the box
130+
/**
131+
* Check if user is logged to the box
132+
*
133+
* @return {boolean}
131134
*/
132135
isAuth: function() {
133136
return this.get("auth", false);
134137
},
135138

136-
/*
137-
* Get box status
139+
/**
140+
* Get box status
141+
*
142+
* @return {promise}
138143
*/
139144
status: function() {
140145
var that = this;
@@ -144,31 +149,40 @@ define([
144149
});
145150
},
146151

147-
/*
148-
* Get list of collaborators
152+
/**
153+
* Get list of collaborators
154+
*
155+
* @return {promise}
149156
*/
150157
collaborators: function() {
151158
return rpc.execute("users/list");
152159
},
153160

154-
/*
155-
* Search files
161+
/**
162+
* Search files
163+
*
164+
* @param q query string
165+
* @return {promise}
156166
*/
157167
searchFiles: function(q) {
158168
return rpc.execute("search/files", {
159169
"query": q
160170
});
161171
},
162172

163-
/*
173+
/**
164174
* Get a runner
175+
*
176+
* @return {promise}
165177
*/
166178
runner: function(options) {
167179
return rpc.execute("run/list", options);
168180
},
169181

170-
/*
171-
* Open a shell
182+
/**
183+
* Open a shell
184+
*
185+
* @return {TerminalView}
172186
*/
173187
openTerminal: function(shellId, _op) {
174188
var terminal = Command.run("terminal.open", shellId);
@@ -190,7 +204,7 @@ define([
190204
return terminal;
191205
},
192206

193-
/*
207+
/**
194208
* Run the project
195209
*/
196210
run: function(options) {
@@ -201,31 +215,37 @@ define([
201215
});
202216
},
203217

204-
/*
205-
* Open a shell
218+
/**
219+
* Open a shell
220+
*
221+
* @return {Shell}
206222
*/
207223
openShell: function(args) {
208224
args = args || {};
209225
args.codebox = this;
210226
return new Shell(args);
211227
},
212228

213-
/*
229+
/**
214230
* List shells open
231+
*
232+
* @return {promise}
215233
*/
216234
listShells: function() {
217235
return rpc.execute("shells/list");
218236
},
219237

220-
/*
221-
* Return running http process
238+
/**
239+
* Return running http process
240+
*
241+
* @return {promise}
222242
*/
223243
procHttp: function() {
224244
return rpc.execute("proc/http");
225245
},
226246

227-
/*
228-
* Set active file
247+
/**
248+
* Set a file (by its path) as active
229249
*/
230250
setActiveFile: function(path) {
231251
if (!_.isString(path)) {

client/models/change.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ define([
2121
'offline': false
2222
},
2323

24-
// apply the change
24+
// Apply the change
2525
apply: function() {
2626
var that = this;
2727
var vfs = require("core/backends/vfs");

0 commit comments

Comments
 (0)