Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Do not generate source links for synthetic elements
Fixes #2544
- Loading branch information
1 parent
fc86d21
commit f690a5d
Showing
4 changed files
with
159 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
package enums | ||
|
||
import org.jetbrains.dokka.SourceLinkDefinitionImpl | ||
import org.jetbrains.dokka.base.testApi.testRunner.BaseAbstractTest | ||
import org.junit.jupiter.api.Disabled | ||
import org.junit.jupiter.api.Test | ||
import signatures.renderedContent | ||
import utils.TestOutputWriterPlugin | ||
import java.io.File | ||
import java.net.URL | ||
import kotlin.test.assertEquals | ||
|
||
class JavaEnumsTest : BaseAbstractTest() { | ||
|
||
// Shouldn't try to give source links to synthetic methods (values, valueOf) if any are present | ||
// https://github.com/Kotlin/dokka/issues/2544 | ||
@Test | ||
fun `java enum with configured source links should not fail build due to any synthetic methods`() { | ||
val configuration = dokkaConfiguration { | ||
sourceSets { | ||
sourceSet { | ||
sourceRoots = listOf("src/") | ||
sourceLinks = listOf( | ||
SourceLinkDefinitionImpl( | ||
localDirectory = "src/main/java", | ||
remoteUrl = URL("https://github.com/user/repo/tree/master/src/main/java"), | ||
remoteLineSuffix = "#L" | ||
) | ||
) | ||
} | ||
} | ||
} | ||
|
||
val writerPlugin = TestOutputWriterPlugin() | ||
|
||
testInline( | ||
""" | ||
|/src/main/java/basic/JavaEnum.java | ||
|package testpackage | ||
| | ||
|public enum JavaEnum { | ||
| ONE, TWO, THREE | ||
|} | ||
""".trimMargin(), | ||
configuration, | ||
pluginOverrides = listOf(writerPlugin) | ||
) { | ||
renderingStage = { _, _ -> | ||
val enumPage = writerPlugin.writer.renderedContent("root/testpackage/-java-enum/index.html") | ||
val sourcesTab = enumPage.select("div[data-togglable=Sources]") | ||
if (sourcesTab.isEmpty()) { | ||
throw AssertionError("Sources tab is empty, enum page: \n$enumPage") | ||
} | ||
val sourceLink = sourcesTab.select("a[href]") | ||
if (sourceLink.isEmpty()) { | ||
throw AssertionError("sourceLink is empty, sources tab:\n$sourcesTab") | ||
} | ||
val sourceLinkValue = sourceLink.attr("href") | ||
if (sourceLinkValue.isEmpty()) { | ||
throw AssertionError("sourceLinkValue is empty, sourceLink:\n$sourceLink") | ||
} | ||
|
||
assertEquals( | ||
"https://github.com/user/repo/tree/master/src/main/java/basic/JavaEnum.java#L3", | ||
sourceLinkValue | ||
) | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters