scala / scala3

The Scala 3 compiler, also known as Dotty.
https://dotty.epfl.ch
Apache License 2.0
5.81k stars 1.05k forks source link

Link children of sealed traits more prominently #11093

Closed abgruszecki closed 3 years ago

abgruszecki commented 4 years ago

In Scaladoc, one could see the children of sealed traits by opening "known subclasses", but this always felt a bit hidden.

Should we instead display them more prominently, perhaps in a separate tab?

BarkingBad commented 3 years ago

We could add separate tab for sealed subclasses, or we can add graphical representation to Graph that would would have indicate that two classes are related to each other. It can be either some text/symbol (e. g. closed lock 🔒) attached to arrows or we can try add clusters that d3 js supports that add background rectangle aggregating given graph nodes.

Which solution do you feel is the most straightforward @romanowski @abgruszecki @pikinier20 ?

romanowski commented 3 years ago

I am not sure about another tab but adding information if the class is sealed and mark sealed parents in Graph, Supertypes, Known subtypes should be enough.

cluster also sounds promising.

pikinier20 commented 3 years ago

Also adding closed lock for every sealed member in graph would be nice. Clusters might get ugly when sb creates sealed trait and then extend it with another sealed trait etc.

BarkingBad commented 3 years ago

@Katrix do you have any thoughts on that?

abgruszecki commented 3 years ago

With the way Scala3doc works now, we wouldn't display a separate tab, just a toggle-able section. I think that still might make sense. Really, the first thing I want to see when going to a page of a class like Option is the list of all of its children.

Katrix commented 3 years ago

Maybe make the distinction between a sealed trait an an enum. For an enum they should definitively be front and center IMO. I'd still like to keep the known subtypes section though

BarkingBad commented 3 years ago

I made a small prototype, how do you find it? obraz

abgruszecki commented 3 years ago

I think the locks are really noisy, visually. I think it'd look better if the lock was displayed only next to the types which are actually sealed. If we really want to display more information than that, then perhaps we should display the inheritance arrows with a different color when the parent is sealed?

BarkingBad commented 3 years ago

only next to the types which are actually sealed

do you mean next to trait A and trait B1 in our case or next to children of trait A and trait B1 or next to both parent and children? Also, it can be hard to have straightforward solution to have lock next to rectangle, the easy way to achieve that is to appended the lock to the name.

abgruszecki commented 3 years ago

I understand that trait A and trait B1 are the ones actually defined as sealed? If yes, then I was suggesting displaying a lock next to those.

If we can only display the lock inside the box, then maybe we should just display the sealed keyword?

BarkingBad commented 3 years ago

Yes, we can, though the idea behind graph was to reduce information about the nodes to minimum, as it will expand rectangles size greatly. Will show updated version soon.

BarkingBad commented 3 years ago

@abgruszecki how do you like it? obraz

abgruszecki commented 3 years ago

@BarkingBad I think it looks fine. It even helps a bit visually that the sealed types have larger boxes, it helps distinguish them from the rest.