@@ -52,36 +52,62 @@ import { DocNoteBox } from '../nodes/DocNoteBox';
52
52
import { Utilities } from '../utils/Utilities' ;
53
53
import { CustomMarkdownEmitter } from '../markdown/CustomMarkdownEmitter' ;
54
54
import { 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' ;
56
61
57
62
/**
58
63
* Renders API documentation in the Markdown file format.
59
64
* For more info: https://en.wikipedia.org/wiki/Markdown
60
65
*/
61
66
export class MarkdownDocumenter {
62
67
private readonly _apiModel : ApiModel ;
63
- private readonly _pluginLoader : PluginLoader ;
68
+ private readonly _documenterConfig : DocumenterConfig | undefined ;
64
69
private readonly _tsdocConfiguration : TSDocConfiguration ;
65
70
private readonly _markdownEmitter : CustomMarkdownEmitter ;
66
71
private _outputFolder : string ;
72
+ private readonly _pluginLoader : PluginLoader ;
67
73
68
- public constructor ( apiModel : ApiModel , pluginLoader : PluginLoader ) {
74
+ public constructor ( apiModel : ApiModel , documenterConfig : DocumenterConfig | undefined ) {
69
75
this . _apiModel = apiModel ;
70
- this . _pluginLoader = pluginLoader ;
76
+ this . _documenterConfig = documenterConfig ;
71
77
this . _tsdocConfiguration = CustomDocNodes . configuration ;
72
78
this . _markdownEmitter = new CustomMarkdownEmitter ( this . _apiModel ) ;
79
+
80
+ this . _pluginLoader = new PluginLoader ( ) ;
73
81
}
74
82
75
83
public generateFiles ( outputFolder : string ) : void {
76
84
this . _outputFolder = outputFolder ;
77
85
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
+
78
100
console . log ( ) ;
79
101
this . _deleteOldOutputFiles ( ) ;
80
102
81
103
for ( const apiPackage of this . _apiModel . packages ) {
82
104
console . log ( `Writing ${ apiPackage . name } package` ) ;
83
105
this . _writeApiItemPage ( apiPackage ) ;
84
106
}
107
+
108
+ if ( this . _pluginLoader . markdownDocumenterFeature ) {
109
+ this . _pluginLoader . markdownDocumenterFeature . onFinished ( { } ) ;
110
+ }
85
111
}
86
112
87
113
private _writeApiItemPage ( apiItem : ApiItem ) : void {
0 commit comments