Skip to content

Commit

Permalink
Do no render Types tab when there are no types (#2900)
Browse files Browse the repository at this point in the history
(cherry picked from commit dca5c31)
  • Loading branch information
vmishenev authored and IgnatBeresnev committed Mar 3, 2023
1 parent 4b5a88d commit 7753776
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ open class HtmlRenderer(
private fun createTabsForPackage(page: PackagePage): List<ContentTab> {
val p = page.documentables.single() as DPackage
return listOfNotNull(
ContentTab(
if (p.typealiases.isEmpty() && p.classlikes.isEmpty()) null else ContentTab(
"Types",
listOf(
BasicTabbedContentType.TYPE,
Expand Down
34 changes: 34 additions & 0 deletions plugins/base/src/test/kotlin/renderers/html/TabbedContentTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,40 @@ class TabbedContentTest : BaseAbstractTest() {
}
}

@Test
fun `should not have Types-tab where there are not types`() {
val source = """
|/src/main/kotlin/test/Test.kt
|package example
|
|val p = 0
|fun foo() = 0
|
|/src/main/kotlin/test/PackageTwo.kt
|package example2
|
|class A
"""
val writerPlugin = TestOutputWriterPlugin()

testInline(
source,
configuration,
pluginOverrides = listOf(writerPlugin)
) {
renderingStage = { _, _ ->
val packagePage = writerPlugin.writer.renderedContent("root/example/index.html")
assertEquals(0, packagePage.select("*[data-togglable=TYPE]").size)
assertEquals(1, packagePage.getTabbedTable("PROPERTY").size)
assertEquals(1, packagePage.getTabbedTable("FUNCTION").size)

val packagePage2 = writerPlugin.writer.renderedContent("root/example2/index.html")
assertEquals(2, packagePage2.select("*[data-togglable=TYPE]").size)
assertEquals(0, packagePage2.getTabbedTable("PROPERTY").size)
assertEquals(0, packagePage2.getTabbedTable("FUNCTION").size)
}
}
}

@Test
fun `should have correct order of members and extensions`() {
Expand Down

0 comments on commit 7753776

Please sign in to comment.