File tree Expand file tree Collapse file tree 6 files changed +98
-4
lines changed
Expand file tree Collapse file tree 6 files changed +98
-4
lines changed Original file line number Diff line number Diff line change 11// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
22// See LICENSE in the project root for license information.
33
4- export { MarkdownDocumenterFeature } from './plugin/MarkdownDocumenterFeature' ;
5- export { PluginFeature , PluginFeatureInitialization } from './plugin/PluginFeature' ;
64export {
75 IFeatureDefinition ,
86 IApiDocumenterPluginManifest
97} from './plugin/IApiDocumenterPluginManifest' ;
8+ export {
9+ MarkdownDocumenterFeatureContext ,
10+ IMarkdownDocumenterFeatureOnBeforeWritePage ,
11+ MarkdownDocumenterFeature
12+ } from './plugin/MarkdownDocumenterFeature' ;
13+ export {
14+ PluginFeature ,
15+ PluginFeatureContext ,
16+ PluginFeatureInitialization
17+ } from './plugin/PluginFeature' ;
Original file line number Diff line number Diff line change 22// See LICENSE in the project root for license information.
33
44import { PluginFeature } from './PluginFeature' ;
5+ import { ApiItem } from '@microsoft/api-extractor-model' ;
6+
7+ /**
8+ * Context object for {@link MarkdownDocumenterFeature}.
9+ *
10+ * @public
11+ */
12+ export class MarkdownDocumenterFeatureContext {
13+
14+ }
15+
16+ /**
17+ * Event arguments for MarkdownDocumenterFeature.onBeforeWritePage()
18+ * @public
19+ */
20+ export interface IMarkdownDocumenterFeatureOnBeforeWritePage {
21+ /**
22+ * The API item corresponding to this page.
23+ */
24+ apiItem : ApiItem ;
25+
26+ /**
27+ * The page content. The onBeforeWritePage() handler can reassign this string to customize the page appearance.
28+ */
29+ pageContent : string ;
30+
31+ /**
32+ * The filename where the output will be written.
33+ */
34+ outputFilename : string ;
35+ }
536
637/**
738 * Inherit from this base class to implement an API Documenter plugin feature that customizes
@@ -10,4 +41,13 @@ import { PluginFeature } from './PluginFeature';
1041 * @public
1142 */
1243export class MarkdownDocumenterFeature extends PluginFeature {
44+ public context : MarkdownDocumenterFeatureContext ;
45+
46+ /**
47+ * This event function is called before writing a page.
48+ * @virtual
49+ */
50+ public onBeforeWritePage ( eventArgs : IMarkdownDocumenterFeatureOnBeforeWritePage ) : void {
51+ // (implemented by child class)
52+ }
1353}
Original file line number Diff line number Diff line change @@ -14,13 +14,26 @@ export class PluginFeatureInitialization {
1414 public constructor ( ) {
1515 // reserved for future use
1616 }
17+
18+ /** @internal */
19+ public _context : PluginFeatureContext ;
20+ }
21+
22+ /**
23+ * Context object for {@link PluginFeature}.
24+ *
25+ * @public
26+ */
27+ export class PluginFeatureContext {
1728}
1829
1930/**
2031 * The abstract base class for all API Documenter plugin features.
2132 * @public
2233 */
2334export abstract class PluginFeature {
35+ public context : PluginFeatureContext ;
36+
2437 /**
2538 * The subclass should pass the `initialization` through to the base class.
2639 * Do not put custom initialization code in the constructor. Insteadm perform your initialization in the
@@ -29,6 +42,7 @@ export abstract class PluginFeature {
2942 */
3043 public constructor ( initialization : PluginFeatureInitialization ) {
3144 // reserved for future expansion
45+ this . context = initialization . _context ;
3246 }
3347
3448 /**
Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ import * as resolve from 'resolve';
66
77import { IConfigPlugin } from '../documenters/IConfigFile' ;
88import { IApiDocumenterPluginManifest , IFeatureDefinition } from './IApiDocumenterPluginManifest' ;
9- import { MarkdownDocumenterFeature } from './MarkdownDocumenterFeature' ;
9+ import { MarkdownDocumenterFeature , MarkdownDocumenterFeatureContext } from './MarkdownDocumenterFeature' ;
1010import { PluginFeatureInitialization } from './PluginFeature' ;
1111
1212interface ILoadedPlugin {
@@ -69,7 +69,11 @@ export class PluginLoader {
6969 throw new Error ( 'A MarkdownDocumenterFeature is already loaded' ) ;
7070 }
7171
72+ const context : MarkdownDocumenterFeatureContext = new MarkdownDocumenterFeatureContext ( ) ;
73+
7274 const initialization : PluginFeatureInitialization = new PluginFeatureInitialization ( ) ;
75+ initialization . _context = context ;
76+
7377 let markdownDocumenterFeature : MarkdownDocumenterFeature | undefined = undefined ;
7478 try {
7579 markdownDocumenterFeature = new featureDefinition . subclass ( initialization ) ;
Original file line number Diff line number Diff line change 11{
2- "extends" : " @microsoft/rush-stack-compiler-3.4/includes/tslint.json"
2+ "extends" : " @microsoft/rush-stack-compiler-3.4/includes/tslint.json" ,
3+ "rules" : {
4+ "member-ordering" : false
5+ }
36}
Original file line number Diff line number Diff line change 44
55``` ts
66
7+ import { ApiItem } from ' @microsoft/api-extractor-model' ;
8+
79// @public
810export interface IApiDocumenterPluginManifest {
911 features: IFeatureDefinition [];
@@ -19,22 +21,45 @@ export interface IFeatureDefinition {
1921 };
2022}
2123
24+ // @public
25+ export interface IMarkdownDocumenterFeatureOnBeforeWritePage {
26+ apiItem: ApiItem ;
27+ outputFilename: string ;
28+ pageContent: string ;
29+ }
30+
2231// @public
2332export class MarkdownDocumenterFeature extends PluginFeature {
33+ // (undocumented)
34+ context: MarkdownDocumenterFeatureContext ;
35+ // @virtual
36+ onBeforeWritePage(eventArgs : IMarkdownDocumenterFeatureOnBeforeWritePage ): void ;
37+ }
38+
39+ // @public
40+ export class MarkdownDocumenterFeatureContext {
2441}
2542
2643// @public
2744export abstract class PluginFeature {
2845 // @internal
2946 constructor (initialization : PluginFeatureInitialization );
47+ // (undocumented)
48+ context: PluginFeatureContext ;
3049 // @virtual
3150 onInitialized(): void ;
3251}
3352
53+ // @public
54+ export class PluginFeatureContext {
55+ }
56+
3457// @public
3558export class PluginFeatureInitialization {
3659 // @internal
3760 constructor ();
61+ // @internal (undocumented)
62+ _context: PluginFeatureContext ;
3863}
3964
4065
You can’t perform that action at this time.
0 commit comments