OpenEnergyTools / scl-lib

5 stars 4 forks source link

Why not include helper functions? #39

Open ca-d opened 1 year ago

ca-d commented 1 year ago

I'd love to have helper functions for dealing with SCL documents in here, like e.g. the describe function from scl-diff.

At the moment, my most urgent request would be the inclusion of the identity/selector pair of functions including tag data from open-scd, or maybe an identity/query function pair with a signature like

function identity(element: Element): string | NaN;
function query(scope: XMLDocument | DocumentFragment | Element, tagName: string, identity: string): Element | null;

Could you find it in your heart to include that here? If not, what other place would you suggest we publish those functions from in order to make them re-usable?

danyill commented 1 year ago

That would make me happy also, I have copy and pasted identity/selector too many times into core plugins...

On Wed, 19 Jul 2023, 21:17 cad, @.***> wrote:

I'd love to have helper functions for dealing with SCL documents in here, like e.g. the describe function from scl-diff.

At the moment, my most urgent request would be the inclusion of the identity/selector pair of functions including tag data from open-scd, or maybe an identity/query function pair with a signature like

function identity(element: Element): string | NaN;function query(scope: XMLDocument | DocumentFragment | Element, tagName: string, identity: string): Element | null;

Could you find it in your heart to include that here? If not, what other place would you suggest we publish those functions from in order to make them re-usable?

— Reply to this email directly, view it on GitHub https://github.com/OpenEnergyTools/scl-lib/issues/39, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAFEXX5CCMMHZDU7BCUQPCLXQ6Q3LANCNFSM6AAAAAA2PTVIHE . You are receiving this because you are subscribed to this thread.Message ID: @.***>

JakobVogelsang commented 1 year ago

I am a bit torn, I must tell you. Maybe it is the flashback from the nasty experiences from the meetings in OpenSCD that I am afraid to reproduce here and am biased for this reason...

So far, I have not found a good specification/wording/definition on the limits of helper function, especially anything that is retrieving information from the XMLDocument "query" type functions are a scary thing to me as it potentially can be anything and I already see myself in other endless debates about what should or should not be part of the library.

I do see though that we need to reproduce, at least, what is in foundation of open-scd right now as some plugin migration has started. I therefore would propose this:

Move foundation functionality as is - no additional test and no change of the API to oscd-scl. Then we have at least the global business logic state that is hosted in open-scd right now. This repository I would prefer to have to work on what such a library could become in the future.

ca-d commented 1 year ago

So far, I have not found a good specification/wording/definition on the limits of helper function

What do you think about something along the lines of "a significant piece of work with broad applicability for SCL editing", basically leaving to the maintainer the decision of what makes a significant piece of work (e.g. no one-liners) and broad applicability?

Overall, I believe we could instigate a much stricter maintenance policy here than we ever had in OpenSCD, so I'm not that afraid of a repeat. What are your thoughts about that?