Skip to content

Instantly share code, notes, and snippets.

@wrumsby
Created May 27, 2013 01:30
Show Gist options
  • Select an option

  • Save wrumsby/5654729 to your computer and use it in GitHub Desktop.

Select an option

Save wrumsby/5654729 to your computer and use it in GitHub Desktop.
Documenting "interfaces" in JavaScript
> npm install -g yuidocjs
> yuidoc -o doc src
/**
* 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;
}
};
@wrumsby
Copy link
Author

wrumsby commented May 27, 2013

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.js is in the directory src.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment