aboutsummaryrefslogtreecommitdiff
path: root/plugins/base/src/main/kotlin/resolvers/external/DefaultExternalLocationProviderFactory.kt
blob: 09ddca0156e46f146dd76839e800837ff1f5606e (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
/*
 * 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.resolvers.external

import org.jetbrains.dokka.base.resolvers.shared.RecognizedLinkFormat
import org.jetbrains.dokka.plugability.DokkaContext

public class DefaultExternalLocationProviderFactory(
    public val context: DokkaContext,
) : ExternalLocationProviderFactory by ExternalLocationProviderFactoryWithCache(
    { doc ->
        when (doc.packageList.linkFormat) {
            RecognizedLinkFormat.KotlinWebsite,
            RecognizedLinkFormat.KotlinWebsiteHtml,
            RecognizedLinkFormat.DokkaOldHtml,
            -> Dokka010ExternalLocationProvider(doc, ".html", context)

            RecognizedLinkFormat.DokkaHtml -> DefaultExternalLocationProvider(doc, ".html", context)
            RecognizedLinkFormat.DokkaGFM,
            RecognizedLinkFormat.DokkaJekyll,
            -> DefaultExternalLocationProvider(doc, ".md", context)

            else -> null
        }
    }
)