Skip to content

Commit 8e27dfb

Browse files
committed
docstrings final
1 parent 2b5e670 commit 8e27dfb

File tree

2 files changed

+68
-14
lines changed

2 files changed

+68
-14
lines changed

src/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -541,7 +541,6 @@ function addCommands(
541541
icon: saveIcon,
542542
execute: (args) => {
543543
const dashboard = dashboardTracker.currentWidget;
544-
dashboard.model.path;
545544
dashboard.context.save();
546545
},
547546
isEnabled: (args) => inToolbar(args) || hasDashboard(),

src/model.ts

Lines changed: 68 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,6 @@ export interface IDashboardModel extends DocumentRegistry.IModel {
6767
*/
6868
mode: Dashboard.Mode;
6969

70-
/**
71-
* The path to the dashboard file.
72-
*/
73-
path: string;
74-
7570
/**
7671
* The name of the dashboard.
7772
*/
@@ -237,13 +232,9 @@ export class DashboardModel extends DocumentModel implements IDashboardModel {
237232
// no-op
238233
}
239234

240-
get path(): string {
241-
return this._path;
242-
}
243-
set path(newPath: string) {
244-
this._path = newPath;
245-
}
246-
235+
/**
236+
* The display mode of the dashboard.
237+
*/
247238
get mode(): Dashboard.Mode {
248239
return this._mode;
249240
}
@@ -256,31 +247,56 @@ export class DashboardModel extends DocumentModel implements IDashboardModel {
256247
this.triggerStateChange({ name: 'mode', oldValue, newValue });
257248
}
258249

250+
/**
251+
* The metadata associated with the dashboard;
252+
*/
259253
get metadata(): IObservableJSON {
260254
return this._metadata;
261255
}
262256

257+
/**
258+
* The name of the dashboard.
259+
*
260+
* ### Development notes
261+
* This may be redundant with the filename and could be removed.
262+
*/
263263
get name(): string {
264264
return this.metadata.get('name') as string;
265265
}
266266
set name(newValue: string) {
267267
this._setMetadataProperty('name', newValue);
268268
}
269269

270+
/**
271+
* The width of the dashboard in pixels.
272+
*/
270273
get width(): number {
271274
return +this.metadata.get('dashboardWidth');
272275
}
273276
set width(newValue: number) {
274277
this._setMetadataProperty('dashboardWidth', newValue);
275278
}
276279

280+
/**
281+
* The height of the dashboard in pixels.
282+
*/
277283
get height(): number {
278284
return +this.metadata.get('dashboardHeight');
279285
}
280286
set height(newValue: number) {
281287
this._setMetadataProperty('dashboardHeight', newValue);
282288
}
283289

290+
/**
291+
* Sets a key in the metadata and emits the change as a signal.
292+
*
293+
* @param key - the key to change in the metadata.
294+
*
295+
* @param newValue - the new value to set the key to.
296+
*
297+
* ### Notes
298+
* No signal is emitted if newValue is the same as the old value.
299+
*/
284300
private _setMetadataProperty(key: string, newValue: any): void {
285301
const oldValue = this.metadata.get(key);
286302
if (oldValue === newValue) {
@@ -290,10 +306,16 @@ export class DashboardModel extends DocumentModel implements IDashboardModel {
290306
this.triggerStateChange({ name: key, oldValue, newValue });
291307
}
292308

309+
/**
310+
* A signal emitted when the dashboard is done being deserialized.
311+
*/
293312
get loaded(): Signal<this, void> {
294313
return this._loaded;
295314
}
296315

316+
/**
317+
* The scroll mode of the dashboard.
318+
*/
297319
get scrollMode(): Dashboard.ScrollMode {
298320
return this._scrollMode;
299321
}
@@ -318,7 +340,6 @@ export class DashboardModel extends DocumentModel implements IDashboardModel {
318340

319341
private _metadata: IObservableJSON = new ObservableJSON();
320342
private _loaded = new Signal<this, void>(this);
321-
private _path: string;
322343
private _mode: Dashboard.Mode = 'edit';
323344
private _scrollMode: Dashboard.ScrollMode = 'constrained';
324345
}
@@ -342,36 +363,67 @@ export namespace DashboardModel {
342363
}
343364
}
344365

366+
/**
367+
* A factory class for dashboard models.
368+
*/
345369
export class DashboardModelFactory
346370
implements DocumentRegistry.IModelFactory<IDashboardModel> {
371+
/**
372+
* Construct a new dashboard model factory.
373+
*/
347374
constructor(options: DashboardModelFactory.IOptions) {
348375
this._notebookTracker = options.notebookTracker;
349376
}
350377

378+
/**
379+
* Whether the model factory is disposed.
380+
*/
351381
get isDisposed(): boolean {
352382
return this._disposed;
353383
}
354384

385+
/**
386+
* Dispose of the resources held by the model factory.
387+
*/
355388
dispose(): void {
356389
this._disposed = true;
357390
}
358391

392+
/**
393+
* The format of the file.
394+
*/
359395
get fileFormat(): Contents.FileFormat {
360396
return 'text';
361397
}
362398

399+
/**
400+
* The name of the model.
401+
*/
363402
get name(): string {
364403
return 'dashboard';
365404
}
366405

406+
/**
407+
* The content type of the file.
408+
*/
367409
get contentType(): Contents.ContentType {
368410
return 'file';
369411
}
370412

413+
/**
414+
* Get the preferred kernel langauge given a path (currently a no-op).
415+
*/
371416
preferredLanguage(path: string): string {
372417
return '';
373418
}
374419

420+
/**
421+
* Create a new model for a given path.
422+
*
423+
* @param languagePreference - an optional kernel language preference.
424+
*
425+
* @param modelDB - the model database associated with the model.
426+
*/
375427
createNew(languagePreference?: string, modelDB?: IModelDB): DashboardModel {
376428
const notebookTracker = this._notebookTracker;
377429
const contentsManager = new ContentsManager();
@@ -393,6 +445,9 @@ export class DashboardModelFactory
393445
private _docManager: IDocumentManager;
394446
}
395447

448+
/**
449+
* A namespace for the dashboard model factory.
450+
*/
396451
export namespace DashboardModelFactory {
397452
export interface IOptions {
398453
notebookTracker: INotebookTracker;

0 commit comments

Comments
 (0)