aboutsummaryrefslogtreecommitdiff
path: root/test/src/format/HtmlFormatTest.kt
blob: 752e44249718792fe53d29a1bdb6b75a5bb74e62 (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
package org.jetbrains.dokka.tests

import org.jetbrains.dokka.HtmlFormatService
import org.jetbrains.dokka.HtmlTemplateService
import org.jetbrains.dokka.KotlinLanguageService
import org.jetbrains.kotlin.cli.jvm.config.JavaSourceRoot
import org.jetbrains.kotlin.config.KotlinSourceRoot
import org.junit.Test
import java.io.File

public class HtmlFormatTest {
    private val htmlService = HtmlFormatService(InMemoryLocationService, KotlinLanguageService(), HtmlTemplateService.default())

    @Test fun classWithCompanionObject() {
        verifyOutput("test/data/format/classWithCompanionObject.kt", ".html") { model, output ->
            htmlService.appendNodes(tempLocation, output, model.members.single().members)
        }
    }

    @Test fun htmlEscaping() {
        verifyOutput("test/data/format/htmlEscaping.kt", ".html") { model, output ->
            htmlService.appendNodes(tempLocation, output, model.members.single().members)
        }
    }

    @Test fun overloads() {
        verifyOutput("test/data/format/overloads.kt", ".html") { model, output ->
            htmlService.appendNodes(tempLocation, output, model.members)
        }
    }

    @Test fun overloadsWithDescription() {
        verifyOutput("test/data/format/overloadsWithDescription.kt", ".html") { model, output ->
            htmlService.appendNodes(tempLocation, output, model.members.single().members)
        }
    }

    @Test fun overloadsWithDifferentDescriptions() {
        verifyOutput("test/data/format/overloadsWithDifferentDescriptions.kt", ".html") { model, output ->
            htmlService.appendNodes(tempLocation, output, model.members.single().members)
        }
    }

    @Test fun deprecated() {
        verifyOutput("test/data/format/deprecated.kt", ".package.html") { model, output ->
            htmlService.appendNodes(tempLocation, output, model.members)
        }
        verifyOutput("test/data/format/deprecated.kt", ".class.html") { model, output ->
            htmlService.appendNodes(tempLocation, output, model.members.single().members)
        }
    }

    @Test fun brokenLink() {
        verifyOutput("test/data/format/brokenLink.kt", ".html") { model, output ->
            htmlService.appendNodes(tempLocation, output, model.members.single().members)
        }
    }

    @Test fun codeSpan() {
        verifyOutput("test/data/format/codeSpan.kt", ".html") { model, output ->
            htmlService.appendNodes(tempLocation, output, model.members.single().members)
        }
    }

    @Test fun parenthesis() {
        verifyOutput("test/data/format/parenthesis.kt", ".html") { model, output ->
            htmlService.appendNodes(tempLocation, output, model.members.single().members)
        }
    }

    @Test fun bracket() {
        verifyOutput("test/data/format/bracket.kt", ".html") { model, output ->
            htmlService.appendNodes(tempLocation, output, model.members.single().members)
        }
    }

    @Test fun see() {
        verifyOutput("test/data/format/see.kt", ".html") { model, output ->
            htmlService.appendNodes(tempLocation, output, model.members.single().members)
        }
    }

    @Test fun tripleBackticks() {
        verifyOutput("test/data/format/tripleBackticks.kt", ".html") { model, output ->
            htmlService.appendNodes(tempLocation, output, model.members.single().members)
        }
    }

    @Test fun typeLink() {
        verifyOutput("test/data/format/typeLink.kt", ".html") { model, output ->
            htmlService.appendNodes(tempLocation, output, model.members.single().members.filter { it.name == "Bar"} )
        }
    }

    @Test fun parameterAnchor() {
        verifyOutput("test/data/format/parameterAnchor.kt", ".html") { model, output ->
            htmlService.appendNodes(tempLocation, output, model.members.single().members)
        }
    }

    @Test fun javaSupertypeLink() {
        verifyJavaOutput("test/data/format/javaSupertype.java", ".html") { model, output ->
            htmlService.appendNodes(tempLocation, output, model.members.single().members.single { it.name == "C"}.members.filter { it.name == "Bar"} )
        }
    }

    @Test fun javaLinkTag() {
        verifyJavaOutput("test/data/format/javaLinkTag.java", ".html") { model, output ->
            htmlService.appendNodes(tempLocation, output, model.members.single().members)
        }
    }

    @Test fun javaLinkTagWithLabel() {
        verifyJavaOutput("test/data/format/javaLinkTagWithLabel.java", ".html") { model, output ->
            htmlService.appendNodes(tempLocation, output, model.members.single().members)
        }
    }

    @Test fun javaSeeTag() {
        verifyJavaOutput("test/data/format/javaSeeTag.java", ".html") { model, output ->
            htmlService.appendNodes(tempLocation, output, model.members.single().members)
        }
    }

    @Test fun javaDeprecated() {
        verifyJavaOutput("test/data/format/javaDeprecated.java", ".html") { model, output ->
            htmlService.appendNodes(tempLocation, output, model.members.single().members.single { it.name == "Foo" }.members.filter { it.name == "foo" })
        }
    }

    @Test fun crossLanguageKotlinExtendsJava() {
        verifyOutput(arrayOf(KotlinSourceRoot("test/data/format/crossLanguage/kotlinExtendsJava/Bar.kt"),
                            JavaSourceRoot(File("test/data/format/crossLanguage/kotlinExtendsJava"))),
                ".html") { model, output ->
            htmlService.appendNodes(tempLocation, output, model.members.single().members.filter { it.name == "Bar" })
        }
    }

    @Test fun orderedList() {
        verifyOutput("test/data/format/orderedList.kt", ".html") { model, output ->
            htmlService.appendNodes(tempLocation, output, model.members.single().members.filter { it.name == "Bar" })
        }
    }

    @Test fun linkWithLabel() {
        verifyOutput("test/data/format/linkWithLabel.kt", ".html") { model, output ->
            htmlService.appendNodes(tempLocation, output, model.members.single().members.filter { it.name == "Bar" })
        }
    }

    @Test fun entity() {
        verifyOutput("test/data/format/entity.kt", ".html") { model, output ->
            htmlService.appendNodes(tempLocation, output, model.members.single().members.filter { it.name == "Bar" })
        }
    }
}