Here property"out"means that we want to create documentation folder with namedocs.
Next is to add this lines into project'spackage.jsonscriptssection:
Here:
"docs"
it is name of command to build documents
our TypeDoc options are in
typedoc.json
file
we are excluding testing
**/*.spec.ts
files
source files form which documentation must be generated are in project's folder
/src/app/
The command to build documentation is:
After successful command execution there will be message in console:
where...is absolute path to documents folder and folder structure is:
Now you can open documents index.html file in browser.
Describing Models/Components/Services
Example of Model description:
Example of Component description:
Example of Service description:
Code comments
The documentation generator currently understands these javadoc tags:
All other tags will be rendered as definition lists, so they are not lost.
Comment to some variable:
Function comments:
Modules comments
Modules can be commented like any other elements in TypeScript. As modules can be defined in multiple files, TypeDoc selects the longest comment by default. One may override this behaviour with the special@preferredcomment tag.
HTML tags in comments
It is possible to use HTML tags in comments. For example:
import { Injectable } from '@angular/core';
import { Headers, Http } from '@angular/http';
import 'rxjs/add/operator/toPromise';
import { Contact } from '../classes/contact';
/**
* Description for service 'ContactService'.
*/
@Injectable()
export class ContactService {
constructor(private http: Http) { }
}
@param <param name>
@return(s)
/**
* This is a doc comment for "someVar".
*/
var someVar:string = "value";
/**
* Comment for method ´doSomething´.
* @param target Comment for parameter ´target´.
* @param arg Comment for parameter ´arg´.
* @returns Comment for return value.
*/
function doSomething(target:any, arg:number):number {
return 0;
}
/**
* Actual module comment.
* @preferred
*/
module MyModule { }
/**
* Dismissed module comment.
* This is the longer comment but will be dismissed in favor of the preferred comment.
*/
module MyModule { }
/**
* Description with HTML tags.
*
* <pre>{
* 'firstName': 'John',
* 'lastName': 'Doe'
* }</pre>
*
* Link to: <a target="_blank" href="https://www.google.com/">Google</a>
*/