Kotlin / dokka

API documentation engine for Kotlin
https://kotl.in/dokka
Apache License 2.0
3.34k stars 396 forks source link

[K2] Inconsistent member representation for Java/Kotlin files #3338

Open atyrin opened 7 months ago

atyrin commented 7 months ago

Parent.java:

public class Parent {
    protected int protectedPropertyWithPublicGetterPublicSetter = 0;

    public int getProtectedPropertyWithPublicGetterPublicSetter() {
        return protectedPropertyWithPublicGetterPublicSetter;
    }

    public void setProtectedPropertyWithPublicGetterPublicSetter(int protectedPropertyWithPublicGetterPublicSetter) {
        this.protectedPropertyWithPublicGetterPublicSetter = protectedPropertyWithPublicGetterPublicSetter;
    }
}

Child.kt

open class Child: Parent()

K1

Java and Kotlin:

image

K2

Java The same as in K1.

Kotlin Inheritor getter/setter methods are omitted.

image

Representation in K2 for Kotlin files looks correct (as no getters/setters are available in the code). But it seems for the Java class, it should be the same.

Installation

Parent: #3328

atyrin commented 7 months ago

Related: #3128

IgnatBeresnev commented 7 months ago

For the given code, the child's page and the parent's page should look the same, as for the K2 child's page, so like this

image

IgnatBeresnev commented 2 months ago

Blocked by #3576

vmishenev commented 1 month ago

The summary based on the spike https://github.com/Kotlin/dokka/issues/3576: Presumably we decided to show a backing field, a getter, and a setter always. We are going to ask to validate our decision other teams, e.g. Kotlin Evolution (as they can have plans on https://youtrack.jetbrains.com/issue/KT-6653).


We are not sure about the case with a private field:

public class A {
   private int prop = 1;
   public int getProp() {
       return prop;
   }
   public void setProp(int a) {
       this.prop = a;
   }
}

Should Dokka display accessors here?! Despite the counter-example below, It seems a field and its accessors should be an united entity.

class B : A() {
    override fun getProp(): Int {
        ....
    }
    override fun setProp(a: Int) {
        ...
    }
}