From bcf6b90c951997693be67166e9f4f3f0472384f4 Mon Sep 17 00:00:00 2001 From: Vikram Subramanian Date: Thu, 20 Jul 2017 14:30:35 -0700 Subject: [PATCH] docs(platform-server): inline PlatformOptions and add doc strings (#18264) Fix documentation for the options passed into renderModule and renderModuleFactory. PR Close #18264 --- packages/platform-server/src/utils.ts | 36 ++++++++----------- .../platform-server/platform-server.d.ts | 12 +++++-- 2 files changed, 25 insertions(+), 23 deletions(-) diff --git a/packages/platform-server/src/utils.ts b/packages/platform-server/src/utils.ts index 01add9360c..f768a24709 100644 --- a/packages/platform-server/src/utils.ts +++ b/packages/platform-server/src/utils.ts @@ -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[]; } @@ -74,12 +57,18 @@ 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(module: Type, options: PlatformOptions): Promise { +export function renderModule( + module: Type, + options: {document?: string, url?: string, extraProviders?: Provider[]}): Promise { const platform = _getPlatform(platformDynamicServer, options); return _render(platform, platform.bootstrapModule(module)); } @@ -87,10 +76,15 @@ export function renderModule(module: Type, options: PlatformOptions): Prom /** * 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( - moduleFactory: NgModuleFactory, options: PlatformOptions): Promise { + moduleFactory: NgModuleFactory, + options: {document?: string, url?: string, extraProviders?: Provider[]}): Promise { const platform = _getPlatform(platformServer, options); return _render(platform, platform.bootstrapModuleFactory(moduleFactory)); } diff --git a/tools/public_api_guard/platform-server/platform-server.d.ts b/tools/public_api_guard/platform-server/platform-server.d.ts index 38063a7647..5a7c35f860 100644 --- a/tools/public_api_guard/platform-server/platform-server.d.ts +++ b/tools/public_api_guard/platform-server/platform-server.d.ts @@ -21,10 +21,18 @@ export declare class PlatformState { } /** @experimental */ -export declare function renderModule(module: Type, options: PlatformOptions): Promise; +export declare function renderModule(module: Type, options: { + document?: string; + url?: string; + extraProviders?: Provider[]; +}): Promise; /** @experimental */ -export declare function renderModuleFactory(moduleFactory: NgModuleFactory, options: PlatformOptions): Promise; +export declare function renderModuleFactory(moduleFactory: NgModuleFactory, options: { + document?: string; + url?: string; + extraProviders?: Provider[]; +}): Promise; /** @experimental */ export declare class ServerModule {