forked from microsoft/rushstack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMarkdownDocumenterFeature.ts
More file actions
93 lines (81 loc) · 2.53 KB
/
MarkdownDocumenterFeature.ts
File metadata and controls
93 lines (81 loc) · 2.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
// See LICENSE in the project root for license information.
import { PluginFeature } from './PluginFeature';
import { ApiItem, ApiModel } from '@microsoft/api-extractor-model';
import { MarkdownDocumenterAccessor } from './MarkdownDocumenterAccessor';
/**
* Context object for {@link MarkdownDocumenterFeature}.
* Exposes various services that can be used by a plugin.
*
* @public
*/
export class MarkdownDocumenterFeatureContext {
/** @internal */
public constructor(options: MarkdownDocumenterFeatureContext) {
this.apiModel = options.apiModel;
this.outputFolder = options.outputFolder;
this.documenter = options.documenter;
}
/**
* Provides access to the `ApiModel` for the documentation being generated.
*/
public readonly apiModel: ApiModel;
/**
* The full path to the output folder.
*/
public readonly outputFolder: string;
/**
* Exposes functionality of the documenter.
*/
public readonly documenter: MarkdownDocumenterAccessor;
}
/**
* Event arguments for MarkdownDocumenterFeature.onBeforeWritePage()
* @public
*/
export interface IMarkdownDocumenterFeatureOnBeforeWritePageArgs {
/**
* The API item corresponding to this page.
*/
readonly apiItem: ApiItem;
/**
* The page content. The {@link MarkdownDocumenterFeature.onBeforeWritePage} handler can reassign this
* string to customize the page appearance.
*/
pageContent: string;
/**
* The filename where the output will be written.
*/
readonly outputFilename: string;
}
/**
* Event arguments for MarkdownDocumenterFeature.onFinished()
* @public
*/
export interface IMarkdownDocumenterFeatureOnFinishedArgs {
}
/**
* Inherit from this base class to implement an API Documenter plugin feature that customizes
* the generation of markdown output.
*
* @public
*/
export class MarkdownDocumenterFeature extends PluginFeature {
/** {@inheritdoc PluginFeature.context} */
public context: MarkdownDocumenterFeatureContext;
/**
* This event occurs before each markdown file is written. It provides an opportunity to customize the
* content of the file.
* @virtual
*/
public onBeforeWritePage(eventArgs: IMarkdownDocumenterFeatureOnBeforeWritePageArgs): void {
// (implemented by child class)
}
/**
* This event occurs after all output files have been written.
* @virtual
*/
public onFinished(eventArgs: IMarkdownDocumenterFeatureOnFinishedArgs): void {
// (implemented by child class)
}
}