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: add code helper #15

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

geovie
Copy link
Contributor

@geovie geovie commented Jan 24, 2021

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 by node 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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant