Created
May 27, 2013 01:30
-
-
Save wrumsby/5654729 to your computer and use it in GitHub Desktop.
Documenting "interfaces" in JavaScript
This file contains hidden or 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
| > npm install -g yuidocjs | |
| > yuidoc -o doc src |
This file contains hidden or 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
| /** | |
| * Foo | |
| * | |
| * @class Foo | |
| * @constructor | |
| */ | |
| function Foo() {} | |
| Foo.prototype = { | |
| /** | |
| * foo | |
| * | |
| * @method foo | |
| * @param {Object} bah | |
| * @param {String} bah.name | |
| * @param {Function} bah.getName | |
| * @return {Boolean} | |
| */ | |
| foo: function(bah) { | |
| return false; | |
| } | |
| }; |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
JavaScript documentation syntaxes like JSDoc and YUIDoc let you specify nested properties, so you could describe the members your object is expected to have. Which is sort of like describing an interface.
This example assumes that
Foo.jsis in the directorysrc.