gtoolkit icon indicating copy to clipboard operation
gtoolkit copied to clipboard

[Examples]: Hook Connecting Exemplified Class to Example Source

Open seandenigris opened this issue 1 year ago • 4 comments

Since the best practice seems (per the GT Book) to create a "class of examples" instead of storing the examples on the class-side of the exemplified class, shouldn't there be a hook to specify the example class so you don't give up Coder's example features (Example tab and runner button) while browsing the exemplified class?

Before: Screenshot_2024-09-18_at_9 37 44_PM

After: Screenshot 2024-09-19 at 9 26 16 PM

First reported on Discord

seandenigris avatar Sep 20 '24 01:09 seandenigris

There is a difference between the container of examples and the target of examples. The existing view denotes the container, not the target. Your change mixes the two. Also, we want the link to come from the example to the class, not from the class to the example because a class can be exemplified in different places.

We can add two views. And revive the <gtExampleTarget: SomeClass> mechanism instead.

girba avatar Sep 20 '24 17:09 girba

It makes sense to reverse the link, but seems like overkill to require annotating each method since the common pattern seems to be that an entire examples class only pertains to one target.

seandenigris avatar Sep 21 '24 02:09 seandenigris

With examples, we often use other examples to compose larger ones. Not all examples in a class end up exemplifying directly the target class. Then just showing all creates noise.

chisandrei avatar Sep 22 '24 20:09 chisandrei

To add what @chisandrei said, we could also provide tool support to suggest the target of an example after running it.

girba avatar Sep 23 '24 09:09 girba

We do not have a good solution for this that works in general yet. I close it for now.

girba avatar Mar 16 '25 19:03 girba