aboutsummaryrefslogtreecommitdiff
path: root/src/Languages/LanguageService.kt
blob: c587335a1b16debd740929d17c575ca44cb7b679 (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
package org.jetbrains.dokka

/**
 * Provides facility for rendering [DocumentationNode] as a language-dependent declaration
 */
interface LanguageService {
    enum class RenderMode {
        /** Brief signature (used in a list of all members of the class). */
        SUMMARY,
        /** Full signature (used in the page describing the member itself */
        FULL
    }

    /**
     * Renders a [node](DocumentationNode) as a class, function, property or other signature in a target language.
     * $node: A [DocumentationNode] to render
     * $returns: [ContentNode] which is a root for a rich content tree suitable for formatting with [FormatService]
     */
    fun render(node: DocumentationNode, renderMode: RenderMode = RenderMode.FULL): ContentNode

    /**
     * Renders [node] as a named representation in the target language
     *
     * For example:
     * ${code org.jetbrains.dokka.example}
     *
     * $node: A [DocumentationNode] to render
     * $returns: [String] which is a string representation of the node's name
     */
    fun renderName(node: DocumentationNode): String
}

fun example(service: LanguageService, node: DocumentationNode) {
    println("Node name: ${service.renderName(node)}")
}