Skip to content

Commit 095f531

Browse files
docs(url): Move docs from interface level to UrlService/UrlConfig/UrlRules classes
docs(*): Improve docs - Migrate to @publicapi from @coreapi - Improve file header comment consistency, i.e., @coreapi @module foo
1 parent 5cb9a64 commit 095f531

Some content is hidden

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

79 files changed

+795
-951
lines changed

src/common/common.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,8 @@
33
*
44
* These functions are exported, but are subject to change without notice.
55
*
6-
* @preferred
7-
* @module common
8-
*/
9-
/** for typedoc */
6+
* @preferred @publicapi @module common
7+
*/ /** */
108
import { isFunction, isString, isArray, isRegExp, isDate } from './predicates';
119
import { all, any, prop, curry, not } from './hof';
1210
import { services } from './coreservices';

src/common/coreservices.ts

Lines changed: 36 additions & 142 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
* This module is a stub for core services such as Dependency Injection or Browser Location.
33
* Core services may be implemented by a specific framework, such as ng1 or ng2, or be pure javascript.
44
*
5-
* @module common
6-
*/
7-
/** for typedoc */
5+
* @publicapi @module common
6+
*/ /** */
87
import { IInjectable, Obj } from './common';
98
import { Disposable } from '../interface';
9+
import { UrlConfig, UrlService } from '../url';
1010

1111
const noImpl = (fnname: string) => () => {
1212
throw new Error(`No implementation for ${fnname}. The framework specific code did not implement this method.`);
@@ -48,154 +48,48 @@ export interface CoreServices {
4848
$injector: $InjectorLike;
4949
}
5050

51+
/**
52+
* Handles low level URL read/write
53+
*
54+
* This service handles low level reads and updates of the URL and listens for url changes.
55+
* Implementors should pass these through to the underlying URL mechanism.
56+
* The underlying URL mechanism might be browser APIs, framework APIs, or some 3rd party URL management library.
57+
*
58+
* UI-Router Core includes three basic implementations:
59+
*
60+
* - [[PushStateLocationService]]
61+
* - [[HashLocationService]]
62+
* - [[MemoryLocationService]]
63+
*/
5164
export interface LocationServices extends Disposable {
52-
/**
53-
* Gets the current url string
54-
*
55-
* The URL is normalized using the internal [[path]]/[[search]]/[[hash]] values.
56-
*
57-
* For example, the URL may be stored in the hash ([[HashLocationServices]]) or
58-
* have a base HREF prepended ([[PushStateLocationServices]]).
59-
*
60-
* The raw URL in the browser might be:
61-
*
62-
* ```
63-
* http://mysite.com/somepath/index.html#/internal/path/123?param1=foo#anchor
64-
* ```
65-
*
66-
* or
67-
*
68-
* ```
69-
* http://mysite.com/basepath/internal/path/123?param1=foo#anchor
70-
* ```
71-
*
72-
* then this method returns:
73-
*
74-
* ```
75-
* /internal/path/123?param1=foo#anchor
76-
* ```
77-
*
78-
*
79-
* #### Example:
80-
* ```js
81-
* locationServices.url(); // "/some/path?query=value#anchor"
82-
* ```
83-
*
84-
* @returns the current value of the url, as a string.
85-
*/
86-
url(): string;
87-
88-
/**
89-
* Updates the url, or gets the current url
90-
*
91-
* Updates the url, changing it to the value in `newurl`
92-
*
93-
* #### Example:
94-
* ```js
95-
* locationServices.url("/some/path?query=value#anchor", true);
96-
* ```
97-
*
98-
* @param newurl The new value for the URL.
99-
* This url should reflect only the new internal [[path]], [[search]], and [[hash]] values.
100-
* It should not include the protocol, site, port, or base path of an absolute HREF.
101-
* @param replace When true, replaces the current history entry (instead of appending it) with this new url
102-
* @param state The history's state object, i.e., pushState (if the LocationServices implementation supports it)
103-
* @return the url (after potentially being processed)
104-
*/
105-
url(newurl: string, replace?: boolean, state?: any): string;
106-
107-
/**
108-
* Gets the path part of the current url
109-
*
110-
* If the current URL is `/some/path?query=value#anchor`, this returns `/some/path`
111-
*
112-
* @return the path portion of the url
113-
*/
114-
path(): string;
115-
116-
/**
117-
* Gets the search part of the current url as an object
118-
*
119-
* If the current URL is `/some/path?query=value#anchor`, this returns `{ query: 'value' }`
120-
*
121-
* @return the search (querystring) portion of the url, as an object
122-
*/
123-
search(): { [key: string]: any };
124-
125-
/**
126-
* Gets the hash part of the current url
127-
*
128-
* If the current URL is `/some/path?query=value#anchor`, this returns `anchor`
129-
*
130-
* @return the hash (anchor) portion of the url
131-
*/
132-
hash(): string;
133-
134-
/**
135-
* Registers a url change handler
136-
*
137-
* #### Example:
138-
* ```js
139-
* let deregisterFn = locationServices.onChange((evt) => console.log("url change", evt));
140-
* ```
141-
*
142-
* @param callback a function that will be called when the url is changing
143-
* @return a function that de-registers the callback
144-
*/
145-
onChange(callback: Function): Function;
65+
/** See: [[UrlService.url]] */ url: UrlService['url'];
66+
/** See: [[UrlService.path]] */ path: UrlService['path'];
67+
/** See: [[UrlService.search]] */ search: UrlService['search'];
68+
/** See: [[UrlService.hash]] */ hash: UrlService['hash'];
69+
/** See: [[UrlService.onChange]] */ onChange: UrlService['onChange'];
14670
}
14771

14872
/**
149-
* This service returns the location configuration
73+
* Returns low level URL configuration and metadata
15074
*
15175
* This service returns information about the location configuration.
15276
* This service is primarily used when building URLs (e.g., for `hrefs`)
77+
*
78+
* Implementors should pass these through to the underlying URL APIs.
79+
* The underlying URL mechanism might be browser APIs, framework APIs, or some 3rd party URL management library.
80+
*
81+
* UI-Router Core includes two basic implementations:
82+
*
83+
* - [[BrowserLocationConfig]]
84+
* - [[MemoryLocationConfig]]
15385
*/
15486
export interface LocationConfig extends Disposable {
155-
/**
156-
* Gets the port, e.g., `80`
157-
*
158-
* @return the port number
159-
*/
160-
port(): number;
161-
/**
162-
* Gets the protocol, e.g., `http`
163-
*
164-
* @return the protocol
165-
*/
166-
protocol(): string;
167-
/**
168-
* Gets the host, e.g., `localhost`
169-
*
170-
* @return the protocol
171-
*/
172-
host(): string;
173-
/**
174-
* Gets the base Href, e.g., `http://localhost/approot/`
175-
*
176-
* @return the application's base href
177-
*/
178-
baseHref(): string;
179-
/**
180-
* Returns true when running in pushstate mode
181-
*
182-
* @return true when running in pushstate mode
183-
*/
184-
html5Mode(): boolean;
185-
/**
186-
* Gets the hashPrefix (when not running in pushstate mode)
187-
*
188-
* If the current url is `http://localhost/app#!/uirouter/path/#anchor`, it returns `!` which is the prefix for the "hashbang" portion.
189-
*
190-
* @return the hash prefix
191-
*/
192-
hashPrefix(): string;
193-
/**
194-
* Sets the hashPrefix (when not running in pushstate mode)
195-
*
196-
* @return the new hash prefix
197-
*/
198-
hashPrefix(newprefix: string): string;
87+
/** See: [[UrlConfig.port]] */ port: UrlConfig['port'];
88+
/** See: [[UrlConfig.protocol]] */ protocol: UrlConfig['protocol'];
89+
/** See: [[UrlConfig.host]] */ host: UrlConfig['host'];
90+
/** See: [[UrlConfig.baseHref]] */ baseHref: UrlConfig['baseHref'];
91+
/** See: [[UrlConfig.html5Mode]] */ html5Mode: UrlConfig['html5Mode'];
92+
/** See: [[UrlConfig.hashPrefix]] */ hashPrefix: UrlConfig['hashPrefix'];
19993
}
20094

20195
export { services };

src/common/glob.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
/**
2-
* @coreapi
3-
* @module core
4-
*/
1+
/** @publicapi @module core */
52
/**
63
* Matches state names using glob-like pattern strings.
74
*

src/common/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/** @module common */ /** for typedoc */
1+
/** @publicapi @module common */ /** */
22
export * from './common';
33
export * from './coreservices';
44
export * from './glob';

src/common/predicates.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44
* Although these functions are exported, they are subject to change without notice.
55
*
66
* @module common_predicates
7-
*/
8-
/** */
7+
*/ /** */
98
import { and, not, pipe, prop, or } from './hof';
109
import { Predicate } from './common'; // has or is using
1110
import { StateObject } from '../state/stateObject';

src/common/queue.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/** @module common */
1+
/** @publicapi @module common */ /** */
22
import { pushTo } from './common';
33

44
export class Queue<T> {

src/common/trace.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,7 @@
3030
* app.run($trace => $trace.enable());
3131
* ```
3232
*
33-
* @coreapi
34-
* @module trace
33+
* @publicapi @module trace
3534
*/
3635
/* tslint:disable:no-console */
3736
import { parse } from '../common/hof';

src/globals.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
/**
2-
* @coreapi
3-
* @module core
4-
*/ /** */
1+
/** @publicapi @module core */ /** */
52
import { StateParams } from './params/stateParams';
63
import { StateDeclaration } from './state/interface';
74
import { StateObject } from './state/stateObject';

src/hooks/coreResolvables.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/** @module hooks */ /** */
1+
/** @internalapi @module hooks */ /** */
22
import { Transition } from '../transition/transition';
33
import { UIRouter } from '../router';
44
import { TransitionService } from '../transition/transitionService';

src/hooks/ignoredTransition.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/** @module hooks */ /** */
1+
/** @internalapi @module hooks */ /** */
22

33
import { trace } from '../common/trace';
44
import { Rejection } from '../transition/rejectFactory';

0 commit comments

Comments
 (0)