Skip to content

Commit f1ff07e

Browse files
Started adding some typedoc documentation
1 parent 88e64aa commit f1ff07e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+807
-237
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ The transition lifecycle hooks are currently:
2929
When registering a hook, you can provide criteria (a state name, a glob, or a function), and you can modify the transition by returning something from the hook (an abort, a redirect, a promise, or some new resolves to add to the transition).
3030

3131
This enables lots of fun stuff! Here are a couple of possibilities to get your imagination started:
32-
```
32+
```javascript
3333
$transitionsProvider.onBefore({ to: 'my.state', from: '*' }, function(AsyncService) {
3434
return AsyncService.doSomeAsyncThing();
3535
});

src/common/angular1.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/** @module common */ /** for typedoc */
12
/// <reference path='../../typings/angularjs/angular.d.ts' />
23
import {IQService} from "angular";
34

src/common/common.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/** @module common */ /** for typedoc */
12
/// <reference path='../../typings/angularjs/angular.d.ts' />
23
let { isDefined, isFunction, isNumber, isString, isObject, isArray, forEach, extend, copy, noop, toJson, fromJson, equals, identity } = angular;
34
export { isDefined, isFunction, isNumber, isString, isObject, isArray, forEach, extend, copy, noop, toJson, fromJson, equals, identity };

src/common/module.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/** @module common */ /** for typedoc */
12
export * from "./angular1";
23
export * from "./common";
34
export * from "./queue";

src/common/queue.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/** @module common */ /** for typedoc */
12
import {map} from "./common"
23

34
export class Queue<T> {

src/common/trace.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1+
/** @module common */ /** for typedoc */
12
import {isNull, isPromise, isNumber, fnToString, maxLength, padString, isInjectable, is, invoke, not, val, pattern, parse, isDefined, identity} from "../common/common";
23
import {Resolvable} from "../resolve/resolvable";
34
import {Transition} from "../transition/transition";
45
import {TransitionRejection} from "../transition/rejectFactory";
5-
import {IUiViewData} from "../view/interface";
6+
import {UIViewData} from "../view/interface";
67
import {ViewConfig} from "../view/view";
78

89
function promiseToString(p) {
@@ -170,22 +171,22 @@ class Trace {
170171
console.log(`Transition #${tid} Digest #${digest}: <- Success ${transitionStr}, final state: ${state}`);
171172
}
172173

173-
traceUiViewEvent(event: string, viewData: IUiViewData, extra = "") {
174+
traceUiViewEvent(event: string, viewData: UIViewData, extra = "") {
174175
if (!this.enabled(Category.UIVIEW)) return;
175176
console.log(`ui-view: ${padString(30, event)} ${uiViewString(viewData)}${extra}`);
176177
}
177178

178-
traceUiViewConfigUpdated(viewData: IUiViewData, context) {
179+
traceUiViewConfigUpdated(viewData: UIViewData, context) {
179180
if (!this.enabled(Category.UIVIEW)) return;
180181
this.traceUiViewEvent("Updating", viewData, ` with ViewConfig from context='${context}'`);
181182
}
182183

183-
traceUiViewScopeCreated(viewData: IUiViewData, newScope) {
184+
traceUiViewScopeCreated(viewData: UIViewData, newScope) {
184185
if (!this.enabled(Category.UIVIEW)) return;
185186
this.traceUiViewEvent("Created scope for", viewData, `, scope #${newScope.$id}`);
186187
}
187188

188-
traceUiViewFill(viewData: IUiViewData, html) {
189+
traceUiViewFill(viewData: UIViewData, html) {
189190
if (!this.enabled(Category.UIVIEW)) return;
190191
this.traceUiViewEvent("Fill", viewData, ` with: ${maxLength(200, html)}`);
191192
}
@@ -195,7 +196,7 @@ class Trace {
195196
console.log(`$view.ViewConfig: ${event} ${viewConfigString(viewConfig)}`);
196197
}
197198

198-
traceViewServiceUiViewEvent(event: string, viewData: IUiViewData) {
199+
traceViewServiceUiViewEvent(event: string, viewData: UIViewData) {
199200
if (!this.enabled(Category.VIEWCONFIG)) return;
200201
console.log(`$view.ViewConfig: ${event} ${uiViewString(viewData)}`);
201202
}

src/params/interface.ts

Lines changed: 110 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,111 @@
1-
export interface IRawParams {
2-
[key: string]: any
1+
/** @module params */ /** for typedoc */
2+
import {Type} from "./type";
3+
4+
export interface RawParams {
5+
[key: string]: any
36
}
4-
export type IParamsOrArray = (IRawParams|IRawParams[]);
7+
8+
export type ParamsOrArray = (RawParams|RawParams[]);
9+
10+
/**
11+
* Inside the [[StateDeclaration.params]] object of a [[StateDeclaration]]:
12+
* A ParamDeclaration object defines how a single State Parameter should work.
13+
*
14+
* @example ---
15+
*
16+
* ```
17+
* var mystate = {
18+
* template: '<div ui-view/>',
19+
* controller: function() {}
20+
* url: '/mystate/:param1',
21+
* params: {
22+
* param1: "index", // Default value for 'param1'
23+
*
24+
* nonUrlParam: { // ParamDeclaration for 'nonUrlParam' starts
25+
* type: "int", // non
26+
* array: true,
27+
* value: []
28+
* }
29+
* }
30+
* }
31+
* ```
32+
*/
33+
export interface ParamDeclaration {
34+
/**
35+
* Specifies the default value for this parameter. This implicitly sets this parameter as optional.
36+
*
37+
* When UI-Router routes to a state and no value is specified for this parameter in the URL or transition,
38+
* the default value will be used instead. If value is a function, it will be injected and invoked, and the
39+
* return value used.
40+
*
41+
* Note: `value: undefined` is treated as though no default value was specified, while `value: null` is treated
42+
* as "the default value is null".
43+
*
44+
* ```
45+
* // define default values for param1 and param2
46+
* params: {
47+
* param1: {
48+
* value: "defaultValue"
49+
* },
50+
* param2: {
51+
* value: "param2Default;
52+
* }
53+
* }
54+
*```
55+
*
56+
* Shorthand: If you only need to configure the default value of the parameter, you may use a shorthand syntax.
57+
* In the params map, instead mapping the param name to a full parameter configuration object, simply set map it
58+
* to the default parameter value, e.g.:
59+
* ```
60+
* // define a parameter's default value
61+
* params: {
62+
* param1: {
63+
* value: "defaultValue"
64+
* },
65+
* param2: {
66+
* value: "param2Default;
67+
* }
68+
* }
69+
*
70+
* // shorthand default values
71+
* params: {
72+
* param1: "defaultValue",
73+
* param2: "param2Default"
74+
* }
75+
```
76+
*
77+
* This defines a default value for the parameter. If the parameter value is `undefined`, this value will be used instead
78+
*/
79+
value?: any;
80+
81+
/**
82+
* Specifies the parameter type.
83+
*
84+
* Supplying a parameter type
85+
*/
86+
type: (string|Type);
87+
array: boolean;
88+
squash: (boolean|string);
89+
replace: any;
90+
/** @internal */
91+
isOptional: boolean;
92+
dynamic: boolean;
93+
}
94+
95+
/**
96+
* Inside a state definition:
97+
* A nested object named `params` which defines state parameter customizations.
98+
*
99+
* The ParamDeclaration contains configuration for state parameter declarations.
100+
* Keys should be the name of the parameter and values are treated as [[ParamDeclaration]] objects.
101+
*
102+
* #### example:
103+
* ```
104+
* params: {
105+
* folder: {
106+
* value: "index",
107+
* squash: true
108+
* }
109+
* }```
110+
*/
111+
export interface ParamsConfig { [key: string]: ParamDeclaration }

src/params/module.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
/**
2+
* This module contains code for State Parameters.
3+
*
4+
* See [[ParamDeclaration]]
5+
* @module params
6+
* @preferred doc
7+
*/
8+
/**!*/
19
export * from "./param";
210
export * from "./paramTypes";
311
export * from "./type";

src/params/param.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1+
/** @module params */ /** for typedoc */
12
import {isInjectable, extend, isDefined, isString, isArray, filter, map, pick, prop, propEq, curry, applyPairs} from "../common/common";
2-
import {IRawParams} from "../params/interface";
3+
import {RawParams} from "../params/interface";
34
import {runtime} from "../common/angular1";
45
import {matcherConfig} from "../url/urlMatcherConfig";
56
import {paramTypes} from "./paramTypes";
@@ -145,9 +146,9 @@ export class Param {
145146
return new Param(id, type, config, DefType.SEARCH);
146147
}
147148

148-
static values(params: Param[], values): IRawParams {
149+
static values(params: Param[], values): RawParams {
149150
values = values || {};
150-
return <IRawParams> params.map(param => [param.id, param.value(values[param.id])]).reduce(applyPairs, {});
151+
return <RawParams> params.map(param => [param.id, param.value(values[param.id])]).reduce(applyPairs, {});
151152
}
152153

153154
static equals(params: Param[], values1, values2): boolean {

src/params/paramTypes.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/** @module params */ /** for typedoc */
12
import {isDefined, fromJson, toJson, is, identity, equals, inherit, map, extend, val} from "../common/common";
23
import {Type} from "./type";
34
import {runtime} from "../common/angular1";

0 commit comments

Comments
 (0)