Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi,
when I've added the rust docs I really wished there would be some kind of check which goes over the code in the docs and checks if it even compiles (similar to how rust-doc does it).
So to improve this a bit here is a simple script (
node scripts/extract.js
) which extracts the js/ts code from the docs to a temporary project, where it can be linted.Some tests need some setup so I've also added a
HiddenCode
component which won't be displayed in the docs, but allows to setup some variables needed for the doc code.For now I only changed one file (
docs/guides/basic_authentication.mdx
) to see if there is interest in this, if yes I can work on the others too.node scripts/insert.js
will insert the changes (between the start/end marker) made in the temporary project and insert them into the md/mdx files.The scripts should round trip so
node scripts/extract.js
followed bynode scripts/insert.js
should not make any change.In the future this could be added to the CI to have some checks that the doc code 'works' at least that it's valid ts code.
It could probably also be extend to the other languages (at least Rust should work)
(The scripts are in JS for now as I didn't want to add any new dependencies, but porting them to TS would probably make sense)