From 5576b077ff5a01da88b7e1a2f251fa89e61fd59e Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 1 Aug 2010 00:51:56 +0100 Subject: [PATCH] Added example of base like docs. --- examples/base.js | 73 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 examples/base.js diff --git a/examples/base.js b/examples/base.js new file mode 100644 index 00000000..b7e30e99 --- /dev/null +++ b/examples/base.js @@ -0,0 +1,73 @@ +// Example of how to document code in written in the style of something +// like Dean Edwards' base2.js library + + +var Animal = Class.extend({ + /** + * @constructor Animal + */ + constructor: function(name) { + + /** + * An instance property. + * @property {string} Animal#name + */ + this.name = name; + }, + + /** + * A static property. + * @property {string} Animal.name + */ + name: "", + + /** + * @method Animal#eat + */ + eat: function() { + this.speak("Yum!"); + }, + + /** + * @method Animal#speak + * @param {string} message + */ + speak: function(message) { + alert(this.name + ": " + message); + } +}); + +/** + * @constructor Snake + * @extends Animal + */ +var Snake = Animal.extend({ + + /** + * The sound a snake makes? + * @method Snake#hiss + */ + hiss: function() { + this._super.speak('hissssss'); + } +}); + +/** + * @constructor Cat + * @extends Animal + */ +var Cat = Animal.extend({ + + /** + * @method Cat#meow + */ + meow: function() { + this._super.speak('meow'); + }, + + /** + * Mixin a method from another class. + * @name Cat#hiss => Snake#hiss + */ + hiss: Snake.prototype.hiss +}); \ No newline at end of file