Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move the Properties block to be above Functions #2908

Merged
merged 3 commits into from Apr 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt
Expand Up @@ -90,17 +90,17 @@ open class HtmlRenderer(
listOf(
BasicTabbedContentType.CONSTRUCTOR,
BasicTabbedContentType.TYPE,
BasicTabbedContentType.FUNCTION,
BasicTabbedContentType.PROPERTY
BasicTabbedContentType.PROPERTY,
BasicTabbedContentType.FUNCTION
Comment on lines +93 to +94
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changing the order here doesn't actually do anything, so it's just for consistency

)
),
if (extensions.isEmpty()) null else ContentTab(
"Members & Extensions",
listOf(
BasicTabbedContentType.CONSTRUCTOR,
BasicTabbedContentType.TYPE,
BasicTabbedContentType.FUNCTION,
BasicTabbedContentType.PROPERTY,
BasicTabbedContentType.FUNCTION,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be nice to drop a comment about the order's meaning and why the order is the way it is

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately, here the order doesn't make any difference, even though I expected it would :( Here it's purely cosmetic and I made the change for consistency. Something tells me leaving a comment like that here could be confusing down the road..

I'll write the tests for the true order though

BasicTabbedContentType.EXTENSION_PROPERTY,
BasicTabbedContentType.EXTENSION_FUNCTION
)
Expand Down
Expand Up @@ -318,10 +318,10 @@ open class DefaultPageCreator(
"Inherited functions", inheritedFunctions + inheritedExtensionFunctions
)
} else {
functionsBlock("Functions", functions + extensionFuns)
propertiesBlock(
"Properties", properties + extensionProps
)
functionsBlock("Functions", functions + extensionFuns)
}
}

Expand Down Expand Up @@ -740,4 +740,4 @@ internal inline fun <reified T : NamedTagWrapper> GroupedTags.withTypeNamed(): M
// Annotations might have constructors to substitute reflection invocations
// and for internal/compiler purposes, but they are not expected to be documented
// and instantiated directly under normal circumstances, so constructors should not be rendered.
internal fun List<Documentable>.shouldDocumentConstructors() = !this.any { it is DAnnotation }
internal fun List<Documentable>.shouldDocumentConstructors() = !this.any { it is DAnnotation }
36 changes: 36 additions & 0 deletions plugins/base/src/test/kotlin/renderers/html/TabbedContentTest.kt
Expand Up @@ -142,4 +142,40 @@ class TabbedContentTest : BaseAbstractTest() {
}
}
}

@Test
fun `should have expected order of content types within a members tab`() {
val source = """
|/src/main/kotlin/test/Result.kt
|package example
|
|class Result(val d: Int = 0) {
| class Success(): Result()
|
| val isFailed = false
| fun reset() = 0
| fun String.extension() = 0
|}
"""
val writerPlugin = TestOutputWriterPlugin()

testInline(
source,
configuration,
pluginOverrides = listOf(writerPlugin)
) {
renderingStage = { _, _ ->
val classContent = writerPlugin.writer.renderedContent("root/example/-result/index.html")
val tabSectionNames = classContent.select("div .tabs-section-body > div[data-togglable]")
.map { it.attr("data-togglable") }

val expectedOrder = listOf("CONSTRUCTOR", "TYPE", "PROPERTY", "FUNCTION")

assertEquals(expectedOrder.size, tabSectionNames.size)
expectedOrder.forEachIndexed { index, element ->
assertEquals(element, tabSectionNames[index])
}
}
}
}
}
Expand Up @@ -205,21 +205,21 @@ class InheritedAccessorsSignatureTest : BaseAbstractTest() {
"Expected 5 signatures: class signature, constructor, property and two accessor lookalikes"
)

val getterLookalikeFunction = signatures[2]
val getterLookalikeFunction = signatures[3]
getterLookalikeFunction.match(
"open fun ", A("getA"), "():", A("Int"),
ignoreSpanWithTokenStyle = true
)

val setterLookalikeFunction = signatures[3]
val setterLookalikeFunction = signatures[4]
setterLookalikeFunction.match(
"open fun ", A("setA"), "(", Parameters(
Parameter("a: ", A("Int"))
), ")",
ignoreSpanWithTokenStyle = true
)

val property = signatures[4]
val property = signatures[2]
property.match(
"var ", A("a"), ":", A("Int"),
ignoreSpanWithTokenStyle = true
Expand Down