@@ -52,36 +52,62 @@ import { DocNoteBox } from '../nodes/DocNoteBox';
5252import { Utilities } from '../utils/Utilities' ;
5353import { CustomMarkdownEmitter } from '../markdown/CustomMarkdownEmitter' ;
5454import { PluginLoader } from '../plugin/PluginLoader' ;
55- import { IMarkdownDocumenterFeatureOnBeforeWritePageArgs } from '../plugin/MarkdownDocumenterFeature' ;
55+ import {
56+ IMarkdownDocumenterFeatureOnBeforeWritePageArgs ,
57+ MarkdownDocumenterFeatureContext
58+ } from '../plugin/MarkdownDocumenterFeature' ;
59+ import { DocumenterConfig } from './DocumenterConfig' ;
60+ import { MarkdownDocumenterAccessor } from '../plugin/MarkdownDocumenterAccessor' ;
5661
5762/**
5863 * Renders API documentation in the Markdown file format.
5964 * For more info: https://en.wikipedia.org/wiki/Markdown
6065 */
6166export class MarkdownDocumenter {
6267 private readonly _apiModel : ApiModel ;
63- private readonly _pluginLoader : PluginLoader ;
68+ private readonly _documenterConfig : DocumenterConfig | undefined ;
6469 private readonly _tsdocConfiguration : TSDocConfiguration ;
6570 private readonly _markdownEmitter : CustomMarkdownEmitter ;
6671 private _outputFolder : string ;
72+ private readonly _pluginLoader : PluginLoader ;
6773
68- public constructor ( apiModel : ApiModel , pluginLoader : PluginLoader ) {
74+ public constructor ( apiModel : ApiModel , documenterConfig : DocumenterConfig | undefined ) {
6975 this . _apiModel = apiModel ;
70- this . _pluginLoader = pluginLoader ;
76+ this . _documenterConfig = documenterConfig ;
7177 this . _tsdocConfiguration = CustomDocNodes . configuration ;
7278 this . _markdownEmitter = new CustomMarkdownEmitter ( this . _apiModel ) ;
79+
80+ this . _pluginLoader = new PluginLoader ( ) ;
7381 }
7482
7583 public generateFiles ( outputFolder : string ) : void {
7684 this . _outputFolder = outputFolder ;
7785
86+ if ( this . _documenterConfig ) {
87+ this . _pluginLoader . load ( this . _documenterConfig , ( ) => {
88+ return new MarkdownDocumenterFeatureContext ( {
89+ apiModel : this . _apiModel ,
90+ outputFolder : outputFolder ,
91+ documenter : new MarkdownDocumenterAccessor ( {
92+ getLinkForApiItem : ( apiItem : ApiItem ) => {
93+ return this . _getLinkFilenameForApiItem ( apiItem ) ;
94+ }
95+ } )
96+ } ) ;
97+ } ) ;
98+ }
99+
78100 console . log ( ) ;
79101 this . _deleteOldOutputFiles ( ) ;
80102
81103 for ( const apiPackage of this . _apiModel . packages ) {
82104 console . log ( `Writing ${ apiPackage . name } package` ) ;
83105 this . _writeApiItemPage ( apiPackage ) ;
84106 }
107+
108+ if ( this . _pluginLoader . markdownDocumenterFeature ) {
109+ this . _pluginLoader . markdownDocumenterFeature . onFinished ( { } ) ;
110+ }
85111 }
86112
87113 private _writeApiItemPage ( apiItem : ApiItem ) : void {
0 commit comments