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

kotlin-as-java hides access modifiers #2492

Closed
tripolkaandrey opened this issue May 9, 2022 · 1 comment · Fixed by #2510
Closed

kotlin-as-java hides access modifiers #2492

tripolkaandrey opened this issue May 9, 2022 · 1 comment · Fixed by #2510
Labels
bug good first issue A beginner-friendly issue for which some assistance is expected plugin: kotlin-as-java An issue/PR related to Dokka's kotlin-as-java plugin

Comments

@tripolkaandrey
Copy link
Contributor

Describe the bug
I have a Java project where I am using Dokka. For the proper representation of the documentation for Java, I am using the kotlin-as-java plugin. The produced documentation does not have access modifiers for functions. I have found out that the problem is with the kotlin-as-java plugin. Access modifiers are present when the plugin is not applied.

Expected behaviour
Access modifiers should be displayed.

Screenshots
Dokka output with kotlin-as-java applied.
with kotlin-as-java

Dokka output when kotlin-as-java is not applied.
when `kotlin-as-java` not applied

To Reproduce

  1. Configure Dokka with the provided below configuration.
  2. Create a Java class and methods with different access modifiers.
  3. Run dokkaHtml.

Dokka configuration

dependencies {
  dokkaPlugin("org.jetbrains.dokka:kotlin-as-java-plugin:1.6.20")
}

tasks.withType<DokkaTask>().configureEach {
    dokkaSourceSets.configureEach {
        documentedVisibilities.set(
            setOf(
                Visibility.PUBLIC,
                Visibility.PROTECTED,
            )
        )
    }
}

Installation

  • Operating system: macOS
  • Build tool: Gradle v7.4.2
  • Dokka version: 1.6.20
@IgnatBeresnev IgnatBeresnev added the good first issue A beginner-friendly issue for which some assistance is expected label May 9, 2022
@IgnatBeresnev
Copy link
Member

Hi! Indeed, thanks for reporting the bug. kotlin-as-java plugin is pretty raw, unfortunately :(

The fix is trivial in case anyone wants to contribute - visibility modifiers are simply ignored.

The following line needs to be added:

f.visibility[sourceSet]?.takeIf { it !in ignoredVisibilities }?.name?.let { keyword("$it ") }

between lines 133 and 134 here (so after annotations, but before modifiers)

Tests are necessary for this also, I think KotlinAsJavaPluginTest is OK if there's no other, more suitable place

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug good first issue A beginner-friendly issue for which some assistance is expected plugin: kotlin-as-java An issue/PR related to Dokka's kotlin-as-java plugin
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants