mirror of
https://github.com/google/comprehensive-rust.git
synced 2025-05-23 10:50:18 +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_END: &str = "}}";
|
||||
const FILENAME_START: &str = "<!-- File ";
|
||||
const FILENAME_END: &str = " -->";
|
||||
|
||||
fn main() -> anyhow::Result<()> {
|
||||
pretty_env_logger::init();
|
||||
@ -59,9 +61,15 @@ fn main() -> anyhow::Result<()> {
|
||||
for event in parser {
|
||||
trace!("{:?}", event);
|
||||
match event {
|
||||
Event::Code(x) => {
|
||||
info!("{}:", x);
|
||||
next_filename = Some(x.into_string());
|
||||
Event::Html(html) => {
|
||||
let html = html.trim();
|
||||
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)) => {
|
||||
info!("Start {:?}", x);
|
||||
|
@ -25,6 +25,8 @@ following files.
|
||||
|
||||
`src/main.rs`:
|
||||
|
||||
<!-- File src/main.rs -->
|
||||
|
||||
```rust,compile_fail
|
||||
{{#include compass/src/main.rs:top}}
|
||||
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):
|
||||
|
||||
<!-- File Cargo.toml -->
|
||||
|
||||
```toml
|
||||
{{#include compass/Cargo.toml}}
|
||||
```
|
||||
|
||||
`Embed.toml` (you shouldn't need to change this):
|
||||
|
||||
<!-- File Embed.toml -->
|
||||
|
||||
```toml
|
||||
{{#include compass/Embed.toml}}
|
||||
```
|
||||
|
||||
`.cargo/config.toml` (you shouldn't need to change this):
|
||||
|
||||
<!-- File .cargo/config.toml -->
|
||||
|
||||
```toml
|
||||
{{#include compass/.cargo/config.toml}}
|
||||
```
|
||||
|
@ -8,6 +8,9 @@ Download the [exercise template](../../exercises.zip) and look in the `rtc` dire
|
||||
following files.
|
||||
|
||||
`src/main.rs`:
|
||||
|
||||
<!-- File src/main.rs -->
|
||||
|
||||
```rust,compile_fail
|
||||
{{#include rtc/src/main.rs:top}}
|
||||
|
||||
@ -21,56 +24,89 @@ following files.
|
||||
```
|
||||
|
||||
`src/exceptions.rs` (you shouldn't need to change this):
|
||||
|
||||
<!-- File src/exceptions.rs -->
|
||||
|
||||
```rust,compile_fail
|
||||
{{#include rtc/src/exceptions.rs}}
|
||||
```
|
||||
|
||||
`src/logger.rs` (you shouldn't need to change this):
|
||||
|
||||
<!-- File src/logger.rs -->
|
||||
|
||||
```rust,compile_fail
|
||||
{{#include rtc/src/logger.rs}}
|
||||
```
|
||||
|
||||
`src/pl011.rs` (you shouldn't need to change this):
|
||||
|
||||
<!-- File src/pl011.rs -->
|
||||
|
||||
```rust,compile_fail
|
||||
{{#include rtc/src/pl011.rs}}
|
||||
```
|
||||
|
||||
`Cargo.toml` (you shouldn't need to change this):
|
||||
|
||||
<!-- File Cargo.toml -->
|
||||
|
||||
```toml
|
||||
{{#include rtc/Cargo.toml}}
|
||||
```
|
||||
|
||||
`build.rs` (you shouldn't need to change this):
|
||||
|
||||
<!-- File build.rs -->
|
||||
|
||||
```rust,compile_fail
|
||||
{{#include rtc/build.rs}}
|
||||
```
|
||||
|
||||
`entry.S` (you shouldn't need to change this):
|
||||
|
||||
<!-- File entry.S -->
|
||||
|
||||
```armasm
|
||||
{{#include rtc/entry.S}}
|
||||
```
|
||||
|
||||
`exceptions.S` (you shouldn't need to change this):
|
||||
|
||||
<!-- File exceptions.S -->
|
||||
|
||||
```armasm
|
||||
{{#include rtc/exceptions.S}}
|
||||
```
|
||||
|
||||
`idmap.S` (you shouldn't need to change this):
|
||||
|
||||
<!-- File idmap.S -->
|
||||
|
||||
```armasm
|
||||
{{#include rtc/idmap.S}}
|
||||
```
|
||||
|
||||
`image.ld` (you shouldn't need to change this):
|
||||
|
||||
<!-- File image.ld -->
|
||||
|
||||
```ld
|
||||
{{#include rtc/image.ld}}
|
||||
```
|
||||
|
||||
`Makefile` (you shouldn't need to change this):
|
||||
|
||||
<!-- File Makefile -->
|
||||
|
||||
```makefile
|
||||
{{#include rtc/Makefile}}
|
||||
```
|
||||
|
||||
`.cargo/config.toml` (you shouldn't need to change this):
|
||||
|
||||
<!-- File .cargo/config.toml -->
|
||||
|
||||
```toml
|
||||
{{#include rtc/.cargo/config.toml}}
|
||||
```
|
||||
|
Loading…
x
Reference in New Issue
Block a user