Skip to content
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

The Sway Book does not contain any examples regarding std usage #2047

Closed
Braqzen opened this issue Jun 19, 2022 · 2 comments
Closed

The Sway Book does not contain any examples regarding std usage #2047

Braqzen opened this issue Jun 19, 2022 · 2 comments
Labels
good first issue Good for newcomers lib: std Standard library P: critical Should be looked at before anything else The Sway Book Everything to do with the Sway Book

Comments

@Braqzen
Copy link
Contributor

Braqzen commented Jun 19, 2022

Summary

Taking a look at the link to the Sway Book for the standard library there is no usage for any type and instead it points the reader directly at the master branch / latest release tag.

That is absolutely not what documentation should be doing.
It's okay to reference the library as an addition for the reader to familiarize themselves with the workings under the hood however we should not be telling the user to "just read the source code".

Every type in the standard library must have its own section which shows simple usage for various usages e.g. initialization, calling some method on the type etc.

This will reduce the questions and confusion from users because they have no reference for the correct usage of the library.
This happens too often and should be prioritized.

@Braqzen Braqzen added good first issue Good for newcomers lib: std Standard library The Sway Book Everything to do with the Sway Book P: critical Should be looked at before anything else labels Jun 19, 2022
@adlerjohn adlerjohn moved this to Todo in Fuel Network Jun 19, 2022
@adlerjohn
Copy link
Contributor

So the original idea here was to rely on auto-generated docs with #161, similar to how Rust docs are generated. That would avoid drift between the implementation and the documentation.

As an example, see the docs for Rust's vec (https://doc.rust-lang.org/std/vec/struct.Vec.html) auto-generated from https://doc.rust-lang.org/src/alloc/vec/mod.rs.html.

However, now that I think about this, any example code would require being able to compile and test things from docstrings, which would be a big lift. Putting things info example files included in The Book would provided us with testable code with no further work.

I would therefore be in favor of making a new section in The Book for stdlib types. The content of the section should include only examples of using the types and not documentation on individual methods to avoid duplication. Readers should be pointed to the respective source files to get documentation for methods.

@adlerjohn adlerjohn mentioned this issue Jun 19, 2022
@mohammadfawaz
Copy link
Contributor

mohammadfawaz commented Jan 28, 2023

Standard library docs generated using forc doc will go live soon. Really important features are finding themselves into the book/reference as needed (such as Result, Option, Vec, etc.). So I'm closing this issue for now.

We will, of course, point to the std lib docs (instead of std lib itself) from the book/reference when they're ready

@github-project-automation github-project-automation bot moved this from Todo to Done in Fuel Network Jan 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers lib: std Standard library P: critical Should be looked at before anything else The Sway Book Everything to do with the Sway Book
Projects
Status: Done
Development

No branches or pull requests

3 participants