Skip to content

Conversation

@strangesource
Copy link
Contributor

@strangesource strangesource commented Sep 17, 2025

Custom tags brief not rendered for enum entries and constructors

Contrary to what the documentation on the CustomTagContentProvider suggests, the custom tag brief is not rendered for constructors and enum entries. Reported in #4255.

Changes

  • Render content for custom tag briefs for enum entries and constructors
  • Minimal unit test

Issues encountered

While setting up the unit tests i struggled with the assertion DSL. It doesn't seem fight to assert the whole page tree until the node I actually want to ensure is present, maybe you have some suggestion on how this could be improved.

Copy link
Collaborator

@whyoleg whyoleg left a comment

Choose a reason for hiding this comment

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

Sorry for the delay with reviewing :(

The changes look good, but we can simplify the test further by using Style, which will enable us to easily locate all comments with that style.
I would not say that it is fully idiomatic, but it should simplify the test logic.

.filterIsInstance<ContentPage>()
.single { it.name == "Foo" }

page.content.assertNode {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Overall, the test is correct, but it could be done a bit more cleanly. Let's create an additional Style object, add it via CustomTagContentProvider:

// new style
object TestCustomStyle: Style

class TestCustomTagContentProvider : CustomTagContentProvider {
    override fun isApplicable(customTag: CustomTagWrapper): Boolean {
        return customTag.name == "customTag"
    }

    override fun PageContentBuilder.DocumentableContentBuilder.contentForBrief(
        sourceSet: DokkaConfiguration.DokkaSourceSet,
        customTag: CustomTagWrapper
    ) {
        // add style
        comment(customTag.children.single(), styles = mainStyles + setOf(TestCustomStyle))
    }
}

And in that case, it's possible to find it and do an assertion rather easily:

val customTagContents = page.content.withDescendants().filter {
    it.style.contains(TestCustomStyle)
}.toList()

assertEquals(1, customTagContents.size)
customTagContents.single().assertNode {
    group {
        +"custom tag for constructor"
    }
}

import kotlin.test.Test
import kotlin.test.assertEquals

class CustomTagContentProviderTest : BaseAbstractTest() {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Would you also mind adding a test for class documentation and some function documentation with custom tags, so that we have all cases covered in one test?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants