Skip to content

Commit 7753776

Browse files
vmishenevIgnatBeresnev
authored andcommitted
Do no render Types tab when there are no types (#2900)
(cherry picked from commit dca5c31)
1 parent 4b5a88d commit 7753776

File tree

2 files changed

+35
-1
lines changed

2 files changed

+35
-1
lines changed

plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ open class HtmlRenderer(
117117
private fun createTabsForPackage(page: PackagePage): List<ContentTab> {
118118
val p = page.documentables.single() as DPackage
119119
return listOfNotNull(
120-
ContentTab(
120+
if (p.typealiases.isEmpty() && p.classlikes.isEmpty()) null else ContentTab(
121121
"Types",
122122
listOf(
123123
BasicTabbedContentType.TYPE,

plugins/base/src/test/kotlin/renderers/html/TabbedContentTest.kt

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,40 @@ class TabbedContentTest : BaseAbstractTest() {
7171
}
7272
}
7373

74+
@Test
75+
fun `should not have Types-tab where there are not types`() {
76+
val source = """
77+
|/src/main/kotlin/test/Test.kt
78+
|package example
79+
|
80+
|val p = 0
81+
|fun foo() = 0
82+
|
83+
|/src/main/kotlin/test/PackageTwo.kt
84+
|package example2
85+
|
86+
|class A
87+
"""
88+
val writerPlugin = TestOutputWriterPlugin()
89+
90+
testInline(
91+
source,
92+
configuration,
93+
pluginOverrides = listOf(writerPlugin)
94+
) {
95+
renderingStage = { _, _ ->
96+
val packagePage = writerPlugin.writer.renderedContent("root/example/index.html")
97+
assertEquals(0, packagePage.select("*[data-togglable=TYPE]").size)
98+
assertEquals(1, packagePage.getTabbedTable("PROPERTY").size)
99+
assertEquals(1, packagePage.getTabbedTable("FUNCTION").size)
100+
101+
val packagePage2 = writerPlugin.writer.renderedContent("root/example2/index.html")
102+
assertEquals(2, packagePage2.select("*[data-togglable=TYPE]").size)
103+
assertEquals(0, packagePage2.getTabbedTable("PROPERTY").size)
104+
assertEquals(0, packagePage2.getTabbedTable("FUNCTION").size)
105+
}
106+
}
107+
}
74108

75109
@Test
76110
fun `should have correct order of members and extensions`() {

0 commit comments

Comments
 (0)