@@ -51,19 +51,23 @@ import { DocTableCell } from '../nodes/DocTableCell';
5151import { DocNoteBox } from '../nodes/DocNoteBox' ;
5252import { Utilities } from '../utils/Utilities' ;
5353import { CustomMarkdownEmitter } from '../markdown/CustomMarkdownEmitter' ;
54+ import { PluginLoader } from '../plugin/PluginLoader' ;
55+ import { IMarkdownDocumenterFeatureOnBeforeWritePageArgs } from '../plugin/MarkdownDocumenterFeature' ;
5456
5557/**
5658 * Renders API documentation in the Markdown file format.
5759 * For more info: https://en.wikipedia.org/wiki/Markdown
5860 */
5961export class MarkdownDocumenter {
6062 private readonly _apiModel : ApiModel ;
63+ private readonly _pluginLoader : PluginLoader ;
6164 private readonly _tsdocConfiguration : TSDocConfiguration ;
6265 private readonly _markdownEmitter : CustomMarkdownEmitter ;
6366 private _outputFolder : string ;
6467
65- public constructor ( apiModel : ApiModel ) {
68+ public constructor ( apiModel : ApiModel , pluginLoader : PluginLoader ) {
6669 this . _apiModel = apiModel ;
70+ this . _pluginLoader = pluginLoader ;
6771 this . _tsdocConfiguration = CustomDocNodes . configuration ;
6872 this . _markdownEmitter = new CustomMarkdownEmitter ( this . _apiModel ) ;
6973 }
@@ -249,7 +253,20 @@ export class MarkdownDocumenter {
249253 }
250254 } ) ;
251255
252- FileSystem . writeFile ( filename , stringBuilder . toString ( ) , {
256+ let pageContent : string = stringBuilder . toString ( ) ;
257+
258+ if ( this . _pluginLoader . markdownDocumenterFeature ) {
259+ // Allow the plugin to customize the pageContent
260+ const eventArgs : IMarkdownDocumenterFeatureOnBeforeWritePageArgs = {
261+ apiItem : apiItem ,
262+ outputFilename : filename ,
263+ pageContent : pageContent
264+ } ;
265+ this . _pluginLoader . markdownDocumenterFeature . onBeforeWritePage ( eventArgs ) ;
266+ pageContent = eventArgs . pageContent ;
267+ }
268+
269+ FileSystem . writeFile ( filename , pageContent , {
253270 convertLineEndings : NewlineKind . CrLf
254271 } ) ;
255272 }
0 commit comments