Skip to content

Commit bd626fc

Browse files
docs(*): Update docs fixing broken [[foo]] refs and improving subsystem headings
1 parent 661e833 commit bd626fc

18 files changed

+183
-91
lines changed

src/common/trace.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* UI-Router Transition Tracing
2+
* # Transition tracing (debug)
33
*
44
* Enable transition tracing to print transition information to the console,
55
* in order to help debug your application.

src/globals.ts

+15-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {TransitionService} from "./transition/transitionService";
1111
import {copy} from "./common/common";
1212

1313
/**
14-
* Global mutable state
14+
* Global router state
1515
*
1616
* This is where we hold the global mutable state such as current state, current
1717
* params, current transition, etc.
@@ -43,17 +43,30 @@ export interface UIRouterGlobals {
4343

4444

4545
/**
46-
* Global mutable state
46+
* Global router state
47+
*
48+
* This is where we hold the global mutable state such as current state, current
49+
* params, current transition, etc.
4750
*/
4851
export class Globals implements UIRouterGlobals {
52+
/** @inheritdoc */
4953
params: StateParams = new StateParams();
54+
/** @inheritdoc */
5055
current: StateDeclaration;
56+
/** @inheritdoc */
5157
$current: State;
58+
/** @inheritdoc */
5259
transition: Transition;
60+
61+
/** @internalapi */
5362
transitionHistory = new Queue<Transition>([], 1);
63+
64+
/** @internalapi */
5465
successfulTransitions = new Queue<Transition>([], 1);
5566

67+
/** @hidden */
5668
constructor(transitionService: TransitionService) {
69+
// TODO: This probably belongs in a hooks/globals.ts
5770
const beforeNewTransition = ($transition$: Transition) => {
5871

5972
this.transition = $transition$;

src/interface.ts

+23-14
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Core classes and interfaces
2+
* # Core classes and interfaces
33
*
44
* The classes and interfaces that are core to ui-router and do not belong
55
* to a more specific subsystem (such as resolve).
@@ -16,16 +16,23 @@ import {UIRouter} from "./router";
1616
/**
1717
* An interface for getting values from dependency injection.
1818
*
19-
* This injector primarily returns resolve values (using a [[ResolveContext]]) that match the given token.
19+
* This is primarily used to get resolve values for a given token.
20+
* An instance of the `UIInjector` can be retrieved from the current transition using [[Transition.injector]].
21+
*
22+
* ---
23+
*
2024
* If no resolve is found for a token, then it will delegate to the native injector.
21-
* The native injector may be Angular 1 `$injector`, Angular 2 `Injector`, or a naive polyfill.
25+
* The native injector may be Angular 1 `$injector`, Angular 2 `Injector`, or a simple polyfill.
2226
*
2327
* In Angular 2, the native injector might be the root Injector,
2428
* or it might be a lazy loaded `NgModule` injector scoped to a lazy load state tree.
2529
*/
2630
export interface UIInjector {
2731
/**
28-
* Gets a value from the injector
32+
* Gets a value from the injector.
33+
*
34+
* For a given token, returns the value from the injector that matches the token.
35+
* If the token is for a resolve that has not yet been fetched, this throws an error.
2936
*
3037
* #### Example:
3138
* ```js
@@ -34,7 +41,7 @@ export interface UIInjector {
3441
*
3542
* #### ng1 Example:
3643
* ```js
37-
* // Fetch $state service
44+
* // Fetch StateService
3845
* injector.get('$state').go('home');
3946
* ```
4047
*
@@ -50,26 +57,23 @@ export interface UIInjector {
5057
* var stringArray = injector.get<string[]>('myStringArray');
5158
* ```
5259
*
53-
* ---
54-
*
5560
* ### `NOWAIT` policy
5661
*
5762
* When using [[ResolvePolicy.async]] === `NOWAIT`, the value returned from `get()` is a promise for the result.
63+
* The promise is not automatically unwrapped.
5864
*
59-
* @param token the key for the value to get. May be a string or arbitrary object.
65+
* @param token the key for the value to get. May be a string, a class, or any arbitrary object.
6066
* @return the Dependency Injection value that matches the token
6167
*/
6268
get(token: any): any;
69+
/** Gets a value as type `T` (generics parameter) */
6370
get<T>(token: any): T;
6471

6572
/**
6673
* Asynchronously gets a value from the injector
6774
*
68-
* If the [[ResolveContext]] has a [[Resolvable]] matching the token, it will be
69-
* asynchronously resolved.
70-
*
71-
* Returns a promise for a value from the injector.
72-
* Returns resolve values and/or values from the native injector (ng1/ng2).
75+
* For a given token, returns a promise for the value from the injector that matches the token.
76+
* If the token is for a resolve that has not yet been fetched, this triggers the resolve to load.
7377
*
7478
* #### Example:
7579
* ```js
@@ -82,6 +86,7 @@ export interface UIInjector {
8286
* @return a Promise for the Dependency Injection value that matches the token
8387
*/
8488
getAsync(token: any): Promise<any>;
89+
/** Asynchronously gets a value as type `T` (generics parameter) */
8590
getAsync<T>(token: any): Promise<T>;
8691

8792
/**
@@ -101,15 +106,19 @@ export interface UIInjector {
101106
getNative<T>(token: any): T;
102107
}
103108

109+
/** @internalapi */
104110
export interface UIRouterPlugin extends Disposable {
105111
name: string;
106112
}
107113

108-
export abstract class UIRouterPluginBase implements UIRouterPlugin {
114+
/** @internalapi */
115+
export abstract class UIRouterPluginBase implements UIRouterPlugin, Disposable {
109116
abstract name: string;
110117
dispose(router: UIRouter) { }
111118
}
112119

120+
/** @internalapi */
113121
export interface Disposable {
122+
/** Instructs the Disposable to clean up any resources */
114123
dispose(router?: UIRouter);
115124
}

src/resolve/interface.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* The Resolve subsystem
2+
* # The Resolve subsystem
33
*
44
* This subsystem is an asynchronous, hierarchical Dependency Injection system.
55
*

src/router.ts

+36-9
Original file line numberDiff line numberDiff line change
@@ -21,34 +21,53 @@ let _routerInstance = 0;
2121
/**
2222
* The master class used to instantiate an instance of UI-Router.
2323
*
24-
* UI-Router (for a specific framework) will create an instance of this class during bootstrap.
24+
* UI-Router (for each specific framework) will create an instance of this class during bootstrap.
2525
* This class instantiates and wires the UI-Router services together.
2626
*
2727
* After a new instance of the UIRouter class is created, it should be configured for your app.
28-
* For instance, app states should be registered with the [[stateRegistry]].
28+
* For instance, app states should be registered with the [[UIRouter.stateRegistry]].
2929
*
30-
* Tell UI-Router to monitor the URL by calling `uiRouter.urlRouter.listen()` ([[UrlRouter.listen]])
30+
* ---
31+
*
32+
* Normally the framework code will bootstrap UI-Router.
33+
* If you are bootstrapping UIRouter manually, tell it to monitor the URL by calling
34+
* [[UrlService.listen]] then [[UrlService.sync]].
3135
*/
3236
export class UIRouter {
3337
/** @hidden */
3438
$id: number = _routerInstance++;
3539

40+
/** Provides services related to ui-view synchronization */
3641
viewService = new ViewService();
3742

43+
/** Provides services related to Transitions */
3844
transitionService: TransitionService = new TransitionService(this);
3945

46+
/** Global router state */
4047
globals: UIRouterGlobals = new Globals(this.transitionService);
4148

49+
/**
50+
* Deprecated for public use. Use [[urlService]] instead.
51+
* @deprecated
52+
*/
4253
urlMatcherFactory: UrlMatcherFactory = new UrlMatcherFactory();
4354

55+
/**
56+
* Deprecated for public use. Use [[urlService]] instead.
57+
* @deprecated
58+
*/
4459
urlRouter: UrlRouter = new UrlRouter(this);
4560

61+
/** Provides a registry for states, and related registration services */
4662
stateRegistry: StateRegistry = new StateRegistry(this);
4763

64+
/** Provides services related to states */
4865
stateService = new StateService(this);
4966

67+
/** Provides services related to the URL */
5068
urlService: UrlService = new UrlService(this);
5169

70+
/** @hidden */
5271
private _disposables: Disposable[] = [];
5372

5473
/** Registers an object to be notified when the router is disposed */
@@ -80,6 +99,13 @@ export class UIRouter {
8099
});
81100
}
82101

102+
/**
103+
* Creates a new `UIRouter` object
104+
*
105+
* @param locationService a [[LocationServices]] implementation
106+
* @param locationConfig a [[LocationConfig]] implementation
107+
* @internalapi
108+
*/
83109
constructor(
84110
public locationService: LocationServices = UrlService.locationServiceStub,
85111
public locationConfig: LocationConfig = UrlService.locationConfigStub
@@ -99,6 +125,12 @@ export class UIRouter {
99125
/** @hidden */
100126
private _plugins: { [key: string]: UIRouterPlugin } = {};
101127

128+
/** Add plugin (as ES6 class) */
129+
plugin<T extends UIRouterPlugin>(plugin: { new(router: UIRouter, options?: any): T }, options?: any): T;
130+
/** Add plugin (as javascript constructor function) */
131+
plugin<T extends UIRouterPlugin>(plugin: { (router: UIRouter, options?: any): void }, options?: any): T;
132+
/** Add plugin (as javascript factory function) */
133+
plugin<T extends UIRouterPlugin>(plugin: PluginFactory<T>, options?: any): T;
102134
/**
103135
* Adds a plugin to UI-Router
104136
*
@@ -152,12 +184,6 @@ export class UIRouter {
152184
* @param options options to pass to the plugin class/factory
153185
* @returns the registered plugin instance
154186
*/
155-
plugin<T extends UIRouterPlugin>(plugin: { new(router: UIRouter, options?: any): T }, options?: any): T;
156-
/** Allow javascript constructor function */
157-
plugin<T extends UIRouterPlugin>(plugin: { (router: UIRouter, options?: any): void }, options?: any): T;
158-
/** Allow javascript factory function */
159-
plugin<T extends UIRouterPlugin>(plugin: PluginFactory<T>, options?: any): T;
160-
/** Allow javascript factory function */
161187
plugin<T extends UIRouterPlugin>(plugin: any, options: any = {}): T {
162188
let pluginInstance = new plugin(this, options);
163189
if (!pluginInstance.name) throw new Error("Required property `name` missing on plugin: " + pluginInstance);
@@ -181,4 +207,5 @@ export class UIRouter {
181207
}
182208
}
183209

210+
/** @internalapi */
184211
export type PluginFactory<T> = (router: UIRouter, options?: any) => T;

src/state/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* The state subsystem
2+
* # The state subsystem
33
*
44
* This subsystem implements the ui-router state tree
55
*

src/state/interface.ts

+13-13
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@ export interface TargetStateDef {
2727

2828
export type ResolveTypes = Resolvable | ResolvableLiteral | ProviderLike;
2929
/**
30-
* Base interface for [[Ng1ViewDeclaration]] and [[Ng2ViewDeclaration]]
30+
* Base interface for declaring a view
3131
*
3232
* This interface defines the basic data that a normalized view declaration will have on it.
33-
* Framework-specific implementations may add additional fields (to their interfaces which extend this interface).
33+
* Framework-specific implementations should add additional fields (to their interfaces which extend this interface).
3434
*
3535
* @internalapi
3636
*/
@@ -107,22 +107,21 @@ export type RedirectToResult = string | TargetState | { state?: string, params?:
107107
*/
108108
export interface StateDeclaration {
109109
/**
110-
* The state name
110+
* The state name (required)
111111
*
112112
* A unique state name, e.g. `"home"`, `"about"`, `"contacts"`.
113113
* To create a parent/child state use a dot, e.g. `"about.sales"`, `"home.newest"`.
114114
*
115-
*
116-
* Note: States require unique names. If you omit this property, you must provide
117-
* the state name when you register it with the [[$stateProvider]].
115+
* Note: [State] objects require unique names.
116+
* The name is used like an id.
118117
*/
119118
name?: string;
120119

121120
/**
122-
* abstract state indicator
121+
* Abstract state indicator
123122
*
124-
* An abstract state can never be directly activated. Use an abstract state to provide inherited
125-
* properties (url, resolve, data, etc) to children states.
123+
* An abstract state can never be directly activated.
124+
* Use an abstract state to provide inherited properties (url, resolve, data, etc) to children states.
126125
*/
127126
abstract?: boolean;
128127

@@ -131,8 +130,9 @@ export interface StateDeclaration {
131130
*
132131
* Normally, a state's parent is implied from the state's [[name]], e.g., `"parentstate.childstate"`.
133132
*
134-
* Alternatively, you can explicitly set the parent state using this property. This allows shorter state
135-
* names, e.g., `<a ui-sref="childstate">Child</a>` instead of `<a ui-sref="parentstate.childstate">Child</a>
133+
* Alternatively, you can explicitly set the parent state using this property.
134+
* This allows shorter state names, e.g., `<a ui-sref="childstate">Child</a>`
135+
* instead of `<a ui-sref="parentstate.childstate">Child</a>
136136
*
137137
* When using this property, the state's name should not have any dots in it.
138138
*
@@ -152,7 +152,7 @@ export interface StateDeclaration {
152152
parent?: (string|StateDeclaration);
153153

154154
/**
155-
* Gets the internal API
155+
* Gets the internal State object API
156156
*
157157
* Gets the *internal API* for a registered state.
158158
*
@@ -408,7 +408,7 @@ export interface StateDeclaration {
408408
* - If the property is a function:
409409
* - The function is called with two parameters:
410410
* - The current [[Transition]]
411-
* - An injector which can be used to get dependencies using [[UIRInjector.get]]
411+
* - An [[UIInjector]] which can be used to get dependencies using [[UIInjector.get]] or resolves using [[UIInjector.getAsync]]
412412
* - The return value is processed using the previously mentioned rules.
413413
* - If the return value is a promise, the promise is waited for, then the resolved async value is processed using the same rules.
414414
*

0 commit comments

Comments
 (0)