aboutsummaryrefslogtreecommitdiff
path: root/src/Formats/HtmlFormatService.kt
blob: 4a0bca6f483f0b0369b5b3706b9236bfa92b5e73 (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
package org.jetbrains.dokka

public class HtmlFormatService(val locationService: LocationService,
                               val signatureGenerator: SignatureGenerator) : FormatService {
    override val extension: String = "html"
    override fun format(node: DocumentationNode, to: StringBuilder) {
        with (to) {
            appendln("<h2>")
            appendln("Summary for ${node.name}")
            appendln("</h2>")
            appendln("<code>")
            appendln(signatureGenerator.render(node))
            appendln("</code>")
            appendln()
            appendln("<p>")
            appendln(node.doc.summary)
            appendln("</p>")
            appendln("<hr/>")

            for (section in node.doc.sections) {
                appendln("<h3>")
                appendln(section.label)
                appendln("</h3>")
                appendln("<p>")
                appendln(section.text)
                appendln("</p>")
            }

            appendln("<h3>")
            appendln("Members")
            appendln("</h3>")
            appendln("<table>")

            appendln("<thead>")
            appendln("<tr>")
            appendln("<td>Member</td>")
            appendln("<td>Signature</td>")
            appendln("<td>Summary</td>")
            appendln("</tr>")
            appendln("</thead>")

            appendln("<tbody>")
            for (member in node.members.sortBy { it.name }) {
                val relativePath = locationService.relativeLocation(node, member, extension)
                appendln("<tr>")
                appendln("<td>")
                append("<a href=\"${relativePath}\">${member.name}</a>")
                appendln("</td>")
                appendln("<td>")
                append("${signatureGenerator.render(member)}")
                appendln("</td>")
                appendln("<td>")
                append("${member.doc.summary}")
                appendln("</td>")
                appendln("</tr>")
            }
            appendln("</tbody>")
            appendln("</table>")

        }
    }
}