Skip to content

Tutorial Runner

Barrie Byron edited this page Jun 16, 2023 · 14 revisions

The zkApp Tutorials at zkApp Tutorials use a tutorial runner to verify TypeScript code. See tutorial-runner.ts in GitHub.

Thanks to a community member contribution, the tutorial checker verifies the TypeScript code in code blocks:

  • Code fences for TypeScript require ts syntax and a valid filename `ts src/main.ts`
  • Code fences require a valid file path to the example .ts file
  • Code snippets must be valid TypeScript code
  • Line numbers and command prompts ($) are stripped by the copy-to-clipboard action present on the published doc

For example:

image

To prevent the verification when you want to show generic TypeScript code blocks, like examples of using an API, use an ignore flag:

image

In addition to verifying the TypeScript code, the tutorial checker can also run shell commands and check for the returned status code to be successful:

  • Shell fences require a sh syntax
  • Shell snippets require a '$' before the command to tell the tutorial runner to run the command. (It will not verify the output).

For example:

image


To troubleshoot, you can run the tutorial runner locally by installing act and running the following command:

act --job=<tutorial>
# Run tutorial 1: act --job=hello-world
Clone this wiki locally