aboutsummaryrefslogtreecommitdiff
path: root/plugins/base/src/main/kotlin/DokkaBase.kt
blob: ca86d4d52d7f98de5d1f4ab9d14029b5b29f40a0 (plain)
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
/*
 * Copyright 2014-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
 */

package org.jetbrains.dokka.base

import org.jetbrains.dokka.CoreExtensions
import org.jetbrains.dokka.base.generation.SingleModuleGeneration
import org.jetbrains.dokka.base.renderers.*
import org.jetbrains.dokka.base.renderers.html.*
import org.jetbrains.dokka.base.renderers.html.command.consumers.PathToRootConsumer
import org.jetbrains.dokka.base.renderers.html.command.consumers.ReplaceVersionsConsumer
import org.jetbrains.dokka.base.renderers.html.command.consumers.ResolveLinkConsumer
import org.jetbrains.dokka.base.resolvers.external.DefaultExternalLocationProviderFactory
import org.jetbrains.dokka.base.resolvers.external.ExternalLocationProviderFactory
import org.jetbrains.dokka.base.resolvers.external.javadoc.JavadocExternalLocationProviderFactory
import org.jetbrains.dokka.base.resolvers.local.DokkaLocationProviderFactory
import org.jetbrains.dokka.base.resolvers.local.LocationProviderFactory
import org.jetbrains.dokka.base.resolvers.shared.RecognizedLinkFormat
import org.jetbrains.dokka.base.signatures.KotlinSignatureProvider
import org.jetbrains.dokka.base.signatures.SignatureProvider
import org.jetbrains.dokka.base.templating.ImmediateHtmlCommandConsumer
import org.jetbrains.dokka.base.transformers.documentables.*
import org.jetbrains.dokka.base.transformers.pages.DefaultSamplesTransformer
import org.jetbrains.dokka.base.transformers.pages.annotations.SinceKotlinTransformer
import org.jetbrains.dokka.base.transformers.pages.comments.CommentsToContentConverter
import org.jetbrains.dokka.base.transformers.pages.comments.DocTagToContentConverter
import org.jetbrains.dokka.base.transformers.pages.merger.*
import org.jetbrains.dokka.base.transformers.pages.sourcelinks.SourceLinksTransformer
import org.jetbrains.dokka.base.transformers.pages.tags.CustomTagContentProvider
import org.jetbrains.dokka.base.transformers.pages.tags.SinceKotlinTagContentProvider
import org.jetbrains.dokka.base.translators.documentables.DefaultDocumentableToPageTranslator
import org.jetbrains.dokka.generation.Generation
import org.jetbrains.dokka.plugability.*
import org.jetbrains.dokka.renderers.Renderer
import org.jetbrains.dokka.transformers.documentation.*
import org.jetbrains.dokka.transformers.pages.PageTransformer

@Suppress("unused")
public class DokkaBase : DokkaPlugin() {

    public val preMergeDocumentableTransformer: ExtensionPoint<PreMergeDocumentableTransformer> by extensionPoint()
    public val pageMergerStrategy: ExtensionPoint<PageMergerStrategy> by extensionPoint()
    public val commentsToContentConverter: ExtensionPoint<CommentsToContentConverter> by extensionPoint()
    public val customTagContentProvider: ExtensionPoint<CustomTagContentProvider> by extensionPoint()
    public val signatureProvider: ExtensionPoint<SignatureProvider> by extensionPoint()
    public val locationProviderFactory: ExtensionPoint<LocationProviderFactory> by extensionPoint()
    public val externalLocationProviderFactory: ExtensionPoint<ExternalLocationProviderFactory> by extensionPoint()
    public val outputWriter: ExtensionPoint<OutputWriter> by extensionPoint()
    public val htmlPreprocessors: ExtensionPoint<PageTransformer> by extensionPoint()

    @Deprecated("It is not used anymore")
    public val tabSortingStrategy: ExtensionPoint<TabSortingStrategy> by extensionPoint()
    public val immediateHtmlCommandConsumer: ExtensionPoint<ImmediateHtmlCommandConsumer> by extensionPoint()


    public val singleGeneration: Extension<Generation, *, *> by extending {
        CoreExtensions.generation providing ::SingleModuleGeneration
    }

    public val documentableMerger: Extension<DocumentableMerger, *, *> by extending {
        CoreExtensions.documentableMerger providing ::DefaultDocumentableMerger
    }

    public val deprecatedDocumentableFilter: Extension<PreMergeDocumentableTransformer, *, *> by extending {
        preMergeDocumentableTransformer providing ::DeprecatedDocumentableFilterTransformer
    }

    public val suppressedDocumentableFilter: Extension<PreMergeDocumentableTransformer, *, *> by extending {
        preMergeDocumentableTransformer providing ::SuppressedByConfigurationDocumentableFilterTransformer
    }

    public val suppressedBySuppressTagDocumentableFilter: Extension<PreMergeDocumentableTransformer, *, *> by extending {
        preMergeDocumentableTransformer providing ::SuppressTagDocumentableFilter
    }

    public val documentableVisibilityFilter: Extension<PreMergeDocumentableTransformer, *, *> by extending {
        preMergeDocumentableTransformer providing ::DocumentableVisibilityFilterTransformer
    }

    public val obviousFunctionsVisbilityFilter: Extension<PreMergeDocumentableTransformer, *, *> by extending {
        preMergeDocumentableTransformer providing ::ObviousFunctionsDocumentableFilterTransformer
    }

    public val inheritedEntriesVisbilityFilter: Extension<PreMergeDocumentableTransformer, *, *> by extending {
        preMergeDocumentableTransformer providing ::InheritedEntriesDocumentableFilterTransformer
    }

    public val kotlinArrayDocumentableReplacer: Extension<PreMergeDocumentableTransformer, *, *> by extending {
        preMergeDocumentableTransformer providing ::KotlinArrayDocumentableReplacerTransformer
    }

    public val emptyPackagesFilter: Extension<PreMergeDocumentableTransformer, *, *> by extending {
        preMergeDocumentableTransformer providing ::EmptyPackagesFilterTransformer order {
            after(
                deprecatedDocumentableFilter,
                suppressedDocumentableFilter,
                documentableVisibilityFilter,
                suppressedBySuppressTagDocumentableFilter,
                obviousFunctionsVisbilityFilter,
                inheritedEntriesVisbilityFilter,
            )
        }
    }

    public val emptyModulesFilter: Extension<PreMergeDocumentableTransformer, *, *> by extending {
        preMergeDocumentableTransformer with EmptyModulesFilterTransformer() order {
            after(emptyPackagesFilter)
        }
    }

    public val modulesAndPackagesDocumentation: Extension<PreMergeDocumentableTransformer, *, *> by extending {
        preMergeDocumentableTransformer providing ::ModuleAndPackageDocumentationTransformer
    }

    public val actualTypealiasAdder: Extension<DocumentableTransformer, *, *> by extending {
        CoreExtensions.documentableTransformer with ActualTypealiasAdder()
    }

    public val kotlinSignatureProvider: Extension<SignatureProvider, *, *> by extending {
        signatureProvider providing ::KotlinSignatureProvider
    }

    public val sinceKotlinTransformer: Extension<DocumentableTransformer, *, *> by extending {
        CoreExtensions.documentableTransformer providing ::SinceKotlinTransformer applyIf {
            SinceKotlinTransformer.shouldDisplaySinceKotlin()
        } order {
            before(extensionsExtractor)
        }
    }

    public val inheritorsExtractor: Extension<DocumentableTransformer, *, *> by extending {
        CoreExtensions.documentableTransformer with InheritorsExtractorTransformer()
    }

    public val undocumentedCodeReporter: Extension<DocumentableTransformer, *, *> by extending {
        CoreExtensions.documentableTransformer with ReportUndocumentedTransformer()
    }

    public val extensionsExtractor: Extension<DocumentableTransformer, *, *> by extending {
        CoreExtensions.documentableTransformer with ExtensionExtractorTransformer()
    }

    public val documentableToPageTranslator: Extension<DocumentableToPageTranslator, *, *> by extending {
        CoreExtensions.documentableToPageTranslator providing ::DefaultDocumentableToPageTranslator
    }

    public val docTagToContentConverter: Extension<CommentsToContentConverter, *, *> by extending {
        commentsToContentConverter with DocTagToContentConverter()
    }

    public val sinceKotlinTagContentProvider: Extension<CustomTagContentProvider, *, *> by extending {
        customTagContentProvider with SinceKotlinTagContentProvider applyIf {
            SinceKotlinTransformer.shouldDisplaySinceKotlin()
        }
    }

    public val pageMerger: Extension<PageTransformer, *, *> by extending {
        CoreExtensions.pageTransformer providing ::PageMerger
    }

    public val sourceSetMerger: Extension<PageTransformer, *, *> by extending {
        CoreExtensions.pageTransformer providing ::SourceSetMergingPageTransformer
    }

    public val fallbackMerger: Extension<PageMergerStrategy, *, *> by extending {
        pageMergerStrategy providing { ctx -> FallbackPageMergerStrategy(ctx.logger) }
    }

    public val sameMethodNameMerger: Extension<PageMergerStrategy, *, *> by extending {
        pageMergerStrategy providing { ctx -> SameMethodNamePageMergerStrategy(ctx.logger) } order {
            before(fallbackMerger)
        }
    }

    public val htmlRenderer: Extension<Renderer, *, *> by extending {
        CoreExtensions.renderer providing ::HtmlRenderer
    }

    public val locationProvider: Extension<LocationProviderFactory, *, *> by extending {
        locationProviderFactory providing ::DokkaLocationProviderFactory
    }

    public val javadocLocationProvider: Extension<ExternalLocationProviderFactory, *, *> by extending {
        externalLocationProviderFactory providing ::JavadocExternalLocationProviderFactory
    }

    public val dokkaLocationProvider: Extension<ExternalLocationProviderFactory, *, *> by extending {
        externalLocationProviderFactory providing ::DefaultExternalLocationProviderFactory
    }

    public val fileWriter: Extension<OutputWriter, *, *> by extending {
        outputWriter providing ::FileWriter
    }

    public val rootCreator: Extension<PageTransformer, *, *> by extending {
        htmlPreprocessors with RootCreator applyIf { !delayTemplateSubstitution }
    }

    public val defaultSamplesTransformer: Extension<PageTransformer, *, *> by extending {
        CoreExtensions.pageTransformer providing ::DefaultSamplesTransformer order {
            before(pageMerger)
        }
    }

    public val sourceLinksTransformer: Extension<PageTransformer, *, *> by extending {
        htmlPreprocessors providing ::SourceLinksTransformer order { after(rootCreator) }
    }

    public val navigationPageInstaller: Extension<PageTransformer, *, *> by extending {
        htmlPreprocessors providing ::NavigationPageInstaller order { after(rootCreator) }
    }

    public val scriptsInstaller: Extension<PageTransformer, *, *> by extending {
        htmlPreprocessors providing ::ScriptsInstaller order { after(rootCreator) }
    }

    public val stylesInstaller: Extension<PageTransformer, *, *> by extending {
        htmlPreprocessors providing ::StylesInstaller order { after(rootCreator) }
    }

    public val assetsInstaller: Extension<PageTransformer, *, *> by extending {
        htmlPreprocessors with AssetsInstaller order { after(rootCreator) } applyIf { !delayTemplateSubstitution }
    }

    public val customResourceInstaller: Extension<PageTransformer, *, *> by extending {
        htmlPreprocessors providing { ctx -> CustomResourceInstaller(ctx) } order {
            after(stylesInstaller)
            after(scriptsInstaller)
            after(assetsInstaller)
        }
    }

    public val packageListCreator: Extension<PageTransformer, *, *> by extending {
        htmlPreprocessors providing {
            PackageListCreator(it, RecognizedLinkFormat.DokkaHtml)
        } order { after(rootCreator) }
    }

    public val sourcesetDependencyAppender: Extension<PageTransformer, *, *> by extending {
        htmlPreprocessors providing ::SourcesetDependencyAppender order { after(rootCreator) }
    }

    public val resolveLinkConsumer: Extension<ImmediateHtmlCommandConsumer, *, *> by extending {
        immediateHtmlCommandConsumer with ResolveLinkConsumer
    }
    public val replaceVersionConsumer: Extension<ImmediateHtmlCommandConsumer, *, *> by extending {
        immediateHtmlCommandConsumer providing ::ReplaceVersionsConsumer
    }
    public val pathToRootConsumer: Extension<ImmediateHtmlCommandConsumer, *, *> by extending {
        immediateHtmlCommandConsumer with PathToRootConsumer
    }
    public val baseSearchbarDataInstaller: Extension<PageTransformer, *, *> by extending {
        htmlPreprocessors providing ::SearchbarDataInstaller order { after(sourceLinksTransformer) }
    }

    //<editor-fold desc="Deprecated API left for compatibility">
    @Suppress("DEPRECATION_ERROR")
    @Deprecated(message = org.jetbrains.dokka.base.deprecated.ANALYSIS_API_DEPRECATION_MESSAGE, level = DeprecationLevel.ERROR)
    public val kotlinAnalysis: ExtensionPoint<org.jetbrains.dokka.analysis.KotlinAnalysis> by extensionPoint()

    @Suppress("DEPRECATION_ERROR")
    @Deprecated(message = org.jetbrains.dokka.base.deprecated.ANALYSIS_API_DEPRECATION_MESSAGE, level = DeprecationLevel.ERROR)
    public val externalDocumentablesProvider: ExtensionPoint<org.jetbrains.dokka.base.translators.descriptors.ExternalDocumentablesProvider> by extensionPoint()

    @Suppress("DEPRECATION_ERROR")
    @Deprecated(message = org.jetbrains.dokka.base.deprecated.ANALYSIS_API_DEPRECATION_MESSAGE, level = DeprecationLevel.ERROR)
    public val externalClasslikesTranslator: ExtensionPoint<org.jetbrains.dokka.base.translators.descriptors.ExternalClasslikesTranslator> by extensionPoint()

    @Suppress("DeprecatedCallableAddReplaceWith")
    @Deprecated(message = org.jetbrains.dokka.base.deprecated.ANALYSIS_API_DEPRECATION_MESSAGE, level = DeprecationLevel.ERROR)
    public val descriptorToDocumentableTranslator: org.jetbrains.dokka.plugability.Extension<org.jetbrains.dokka.transformers.sources.SourceToDocumentableTranslator, *, *>
        get() = throw org.jetbrains.dokka.base.deprecated.AnalysisApiDeprecatedError()

    @Suppress("DeprecatedCallableAddReplaceWith")
    @Deprecated(message = org.jetbrains.dokka.base.deprecated.ANALYSIS_API_DEPRECATION_MESSAGE, level = DeprecationLevel.ERROR)
    public val psiToDocumentableTranslator: org.jetbrains.dokka.plugability.Extension<org.jetbrains.dokka.transformers.sources.SourceToDocumentableTranslator, *, *>
        get() = throw org.jetbrains.dokka.base.deprecated.AnalysisApiDeprecatedError()

    @Suppress("DEPRECATION_ERROR", "DeprecatedCallableAddReplaceWith")
    @Deprecated(message = org.jetbrains.dokka.base.deprecated.ANALYSIS_API_DEPRECATION_MESSAGE, level = DeprecationLevel.ERROR)
    public val defaultKotlinAnalysis: org.jetbrains.dokka.plugability.Extension<org.jetbrains.dokka.analysis.KotlinAnalysis, *, *>
        get() = throw org.jetbrains.dokka.base.deprecated.AnalysisApiDeprecatedError()

    @Suppress("DEPRECATION_ERROR", "DeprecatedCallableAddReplaceWith")
    @Deprecated(message = org.jetbrains.dokka.base.deprecated.ANALYSIS_API_DEPRECATION_MESSAGE, level = DeprecationLevel.ERROR)
    public val defaultExternalDocumentablesProvider: org.jetbrains.dokka.plugability.Extension<org.jetbrains.dokka.base.translators.descriptors.ExternalDocumentablesProvider, *, *>
        get() = throw org.jetbrains.dokka.base.deprecated.AnalysisApiDeprecatedError()

    @Suppress("DEPRECATION_ERROR", "DeprecatedCallableAddReplaceWith")
    @Deprecated(message = org.jetbrains.dokka.base.deprecated.ANALYSIS_API_DEPRECATION_MESSAGE, level = DeprecationLevel.ERROR)
    public val defaultExternalClasslikesTranslator: org.jetbrains.dokka.plugability.Extension<org.jetbrains.dokka.base.translators.descriptors.ExternalClasslikesTranslator, *, *>
        get() = throw org.jetbrains.dokka.base.deprecated.AnalysisApiDeprecatedError()
    //</editor-fold>

    @OptIn(DokkaPluginApiPreview::class)
    override fun pluginApiPreviewAcknowledgement(): PluginApiPreviewAcknowledgement =
        PluginApiPreviewAcknowledgement
}