Our goal is to revisit this relatively soon. If the type system work succeeds, we will introduce a new syntax for defining structs and we will make documentation a core part of field names.
On Thu, Oct 19, 2023 at 07:59 Wojtek Mach <woj...@wojtekmach.pl> wrote: > > PS. Having already typed this, it could be possible maybe if the `@doc` > attribute could be shaped like > > `@doc x: 1, y: 2` already works and so does `@moduledoc …`. The data is > written into metadata section of the docs chunk. If you support this in > Next LS and tell users it’s possible, it will totally work today. However > it would be best if this metadata name and shape is standardised, something > I’m definitely in favour of, and used by ExDoc and similar tools too. > > Similarly I’d love to see something like this: > > @doc options: [ > foo: “the foo option”, > bar: “the bar option”, > ] > def f(options) > > > > > On 19 Oct 2023, at 03:58, Mitchell Hanberg <the.mitch.hanb...@gmail.com> > wrote: > > Hi! > > I have no idea if this is really even possible, or what the syntax could > be, but I am curious to hear the reception to the proposal of having > documentation for Struct fields. > > You can already add an `@doc` attribute to `defstruct`. > > This curiosity somewhat stems from being able to show docs for struct > fields when providing completion candidates for intellisense programs like > an LSP server. > > The current struct syntax does not seem to lend itself well to something > like this, but if this proposal sounds any bit interesting, I'm sure we > could think of something. > > Also, if you can already do this and I somehow missed it after 5 years of > being in this community, please correct me 😅 > > - Mitch > > PS. Having already typed this, it could be possible maybe if the `@doc` > attribute could be shaped like > > ```elixir > @doc struct: "i'm a stuct", > fields: [ > foo: "I'm the foo field!", > bar: "I'm the bar field!" > ] > defstruct foo: nil, bar: nil > ``` > > -- > You received this message because you are subscribed to the Google Groups > "elixir-lang-core" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to elixir-lang-core+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/elixir-lang-core/f5a7fc37-865c-4c92-b8c9-485f46183700n%40googlegroups.com > <https://groups.google.com/d/msgid/elixir-lang-core/f5a7fc37-865c-4c92-b8c9-485f46183700n%40googlegroups.com?utm_medium=email&utm_source=footer> > . > > > -- > You received this message because you are subscribed to the Google Groups > "elixir-lang-core" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to elixir-lang-core+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/elixir-lang-core/89FA1347-3A76-4A64-93F7-3E0CBDD6FF79%40wojtekmach.pl > <https://groups.google.com/d/msgid/elixir-lang-core/89FA1347-3A76-4A64-93F7-3E0CBDD6FF79%40wojtekmach.pl?utm_medium=email&utm_source=footer> > . > -- You received this message because you are subscribed to the Google Groups "elixir-lang-core" group. To unsubscribe from this group and stop receiving emails from it, send an email to elixir-lang-core+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/CAGnRm4J3tk54-Q3sRVt-AGCO_zUFSsfR3zh6Lz%3DHs6uiGZqgZg%40mail.gmail.com.