1
0
mirror of https://github.com/google/comprehensive-rust.git synced 2025-06-15 22:00:26 +02:00

Add support for speaker notes

This implements a system for speaker notes via `details` elements and
some JavaScript. The general idea is

1. You add speaker notes to each page by wrapping some Markdown code
   in `<details> … </details>`. This is a standard HTML element for,
   well extra details. Browsers will render the element with a toggle
   control for showing/hiding the content.

2. We inject JavaScript on every page which finds these speaker note
   elements. They’re styled slightly and we keep their open/closed
   state in a browser local storage. This ensures that you can keep
   them open/closed across page loads.

3. We add a link to the speaker notes which will open in a new tab.
   The URL is amended with `#speaker-notes-open`, which we detect in
   the new tab: we hide the other content in this case.
   Simultaneously, we hide the speaker notes in the original window.

4. When navigating to a new page, we signal this to the other window.
   We then navigate to the same page. The logic above kicks in and
   hides the right part of the content. This lets the users page
   through the course using either the regular window or the speaker
   notes — the result is the same and both windows stay in sync.

Tested in both Chrome and Firefox. When using a popup speaker note
window, the content loads more smoothly in Chrome, but it still works
fine in Firefox.

Fixes #53.
This commit is contained in:
Martin Geisler
2022-12-27 16:52:41 +01:00
parent 28942d7b9f
commit d5359fa92a
7 changed files with 322 additions and 2 deletions

View File

@ -16,3 +16,21 @@ What you see:
* The `main` function is the entry point of the program.
* Rust has hygienic macros, `println!` is an example of this.
* Rust strings are UTF-8 encoded and can contain any Unicode character.
<details>
This slide tries to make the students comfortable with Rust code. They will see
a ton of it over the next four days so we start small with something familiar.
Key points:
* Rust is very much like other languages in the C/C++/Java tradition. It is
imperative (not functional) and it doesn't try to reinvent things unless
absolutely necessary.
* Rust is modern with full support for things like Unicode.
* Rust uses macros for situations where you want to have a variable number of
arguments (no function [overloading](basic-syntax/functions-interlude.md)).
</details>

View File

@ -18,3 +18,27 @@ fn main() { // Program entry point
}
```
<details>
The code implements the Collatz conjecture: it is believed that the loop will
always end, but this is not yet proved. Edit the code and play with different
inputs.
Key points:
* Explain that all variables are statically typed. Try removing `i32` to trigger
type inference. Try with `i8` instead and trigger a runtime integer overflow.
* Change `let mut x` to `let x`, discuss the compiler error.
* Show how `print!` gives a compilation error if the arguments don't match the
format string.
* Show how you need to use `{}` as a placeholder if you want to print an
expression which is more complex than just a single variable.
* Show the students the standard library, show them how to search for `std::fmt`
which has the rules of the formatting mini-language. It's important that the
students become familiar with searching in the standard library.
</details>

View File

@ -10,3 +10,20 @@ today:
management, and garbage collection.
* Ownership: move semantics, copying and cloning, borrowing, and lifetimes.
<details>
The idea for the first day is to show _just enough_ of Rust to be able to speak
about the famous borrow checker. The way Rust handles memory is a major feature
and we should show students this right away.
If you're teaching this in a classroom, this is a good place to go over the
schedule. We suggest splitting the day into two parts (following the slides):
* Morning: 9:00 to 12:00,
* Afternoon: 13:00 to 16:00.
You can of course adjust this as necessary. Please make sure to include breaks,
we recommend a break every hour!
</details>

View File

@ -14,3 +14,14 @@ Rust is a new programming language which had its 1.0 release in 2015:
* mobile phones,
* desktops,
* servers.
<details>
Rust fits in the same area as C++:
* High flexibility.
* High level of control.
* Can be scaled down to very constrained devices like mobile phones.
</details>