I would like to add ngdoc documentation to a function declaration within an angular service. How can I do this for myFunction in the example below?
I reckon I need something like @closure, @functionOf or @functionIn.
Please note that (in contrast to myMethod) myFunction is not a method.
/**
* @ngdoc service
* @name myApp.service:myService
* @description
* My application.
*/
angular
.module('myApp')
.factory('myService', function() {
'use strict';
var x = 0;
/**
* @ngdoc function
* @name ?
* @description
* How can this be identified as being within the closure of
* myService, and not be described as a constructor?
*/
function myFunction (z) {
x++;
x += z;
}
return {
/**
* @ngdoc method
* @name myMethod
* @methodOf myApp.service:myService
* @description
* A method of myService.
*/
myMethod : function (x) {
myFunction(x);
}
};
})
TypeDoc contains two themes out of the box. The default one and 'minimal'. To specify a theme use* --theme* option followed by the name of the predefined theme or a path to a custom one. While you can use TypeDoc to document Angular apps, it will treat your code as any other plain TypeScript app. That means no Angular specific documentation.
That means no Angular specific documentation. But there is a whole lot to be documented. Compodoc solves this, it is focused on Angular apps specifically giving you a much more tailored solution. Once you run the compodoc command it will automatically generate your documentation from your project in form of HTML.
To create a service in Angular, you need to run the generate service command: Two new files will be created. Navigate to the data service.ts file, and make sure the content is the same as this: This data service has now been created and hard-coded data stored in the getList function.
One of the common ones is, for example, JSDoc. It is similar to JavaDoc tool used with Java, which can generate automatically documentation based on special comments, which are present directly in the code. However, when working with a framework such as AngularJS (that is -- Angular 1.x), it is handy to have something more powerful.
The keyname you are looking for is the @methodOf
annotation.
When i'm writing documentation using grunt-ngdocs for a service it ends up looking like the following:
/**
* @ngdoc overview
* @name module
* @description A small module containing stuff
*/
angular
.module(module, [])
.factory('name', factory);
/**
* @ngdoc object
* @name module.name
* @description Its a pretty bad factory
*/
function factory() {
return {
doSomething: doSomething
};
/**
* @ngdoc function
* @name module.name#doSomething
* @methodOf module.name
* @description Does the thing
* @param {string=} [foo='bar'] This is a parameter that does nothing, it is
optional and defaults to 'bar'
* @returns {undefined} It doesn't return
*/
function doSomething(foo){...}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With