dherman
dherman

Reputation: 2892

Document a constant using ngDoc

How would one go about documenting a constant using ngDoc? I don't see any angular specific documentation for documenting values registered with .constant, and the jsDoc syntax for constants doesn't seem to generate any actual docs when it's run through ngDoc.

Ex:

/** * @constant * @name WHITE * * @description * The color white! **/ module.constant( 'WHITE', '#fff' );

Upvotes: 8

Views: 2674

Answers (2)

zbycz
zbycz

Reputation: 654

ngDocs currently doesn't provide a way to document constants. As you can see in its templating source code. There isnt relevant html_usage_* method.

I document constants like this, it shows a APP_CONFIG as a module then.

/**
 * @ngdoc object
 * @name APP_CONFIG
 * @description
 *   constant...
 * @example
 * APP_CONFIG is injectable as constant (as a service even to .config())
 * <pre>
 * (...)    .config(function ($APP_CONFIG) {
 * </pre>
 */

Upvotes: 3

Kourkis
Kourkis

Reputation: 57

It should be @const

/** @const */ var MY_BEER = 'stout';

/**
 * My namespace's favorite kind of beer.
 * @const {string}
 */
mynamespace.MY_BEER = 'stout';

/** @const */ MyClass.MY_BEER = 'stout';

/**
 * Initializes the request.
 * @const
 */
mynamespace.Request.prototype.initialize = function() {
  // This method cannot be overridden in a subclass.
};

See the constant part http://google-styleguide.googlecode.com/svn/trunk/javascriptguide.xml#Constants and the comments part http://google-styleguide.googlecode.com/svn/trunk/javascriptguide.xml?showone=Comments#Comments for more informations

Upvotes: -2

Related Questions