feenkcom / gtoolkit

Glamorous Toolkit is the Moldable Development environment. It empowers you to make systems explainable through experiences tailored for each problem.
https://gtoolkit.com
MIT License
1.09k stars 47 forks source link

[Examples]: Hook Connecting Exemplified Class to Example Source #4026

Open seandenigris opened 1 week ago

seandenigris commented 1 week ago

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

girba commented 1 week ago

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.

seandenigris commented 1 week ago

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.

chisandrei commented 6 days ago

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.

girba commented 5 days ago

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