-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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 testing for website code blocks #2014
Conversation
Heavily inspired by tokio-rs/website repo.
Some code snippets are explicitly ignored and some are not run to avoid having to include dependencies for one liners.
Visit the preview URL for this PR (updated for commit e9d217c): https://yew-rs--pr2014-website-code-tests-ocoqi4on.web.app (expires Fri, 03 Sep 2021 12:30:33 GMT) 🔥 via Firebase Hosting GitHub Action 🌎 |
Code snippets can import types from doc_test crate i.e.: ```rust use doc_test::agents::EventBus; ``` This allows for moving some boilerplate away from the example and still checks that the code compiles correctly. Also some slight changes to some of the examples and the information about `ComponentLink` which is deprecated.
Why not put |
The new name makes it more clear the purpose of this crate.
Good point :D I have also renamed |
Description
This PR adds a new crate for testing the website code blocks. This came from this suggestion and the code is essentially tweaked from the tokio-rs/website repo.
Luckily it doesn't wreck havoc with Docusaurus markup to use rust doc test attributes, like
ignore
. Docusaurus attributes, liketitle
, don't seem to cause issues for the doc tests either :)The tests run on the
docs/
path so just themaster
/next
code blocks- I think to test versioned code blocks would require a different crate due to conflicts of the yew versions.Some of the code blocks have been changed quite a bit to add context for it to compile and some seem to have just been old blocks that never got updated.
Some code blocks depend on other types that don't really add to the point of the example but are required for compile checking, this can now be added as module and imported in the code blocks for example:
Part of #2012
Checklist
cargo make pr-flow