Skip to content

Consecutive links and codes not properly handled #4234

@spacedvoid

Description

@spacedvoid

When links and inline code sections appear back-by-back, some of the links and codes are simply not recognized.

Example:

/**
 * `a`[Int]`b`[Long]`c`
 */
fun main() {}

Expected: Dokka generates the description as:

<code>a</code>
<a href="kotlin.Int">Int</a>
<code>b</code>
<a href="kotlin.Long">Long</a>
<code>c</code>

Note: This is strawman HTML, not exactly what Dokka will generate.

Actual: Dokka generates the description as:

<p class="paragraph">
  <code class="lang-kotlin">a</code>
  <a href="https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html">Int</a>
  <code class="lang-kotlin">c</code>
</p>

Notice the Int linking to kotlin.Long.

Screenshot of the generated documentation of main:
Image

The link Int redirects to https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long.

Also tested in K2, results in no difference.

Debugging into Dokka using a DocumentableTransformer shows: (Click to zoom in)
Image
The innermost children shows only 3 elements, and the middle one reads Int and links to kotlin.Long.

These back-to-back links and codes were to replicate how Intellij IDEA renders it pretty, as a workaround for #3571:
Image
Though it is still not right, and the Int here also redirects to kotlin.Long.

Installation

  • Operating system: Windows 11
  • Build tool: Gradle v8.14.3
  • Dokka version: 2.0.0 with V2 enabled
Intellij IDEA, if you need:
IntelliJ IDEA 2025.1.4.1 (Community Edition)
Build #IC-251.27812.49, built on July 25, 2025
Source revision: 735cc3bd3c92f
Runtime version: 21.0.7+9-b895.130 amd64 (JCEF 122.1.9)
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
Toolkit: sun.awt.windows.WToolkit
Windows 11.0
Kotlin plugin: K2 mode
Kotlin analyzer version: 2.2.0-ij251-153
GC: G1 Young Generation, G1 Concurrent GC, G1 Old Generation
Memory: 2952M
Cores: 16
Registry:
  debugger.new.tool.window.layout=true
  ide.experimental.ui=true
  llm.show.ai.promotion.window.on.start=false
  kotlin.scripting.index.dependencies.sources=true
  terminal.new.ui.reworked=true
Non-Bundled Plugins:
  dev.azn9.plugins.discord (2.1.7.242)
Kotlin: 251.27812.49-IJ

Metadata

Metadata

Assignees

No one assigned

    Labels

    blocked: parserDepends on fixes inside Lexer/Parser inside Kotlin Compiler Frontendbug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions