1
0
mirror of https://github.com/google/comprehensive-rust.git synced 2025-05-19 17:03:13 +02:00
comprehensive-rust/mdbook-exerciser
michael-kerscher 479d834a10
mdbook-exerciser: ensure all code block bytes of the examples are written to the file (#2742)
- write() attempts to write the entire buffer does not guarantee this.
  Not writing all bytes is not considered an error.
  It just returns the number of bytes.
- write_all() ensures that everything is written or throws an error
2025-05-07 11:48:54 -04:00
..
2023-05-30 17:04:19 +02:00

exerciser

This is an mdBook renderer to generate templates for exercises from the Markdown source. Given a Markdown file example.md with one or more sections like:

<!-- File src/main.rs -->

```rust,compile_fail
{{#include example/src/main.rs:main}}

fn some_more_code() {
    // TODO: Write some Rust code here.
}
```

and mdbook configuration in book.toml like:

[output.exerciser]
output-directory = "comprehensive-rust-exercises"

It will create a file book/exerciser/comprehensive-rust-exercises/example/src/main.rs with the appropriate contents.