-
Notifications
You must be signed in to change notification settings - Fork 10
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
book: build sdk example #1123
book: build sdk example #1123
Conversation
be7d4fb
to
e88d71b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! The idea to use snippets is really nice and an overall improvement.
Now that you've added the bin, should we change the target_path
etc to the guest
package so that if we wanted to, cargo run --example sdk
would actually run?
I'll approve once I generate the docs locally to double check.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Please fix lint |
Sorry, that went completely under my radar. Is now fixed :) |
I purposely wrote I could have shadowed the variable This way it would run out of the box, however this would have made the imports in the book a bit more convoluted. And I am not sure whether that make things better. I think like this we have get the best of both worlds:
But am happy to change anything you consider most appropriate :) |
^This makes sense. I think we can make a separate example repo with a runnable version (and without the heavier computation part) to complement. |
Last week, I corrected some outdated documentation on the sdk usage (#1120). However, the two underlying problems were not address, which are:
There are currently no checkguards done on the sdk interface.
The code snippets in the documentation are hard-coded, which can lead to inconsistencies between the documentation and the actual code (as happened in book: sdk usage correction #1120)
In this PR, I tackle both problem by:
a. created a bin crate (
sdk.rs
) in the examples folder. This way, the compiler will run it's check on the code, and if anything if the interface changes this will trigger a compiler error on the example. This has also the advantage that the code is never run, against running expensive e2e tests.b. I linked in
book
the code snippets to the compiled code in a, to ensure that the code snippets are automatically updated so no extra effort is incurred in updating the docs.