forked from jsdoc/jsdoc
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
106 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
/** | ||
* @classdesc Toaster singleton. | ||
* @class | ||
* @hideconstructor | ||
*/ | ||
var Toaster = (function() { | ||
var instance = null; | ||
|
||
function Toaster() {} | ||
|
||
/** | ||
* Toast an item. | ||
* | ||
* @alias toast | ||
* @memberof Toaster | ||
* @instance | ||
* @param {BreadyThing} item - The item to toast. | ||
* @return {Toast} A toasted bready thing. | ||
*/ | ||
Toaster.prototype.toast = function(item) {}; | ||
|
||
return { | ||
/** | ||
* Get the Toaster instance. | ||
* | ||
* @alias Toaster.getInstance | ||
* @returns {Toaster} The Toaster instance. | ||
*/ | ||
getInstance: function() { | ||
if (instance === null) { | ||
instance = new Toaster(); | ||
delete instance.constructor; | ||
} | ||
|
||
return instance; | ||
} | ||
}; | ||
})(); | ||
|
||
/** | ||
* Waffle iron singleton. | ||
*/ | ||
class WaffleIron { | ||
#instance = null; | ||
|
||
/** | ||
* Create the waffle iron. | ||
* | ||
* @hideconstructor | ||
*/ | ||
constructor() { | ||
if (#instance) { | ||
return #instance; | ||
} | ||
|
||
/** | ||
* Cook a waffle. | ||
* | ||
* @param {Batter} batter - The waffle batter. | ||
* @return {Waffle} The cooked waffle. | ||
*/ | ||
this.cook = function(batter) {}; | ||
|
||
this.#instance = this; | ||
} | ||
|
||
/** | ||
* Get the WaffleIron instance. | ||
* | ||
* @return {WaffleIron} The WaffleIron instance. | ||
*/ | ||
getInstance() { | ||
return new WaffleIron(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
'use strict'; | ||
|
||
describe('@hideconstructor tag', function() { | ||
var docSet = jasmine.getDocSetFromFile('test/fixtures/hideconstructortag.js'); | ||
var toaster = docSet.getByLongname('Toaster')[0]; | ||
var waffleIron = docSet.getByLongname('WaffleIron')[0]; | ||
|
||
it('should add a `hideconstructor` attribute to pre-ES2015 classes', function() { | ||
expect(toaster.hideconstructor).toBe(true); | ||
}); | ||
|
||
it('should add a `hideconstructor` attribute to ES2015 classes when the constructor is tagged', | ||
function() { | ||
expect(waffleIron.hideconstructor).toBe(true); | ||
}); | ||
}); |