Skip to content

Render custom tag briefs for enum entries and constructor - #4265

Open
strangesource wants to merge 2 commits into
Kotlin:masterfrom
strangesource:fix/render-custom-tag-briefs-for-enum-entries-and-constructor
Open

Render custom tag briefs for enum entries and constructor#4265
strangesource wants to merge 2 commits into
Kotlin:masterfrom
strangesource:fix/render-custom-tag-briefs-for-enum-entries-and-constructor

Conversation

@strangesource

@strangesource strangesource commented Sep 17, 2025

Copy link
Copy Markdown
Contributor

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.

@whyoleg whyoleg left a comment

Copy link
Copy Markdown
Collaborator

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
Copy Markdown
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
Copy Markdown
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?

@whyoleg

whyoleg commented Jan 29, 2026

Copy link
Copy Markdown
Collaborator

@strangesource, are you still willing to finalize the PR?

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