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

docs(examples): Create description for each crate in examples/* #3539

Closed
wants to merge 9 commits into from

Conversation

mqxf
Copy link
Contributor

@mqxf mqxf commented Nov 29, 2023

Resolves #2845.

Notes:

@reviewer-or-team

@mqxf mqxf added the A1-inprogress Issue is in progress or PR draft is not ready to be reviewed label Nov 29, 2023
@mqxf mqxf self-assigned this Nov 29, 2023
@mqxf mqxf added A0-pleasereview PR is ready to be reviewed by the team and removed A1-inprogress Issue is in progress or PR draft is not ready to be reviewed labels Nov 30, 2023
@mqxf mqxf requested a review from techraed November 30, 2023 15:55
Copy link
Contributor

@clearloop clearloop left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as we now have documents for examples, we can build docs for them as well https://github.com/gear-tech/gear/blob/master/Makefile#L246

append --examples

Copy link
Member

@techraed techraed left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe the approach to docs should be different. Instead of writing literally every call in each function, you'd better give first some high-level, conceptual comments on purpose of that particular example, execution flow and how it reaches the purpose with that wasm. Entry points details about each procedure in them can be reduced.

Also to be clear, this is a general comment for all documented examples, not only "async" ones.

@@ -16,6 +16,20 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.

//! This program demonstrates the use of async `init` entry point, as well as custom entry point
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would add some information about the execution. Docs should give some more description on async execution flow in this example.

@@ -16,15 +16,17 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.

//! The program demonstrates asynchronous execution and
//! how to use macros `gstd::async_init`/`gstd::async_main`.
//! This program demonstrates asynchronous execution and how to use macros `gstd::async_init` and
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please add a bit more info on the role of async here, as from description it seems same stuff can be done without async.

@@ -16,6 +16,15 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.

//! This program demonstrates the use of an async recursive function using the [`async_recursion`]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Give more higher level explanations of the async execution flow.

// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.

//! This program demonstrates the use of [`msg`] syscalls from an async environment.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
//! This program demonstrates the use of [`msg`] syscalls from an async environment.
//! This program demonstrates the use of [`gstd::msg`] syscalls from an async environment.

Comment on lines +24 to +42
//! [`Send`] uses the [`send_for_reply()`] syscall to send a message back to the source, containing
//! the `kind` in the payload.
//!
//! [`SendWithGas(gas)`] uses the [`send_with_gas_for_reply()`] syscall to send a message back to
//! the source, containing the `kind` in the payload, and `gas` as the gas limit.
//!
//! [`SendBytes`] uses the [`send_bytes_for_reply()`] syscall to send a message back to the source,
//! containing the `kind` encoded as bytes in the payload.
//!
//! [`SendBytesWithGas(gas)`] uses the [`send_bytes_with_gas_for_reply()`] syscall to send a message
//! back to the source, containing the `kind` encoded as bytes in the payload and `gas` as the gas
//! limit.
//!
//! [`SendCommit`] uses the [`MessageHandle`], pushing the `kind` encoded as bytes and using
//! [`commit_for_reply()`] to send the message back to the source.
//!
//! [`SendCommitWithGas(gas)`] uses the [`MessageHandle`], pushing the `kind` encoded as bytes and
//! using [`commit_with_gas_for_reply()`] to send the message back to the source with `gas` as the
//! gas limit.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't need to literally explain every step of the program. These steps are clear, btw. State main of this tester crate (look at the usage).

Comment on lines 19 to 34
//! This program demonstrates use of an async `handle` entry point using the `gstd::async_main`
//! macro.
//!
//! `Init` method gets an address of a program in the payload, which should accept "PING" messages
//! and reply with "PONG".
//!
//! `Handle` is async and gets a [`Command`] in the payload, executes a certain action based on it,
//! and send a [`reply()`] with a payload containing the id of the current message. There are two commands
//! that can be executed: [`Common`] and [`Mutex`].
//!
//! [`Common`] sends three async messages to the ping program, with the payload "PING",
//! awaits the reply and asserts that the reply is "PONG".
//!
//! [`Mutex`] asynchronously locks the mutex, awaiting it, sends a message back to the
//! source of the current message, containing the current message id in the payload, and then
//! it sends a ping message, awaiting the reply and asserting that the reply is "PONG".
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's not clear what this wasms does, what's the purpose of that.

@techraed techraed added A1-inprogress Issue is in progress or PR draft is not ready to be reviewed D4-test Autotests, and examples C3-debt and removed A0-pleasereview PR is ready to be reviewed by the team labels Dec 1, 2023
@breathx
Copy link
Member

breathx commented Jan 8, 2024

Please re-open once work continued

@breathx breathx closed this Jan 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A1-inprogress Issue is in progress or PR draft is not ready to be reviewed C3-debt D4-test Autotests, and examples
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Create description for each crate in examples/*
4 participants