Skip to content

Commit

Permalink
docs(platform-server): inline PlatformOptions and add doc strings (#1…
Browse files Browse the repository at this point in the history
…8264)

Fix documentation for the options passed into renderModule and
renderModuleFactory.

PR Close #18264
  • Loading branch information
vikerman authored and mhevery committed Jul 25, 2017
1 parent ce47546 commit 4cea2bd
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 23 deletions.
36 changes: 15 additions & 21 deletions packages/platform-server/src/utils.ts
Expand Up @@ -18,26 +18,9 @@ import {INITIAL_CONFIG} from './tokens';

const parse5 = require('parse5');

/**
* Options used to configure the server Platform instance that is created in {@link renderModule}
* and {@link renderModuleFactory}.
*
* @experimental
*/
export interface PlatformOptions {
/**
* The full document HTML of the page to render as a string.
*/
interface PlatformOptions {
document?: string;

/**
* The URL for the current render request.
*/
url?: string;

/**
* Platform level providers for the current render request.
*/
extraProviders?: Provider[];
}

Expand Down Expand Up @@ -74,23 +57,34 @@ the server-rendered app can be properly bootstrapped into a client app.`);
/**
* Renders a Module to string.
*
* `document` is the full document HTML of the page to render, as a string.
* `url` is the URL for the current render request.
* `extraProviders` are the platform level providers for the current render request.
*
* Do not use this in a production server environment. Use pre-compiled {@link NgModuleFactory} with
* {link renderModuleFactory} instead.
* {@link renderModuleFactory} instead.
*
* @experimental
*/
export function renderModule<T>(module: Type<T>, options: PlatformOptions): Promise<string> {
export function renderModule<T>(
module: Type<T>,
options: {document?: string, url?: string, extraProviders?: Provider[]}): Promise<string> {
const platform = _getPlatform(platformDynamicServer, options);
return _render(platform, platform.bootstrapModule(module));
}

/**
* Renders a {@link NgModuleFactory} to string.
*
* `document` is the full document HTML of the page to render, as a string.
* `url` is the URL for the current render request.
* `extraProviders` are the platform level providers for the current render request.
*
* @experimental
*/
export function renderModuleFactory<T>(
moduleFactory: NgModuleFactory<T>, options: PlatformOptions): Promise<string> {
moduleFactory: NgModuleFactory<T>,
options: {document?: string, url?: string, extraProviders?: Provider[]}): Promise<string> {
const platform = _getPlatform(platformServer, options);
return _render(platform, platform.bootstrapModuleFactory(moduleFactory));
}
12 changes: 10 additions & 2 deletions tools/public_api_guard/platform-server/platform-server.d.ts
Expand Up @@ -21,10 +21,18 @@ export declare class PlatformState {
}

/** @experimental */
export declare function renderModule<T>(module: Type<T>, options: PlatformOptions): Promise<string>;
export declare function renderModule<T>(module: Type<T>, options: {
document?: string;
url?: string;
extraProviders?: Provider[];
}): Promise<string>;

/** @experimental */
export declare function renderModuleFactory<T>(moduleFactory: NgModuleFactory<T>, options: PlatformOptions): Promise<string>;
export declare function renderModuleFactory<T>(moduleFactory: NgModuleFactory<T>, options: {
document?: string;
url?: string;
extraProviders?: Provider[];
}): Promise<string>;

/** @experimental */
export declare class ServerModule {
Expand Down

0 comments on commit 4cea2bd

Please sign in to comment.