-
-
Notifications
You must be signed in to change notification settings - Fork 251
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add reference to record
to structs section
#379
Conversation
Thanks for helping to improve the documentation! The reason why This book is intended to be a reference of the language, while the standard library is documented at https://crystal-lang.org/api. And that's where you can find the documentation for If you have suggestions to improve the documentation, please add it to the stdlib API docs in Maybe we could add a hint about |
Ok -sounds good - feel free to close this.
Best wishes,
Bill
… On 2 Jan 2020, at 21:57, Johannes Müller ***@***.***> wrote:
Thanks for helping to improve the documentation!
The reason why record is not documented here is because it's not part of the language. It's a macro provided by the standard library and acts as syntactic sugar for declaring a struct type.
This book is intended to be a reference of the language, while the standard library is documented at https://crystal-lang.org/api. And that's where you can find the documentation for record: https://crystal-lang.org/api/0.32.1/toplevel.html#record(name,*properties)-macro
If you have suggestions to improve the documentation, please add it to the stdlib API docs in src/macros.cr.
Maybe we could add a hint about record to the structs page, which should only act as a reference to the API docs and help readers find the documentation they're looking for.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or unsubscribe.
|
I don't think taking the purely technical view of "this is a macro so it cannot be in the language guide" is helpful to new users. Why not mention records at the bottom of the structs page, that it's a macro, and link to the stdlib documentation? Discoverability of top-level macros like If this is where people are looking, why not help them out and forward them on to the right place, with an explanation? |
I agree with @RX14 I'd like the docs to explain the language, but saying "By the way, there's this very convenient macro in the standard library which you'll most probably stumble upon or find useful" is helpful for everyone. |
I agree that mentioning I find it hard to say where records should be mentioned. I would add records here, though reframing them as an expansion that leads to a |
I wouldn't document records here. I'd document them in the API docs. There's no need for duplication. But there needs to be a short section which forwards you to the right place with 1 sentence about what they are. |
We should do it like Getters and setters: one section at the bottom of the page, one introductory sentence, one snippet, then a link to the API docs entry. The current wording implies records are a first-class concept that is distinct from structs. |
✅ Deploy Preview for crystal-book ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
I have reduced the Records section to a simple example and reference to stdlib docs. I'm also posting a PR to improve the stdlib docs at crystal-lang/crystal#12334 |
record
to structs section
Purpose: Better documet Records. It was mentioned on gitter that there is a simplified way to create data structures (structs) in crystal using Records -- which isn't documented in the Crystal git book.
So I was hoping to document the usage and how they can provide flexible immutable data types.