mirror of
https://github.com/google/comprehensive-rust.git
synced 2025-05-23 19:00:13 +02:00
Use comment rather than inline code to find filename.
This commit is contained in:
parent
9f91699be6
commit
9375126b3c
@ -25,6 +25,8 @@ use std::{
|
|||||||
|
|
||||||
const INCLUDE_START: &str = "{{#include ";
|
const INCLUDE_START: &str = "{{#include ";
|
||||||
const INCLUDE_END: &str = "}}";
|
const INCLUDE_END: &str = "}}";
|
||||||
|
const FILENAME_START: &str = "<!-- File ";
|
||||||
|
const FILENAME_END: &str = " -->";
|
||||||
|
|
||||||
fn main() -> anyhow::Result<()> {
|
fn main() -> anyhow::Result<()> {
|
||||||
pretty_env_logger::init();
|
pretty_env_logger::init();
|
||||||
@ -59,9 +61,15 @@ fn main() -> anyhow::Result<()> {
|
|||||||
for event in parser {
|
for event in parser {
|
||||||
trace!("{:?}", event);
|
trace!("{:?}", event);
|
||||||
match event {
|
match event {
|
||||||
Event::Code(x) => {
|
Event::Html(html) => {
|
||||||
info!("{}:", x);
|
let html = html.trim();
|
||||||
next_filename = Some(x.into_string());
|
if html.starts_with(FILENAME_START) && html.ends_with(FILENAME_END) {
|
||||||
|
next_filename = Some(
|
||||||
|
html[FILENAME_START.len()..html.len() - FILENAME_END.len()]
|
||||||
|
.to_string(),
|
||||||
|
);
|
||||||
|
info!("Next file: {:?}:", next_filename);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Event::Start(Tag::CodeBlock(x)) => {
|
Event::Start(Tag::CodeBlock(x)) => {
|
||||||
info!("Start {:?}", x);
|
info!("Start {:?}", x);
|
||||||
|
@ -25,6 +25,8 @@ following files.
|
|||||||
|
|
||||||
`src/main.rs`:
|
`src/main.rs`:
|
||||||
|
|
||||||
|
<!-- File src/main.rs -->
|
||||||
|
|
||||||
```rust,compile_fail
|
```rust,compile_fail
|
||||||
{{#include compass/src/main.rs:top}}
|
{{#include compass/src/main.rs:top}}
|
||||||
use microbit::{hal::uarte::{Baudrate, Parity, Uarte}, Board};
|
use microbit::{hal::uarte::{Baudrate, Parity, Uarte}, Board};
|
||||||
@ -40,18 +42,24 @@ use microbit::{hal::uarte::{Baudrate, Parity, Uarte}, Board};
|
|||||||
|
|
||||||
`Cargo.toml` (you shouldn't need to change this):
|
`Cargo.toml` (you shouldn't need to change this):
|
||||||
|
|
||||||
|
<!-- File Cargo.toml -->
|
||||||
|
|
||||||
```toml
|
```toml
|
||||||
{{#include compass/Cargo.toml}}
|
{{#include compass/Cargo.toml}}
|
||||||
```
|
```
|
||||||
|
|
||||||
`Embed.toml` (you shouldn't need to change this):
|
`Embed.toml` (you shouldn't need to change this):
|
||||||
|
|
||||||
|
<!-- File Embed.toml -->
|
||||||
|
|
||||||
```toml
|
```toml
|
||||||
{{#include compass/Embed.toml}}
|
{{#include compass/Embed.toml}}
|
||||||
```
|
```
|
||||||
|
|
||||||
`.cargo/config.toml` (you shouldn't need to change this):
|
`.cargo/config.toml` (you shouldn't need to change this):
|
||||||
|
|
||||||
|
<!-- File .cargo/config.toml -->
|
||||||
|
|
||||||
```toml
|
```toml
|
||||||
{{#include compass/.cargo/config.toml}}
|
{{#include compass/.cargo/config.toml}}
|
||||||
```
|
```
|
||||||
|
@ -8,6 +8,9 @@ Download the [exercise template](../../exercises.zip) and look in the `rtc` dire
|
|||||||
following files.
|
following files.
|
||||||
|
|
||||||
`src/main.rs`:
|
`src/main.rs`:
|
||||||
|
|
||||||
|
<!-- File src/main.rs -->
|
||||||
|
|
||||||
```rust,compile_fail
|
```rust,compile_fail
|
||||||
{{#include rtc/src/main.rs:top}}
|
{{#include rtc/src/main.rs:top}}
|
||||||
|
|
||||||
@ -21,56 +24,89 @@ following files.
|
|||||||
```
|
```
|
||||||
|
|
||||||
`src/exceptions.rs` (you shouldn't need to change this):
|
`src/exceptions.rs` (you shouldn't need to change this):
|
||||||
|
|
||||||
|
<!-- File src/exceptions.rs -->
|
||||||
|
|
||||||
```rust,compile_fail
|
```rust,compile_fail
|
||||||
{{#include rtc/src/exceptions.rs}}
|
{{#include rtc/src/exceptions.rs}}
|
||||||
```
|
```
|
||||||
|
|
||||||
`src/logger.rs` (you shouldn't need to change this):
|
`src/logger.rs` (you shouldn't need to change this):
|
||||||
|
|
||||||
|
<!-- File src/logger.rs -->
|
||||||
|
|
||||||
```rust,compile_fail
|
```rust,compile_fail
|
||||||
{{#include rtc/src/logger.rs}}
|
{{#include rtc/src/logger.rs}}
|
||||||
```
|
```
|
||||||
|
|
||||||
`src/pl011.rs` (you shouldn't need to change this):
|
`src/pl011.rs` (you shouldn't need to change this):
|
||||||
|
|
||||||
|
<!-- File src/pl011.rs -->
|
||||||
|
|
||||||
```rust,compile_fail
|
```rust,compile_fail
|
||||||
{{#include rtc/src/pl011.rs}}
|
{{#include rtc/src/pl011.rs}}
|
||||||
```
|
```
|
||||||
|
|
||||||
`Cargo.toml` (you shouldn't need to change this):
|
`Cargo.toml` (you shouldn't need to change this):
|
||||||
|
|
||||||
|
<!-- File Cargo.toml -->
|
||||||
|
|
||||||
```toml
|
```toml
|
||||||
{{#include rtc/Cargo.toml}}
|
{{#include rtc/Cargo.toml}}
|
||||||
```
|
```
|
||||||
|
|
||||||
`build.rs` (you shouldn't need to change this):
|
`build.rs` (you shouldn't need to change this):
|
||||||
|
|
||||||
|
<!-- File build.rs -->
|
||||||
|
|
||||||
```rust,compile_fail
|
```rust,compile_fail
|
||||||
{{#include rtc/build.rs}}
|
{{#include rtc/build.rs}}
|
||||||
```
|
```
|
||||||
|
|
||||||
`entry.S` (you shouldn't need to change this):
|
`entry.S` (you shouldn't need to change this):
|
||||||
|
|
||||||
|
<!-- File entry.S -->
|
||||||
|
|
||||||
```armasm
|
```armasm
|
||||||
{{#include rtc/entry.S}}
|
{{#include rtc/entry.S}}
|
||||||
```
|
```
|
||||||
|
|
||||||
`exceptions.S` (you shouldn't need to change this):
|
`exceptions.S` (you shouldn't need to change this):
|
||||||
|
|
||||||
|
<!-- File exceptions.S -->
|
||||||
|
|
||||||
```armasm
|
```armasm
|
||||||
{{#include rtc/exceptions.S}}
|
{{#include rtc/exceptions.S}}
|
||||||
```
|
```
|
||||||
|
|
||||||
`idmap.S` (you shouldn't need to change this):
|
`idmap.S` (you shouldn't need to change this):
|
||||||
|
|
||||||
|
<!-- File idmap.S -->
|
||||||
|
|
||||||
```armasm
|
```armasm
|
||||||
{{#include rtc/idmap.S}}
|
{{#include rtc/idmap.S}}
|
||||||
```
|
```
|
||||||
|
|
||||||
`image.ld` (you shouldn't need to change this):
|
`image.ld` (you shouldn't need to change this):
|
||||||
|
|
||||||
|
<!-- File image.ld -->
|
||||||
|
|
||||||
```ld
|
```ld
|
||||||
{{#include rtc/image.ld}}
|
{{#include rtc/image.ld}}
|
||||||
```
|
```
|
||||||
|
|
||||||
`Makefile` (you shouldn't need to change this):
|
`Makefile` (you shouldn't need to change this):
|
||||||
|
|
||||||
|
<!-- File Makefile -->
|
||||||
|
|
||||||
```makefile
|
```makefile
|
||||||
{{#include rtc/Makefile}}
|
{{#include rtc/Makefile}}
|
||||||
```
|
```
|
||||||
|
|
||||||
`.cargo/config.toml` (you shouldn't need to change this):
|
`.cargo/config.toml` (you shouldn't need to change this):
|
||||||
|
|
||||||
|
<!-- File .cargo/config.toml -->
|
||||||
|
|
||||||
```toml
|
```toml
|
||||||
{{#include rtc/.cargo/config.toml}}
|
{{#include rtc/.cargo/config.toml}}
|
||||||
```
|
```
|
||||||
|
Loading…
x
Reference in New Issue
Block a user