rust-diplomat / diplomat

Experimental Rust tool for generating FFI definitions allowing many other languages to call Rust code
https://rust-diplomat.github.io/book/
Other
532 stars 51 forks source link

Use multi-level argument names in demo_gen #713

Closed robertbastian closed 4 weeks ago

robertbastian commented 1 month ago

Instead of flattening recursive parameters, like year, month, day if the argument is a Date, qualify them: date:month. Argument names are usually written in the context of a type, so when that is missing they are hard to interpret (e.g. name for the locale argument).

Single-argument names can be omitted, i.e. locale:name can just be locale.

Screenshot 2024-10-23 at 15 59 13
ambiguousname commented 1 month ago

Overlaps with #611. I like this solution, but I also know @sffc had some opinions. Does this sound good?

Manishearth commented 1 month ago

I like this, though there's another option which is to store this as some form of metadata that the renderer can use, potentially to group things into regions, or use colons, or something else.

robertbastian commented 1 month ago

This is a low hanging fruit that doesn't require annotating all of ICU4X. Metadata can be built on top of it, but that's considerably more work. The current state is really not good.

Manishearth commented 1 month ago

Oh 100% we should do the easy thing first

sffc commented 1 month ago

I'm good with this, although I still think the better solution is to just name parameters less ambiguously.

ambiguousname commented 1 month ago

Ok, I'm on this when I have some free time

Manishearth commented 4 weeks ago

I like this, though there's another option which is to store this as some form of metadata that the renderer can use, potentially to group things into regions, or use colons, or something else.

Mockup of a good UI for this with <fieldset>

image