Commit Graph
100 Commits
Author SHA1 Message Date
Martin Geisler 31500974e4 Add note about requesting a room with tables (#479)
* Add note about requesting a room with tables

The course is built on the idea of using live-coding as much as possible. This means that it's important that there are desks in the classrooms — a traditional auditorium setup does not work well.
2023-03-06 15:23:10 +01:00
Martin Geisler 449ead5575 Integrate GA4 code directly with book.js (#470)
* Integrate GA4 code directly with `book.js`

The main advantage of this is that it simplifies the setup since we
can avoid the monkey-patching we did before.

A secondary advantage is that it should make things a little faster
since we avoid a request to the server on every page load.

* Remove unreachable return

* Watch all of `third_party`

It just occurred to me that we want to refresh the page in `mdbook serve` when anything changes in `third_party`.
2023-03-02 17:50:37 +00:00
Martin Geisler 2de8d7cdbb Simplify running the course slightly (#463)
Thanks to many contributors, we now have lots of speaker notes.
2023-03-02 09:13:49 +01:00
Martin Geisler 7e47e31408 Group per-translation output in publish step (#467) 2023-03-02 06:38:32 +09:00
Martin Geisler adc6720031 Increase playground timeout to 15 seconds
We often see timeouts when running the course. Most of the time, the
code compiles on the second try, which indicates that we just need to
wait a little longer.

Fixes #406.
2023-03-01 13:14:42 +01:00
Martin Geisler 2a2f8ec94e Add book.js generated with mdbook init --theme
This allows us to customize the JavaScript used on the page.
2023-03-01 13:14:42 +01:00
Martin Geisler 1feb94e02a Take out unnecessary code from enum size slide (#309)
The slide is way too large to comfortable use in a classroom. Instead
of printing six lines of output, the instructor should carefully walk
through the different examples. That way we can take the course
participants with us through the explanations instead of simply
showing them the end result.
2023-02-27 17:42:46 +01:00
Martin Geisler 261bcfce3e Show Markdown diff as unified diff (#454)
Also add nice colors to make things pretty.
2023-02-24 16:46:08 +01:00
Martin Geisler 5c03394b31 Lock mdbook and mdbook-svgbob version numbers (#398)
This will help avoid breakage[1] when mdbook and mdbook-svgbob are out
of sync with each other.

[1]: https://github.com/boozook/mdbook-svgbob/issues/25.
2023-02-16 13:39:19 +01:00
Martin Geisler bc2dbd0fd3 Add a page which mentions the translations (#424)
This is to help people discover the language picker.
2023-02-16 13:21:45 +01:00
Martin Geisler f16b41f012 Further simplify Box diagrams (#409)
* Further simplify `Box` diagrams

I think we can improve the drawing by simplifying them and making them
more symbolic. Followup to #374.

* Apply suggestions from code review
2023-02-15 18:10:50 +00:00
Martin Geisler 14b5e86579 Fix links in language picker (#417)
When the current page is not `en`, we need to add an additional `../`
to the path to reach the top of the site.
2023-02-15 18:59:58 +01:00
Martin Geisler 3b7123d21a Add language picker menu (#411)
The picker is a drop-down menu using the same design as the theme
picker in the top-left.

There doesn’t seem to be an easy way to pass in a list of languages
and descriptions, so for now we’ll have to expand the menu by hand as
we add new languages. A comment has been added to `publish.yml` to
remind us of this.
2023-02-15 15:10:16 +01:00
Martin Geisler c1e1963839 Update CODEOWNERS after pt-BR.po rename (#397)
The file was renamed in #381 but I forgot to update the path here.
2023-02-13 17:42:56 +01:00
Martin Geisler be5263010a Use .po file as target for edit link on translations (#394) 2023-02-13 17:42:45 +01:00
Martin Geisler 3a29be8c7d Publish Brazilian Portuguese translation (#381)
The IETF language tag for “Brazilian Portuguese” is “pt-BR”[1]. This
tag is also used in the HTML lang attribute[2].

We derive the language code directly from the “.po” filename, so I’ve
renamed “pt_BR.po” to “pt-BR.po” make everything use the correct
language code. Nothing in the Gettext pipeline cares about the precise
filename, so it should be fine to rename it like this.

[1]: https://en.wikipedia.org/wiki/Brazilian_Portuguese#Language_codes
[2]: https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/lang
2023-02-13 13:45:58 +00:00
Martin Geisler dd2c38a19d Add all translators to CODEOWNERS (#385) 2023-02-10 15:46:02 +01:00
Martin Geisler e054abd3da Clear language-team field from pt_BR.po (#384)
The translators are not actually part of this team.
2023-02-10 15:45:52 +01:00
Martin Geisler c4bc10e31d Inline variables printed with println! and friends (#315)
The course follows the style of inlining variable names where possible
in `println!` statements.
2023-02-09 07:48:18 +01:00
Martin Geisler f90fecb449 Add hint about using a PO editor (#356) 2023-02-06 20:17:36 +01:00
Martin Geisler 413098cdac Upload build output as artifacts (#342)
This makes it super easy for translators to see the results of their
work: every PR will now have a list of artifacts, one per translation.
2023-02-06 17:20:32 +01:00
Martin Geisler f9dea3d7a3 Setup redirects after #120 and #177 (#352)
This makes `mdbook` output a simple redirect at the location of the
old pages. I’ll try to add such pages when we shuffle around our
pages to make sure external links stay valid.
2023-02-06 17:10:01 +01:00
Martin Geisler a07bfa108f Wrap long line of code (#312)
This line was too big to show during class.
2023-02-01 12:34:10 +01:00
Martin Geisler 476ee283c6 Simplify Vec slide (#313)
The code is probably meant to illustrate the `vec!` macro, but it
feels out of place when teaching: there is already enough material
here to get through.
2023-02-01 10:49:11 +01:00
Martin Geisler d6182ea498 Fix missing word (#311) 2023-01-31 20:09:00 +00:00
Martin Geisler c6a54ce9a9 Show the pair returned by duplicate (#314)
This makes it easier to talk about the code as you make changes to the
`duplicate` function.
2023-01-31 21:08:09 +01:00
Martin Geisler dee5e654c8 Fix order of standard library slides (#310)
The slides now follow the order on the intro slide.
2023-01-31 15:04:17 -05:00
Martin Geisler efa593e020 Automatically build and test all translations (#298)
This changes the build workflow to first list all available `.po`
files, and then use this information to start parallel jobs which test
each translation.
2023-01-30 13:41:19 +01:00
Martin Geisler e847c13fb7 Take out unnecessary watch dir (#303)
The directory is already mentioned in our `book.toml`.
2023-01-30 13:33:04 +01:00
Martin Geisler 690039fd53 Filter out “fuzzy” translations (#212)
When the source text is updated, existing translations become
outdated. The `msgmerge` program will attempt to find a similar source
text among the existing translations and will reuse the translation.
The translation is marked “fuzzy” to signal to the translator that it
needs to be proofread.
2023-01-28 14:36:57 +01:00
Martin Geisler ee36ae318f Add an aspect-ratio-helper mdbook preprocessor (#187)
The idea is that this will help us make better slides: we can see at a
glance when the slide becomes too full.
2023-01-27 18:30:37 +01:00
Martin Geisler 4409f330c5 Move GA code directly into main page (#289)
This replaces a bit of code with the equivalent HTML code.

We also load the script async, which means that the browser won’t
block rendering while waiting for the scripts.
2023-01-27 14:37:17 +01:00
Martin Geisler 438c16607d Add theme generated with mdbook init --theme (#189)
This will allow us to customize the appearance more easily: we can
move the GA logic into the theme (to reduce load times and to simplify
the JS injection logic). We can also add new elements, which is what I
will do next.

The mdbook theme can be added incrementally: if we don’t add a file to
our theme folder, we will get the corresponding file from mdbook.
2023-01-25 21:31:22 +01:00
Martin Geisler bad5cc9f68 Publish translations to /xx subdirectories (#264)
This publishes translations (currently only the Danish translation) to
subdirectories named after the ISO 639-1 language code: “da/” for
Danish, “ko/” for Korean, etc.

The list of translation is an explicit list to make it easy for us to
enable/disable translations without being tied to the files in po/.
This allows us to experiment with a translation without publishing it
immediately.

I propose that we eventually move the English pages to an “en/”
directory for symmetry with the other locales. However, for now, the
pages remain at the room of our site (which works fine since we don’t
have a subdirectory named “en/” in the course).
2023-01-24 12:07:04 +01:00
Martin Geisler 46f25ac891 Set the site-url to fix 404 page on GitHub Pages (#263)
This fixes the 404 page on GitHub Pages: the default is `/`, but we’re
hosting the site from a subdirectory because of how the repository is
setup.

Fixes #178.
2023-01-24 12:03:46 +01:00
Martin Geisler 1f37933b8b Extract common build steps to composite actions (#242)
* Extract common build steps to composite actions

This allows us to repeat ourselves less across the different jobs.

I also tested using a “reusable workflow” to factor out the common
steps. However, this starts a separate job without a shared
filesystem, which in turn requires us to upload/download artifacts
when we want to use them in several jobs. The artifacts are downloaded
one-by-one and this adds delays and extra steps to all jobs.

* Move Rust cache setup to its own build step

This made it easy to consistently setup the caching of our nested
projects via the “workspacs” config key.
2023-01-23 17:08:29 +01:00
Martin Geisler dbc11b2df2 Watch po/ directory for changes (#188)
This makes `mdbook serve` automatically reload the page when
translations change.
2023-01-20 11:36:14 +01:00
Martin Geisler 790e964ee6 Merge pull request #186 from rastringer/patch-1
Speaker notes for 6.5 Functions
2023-01-19 14:48:11 +01:00
Martin Geisler 20601319f2 Merge pull request #130 from google/translations
Add support for translations
2023-01-18 16:37:07 +01:00
Martin Geisler f42c76e6a8 Test that a no-op translation does nothing
This ensures that the full mdbook-xgettext and mdbook-gettext workflow
is stable and doesn’t include spurious newlines.
2023-01-18 16:12:53 +01:00
Martin Geisler c45bb19528 Test i18n-helpers on pull requests
This ensures that our i18n helpers stay working.
2023-01-18 16:12:53 +01:00
Martin Geisler afa63ad7b5 Test that translations on pull requests
This adds a simple validation step to the PRs: calling ‘msgfmt’ will
check that the ‘.po’ files are well-formed.
2023-01-18 16:12:53 +01:00
Martin Geisler 2de9c0dae8 Start a Danish translation 2023-01-18 16:12:53 +01:00
Martin Geisler 48ec773052 Add support for translations
This implements a translation pipeline using the industry-standard
Gettext[1] system.

I picked Gettext for the reasons described in [2] and [3]:

* It’s widely used in open source software. This means that there are
  graphical editors which will help you in editing the `.po` files. An
  example is Poedit[4], which is available for all major platforms.

  There are also many online systems for doing translations. An
  example is Pontoon[5], which is used for the Rust website itself. We
  can consider setting up such an instance ourselves.

* It is a light-weight yet structured format. This means that nothing
  changes with regards to how you update the original English text. We
  can still accept fixes and PRs like normal.

  The structure means that translators can see exactly which part of
  the course they need to update after a change. This is completely
  lost if you simply copy over the original text and translate it
  in-place in the Markdown files.

The code here only adds support for translations. They are not yet
tested, published or used for anything. Next steps will be:

* Add support for switching languages via a bit of JavaScript on each
  page.

* Update the speaker notes feature to support translations (right now
  “Speaker Notes” is hard-coded into the generated HTML). I think we
  should turn it into a mdbook preprocessor instead.

* Add testing: We should test that the `.po` files are well-formed. We
  should also run `mdbook test` on each language since the
  translations can alter the embedded code.

Fixes #115.

[1]: https://www.gnu.org/software/gettext/manual/html_node/index.html
[2]: https://github.com/rust-lang/mdBook/pull/1864
[3]:
https://github.com/rust-lang/mdBook/issues/5#issuecomment-1144887806
[4]: https://poedit.net/
[5]: https://pontoon.rust-lang.org/
2023-01-18 16:12:53 +01:00
Martin Geisler 8e3941d2e6 Fix close tag on keyboard shortcut page (#179) 2023-01-18 10:57:31 +00:00
Martin Geisler 0324cd2b27 Merge pull request #176 from google/testing
Fix Rustdoc comment.
2023-01-17 17:32:39 +01:00
Martin Geisler d1dc1f466a Merge pull request #167 from sahennenkamp/patch-1
Hint towards making library mut
2023-01-14 08:07:10 +01:00
Martin Geisler 61163d019c Merge pull request #168 from baltuky/rust_memory_management_typo
Fix a typo on the Memory Management in Rust page
2023-01-14 08:06:33 +01:00
Martin Geisler ddd68c5b0f Merge pull request #163 from rastringer/patch-1
Speaker notes to 6.4 Slices
2023-01-12 17:16:57 +01:00
Martin Geisler 39693b929b Merge pull request #162 from fbornhofen/speaker-notes-2
Re-add link that is still in use
2023-01-12 14:31:20 +01:00
Martin Geisler b7de49e1b8 Simplify state transitions for speaker notes
Before, we attempted to change state from “popup” to “inline-open”
when the speaker note window was closed.

We did this by listening to “pagehide” and change the state there. The
event fires every time you navigate away from the page, so we had a
complex setup where we would reset the state to “popup” when the next
page was loaded into the speaker note window.

The problem with this is that it’s racy: we could end up in a
situation where we set the state to “inline-open” right after the
speaker note window was updated. When that happened, we would mark the
window as “defunct”, meaning that it was supposed to be closed.

With this change, we no longer try to change the state from the
speaker note window. If the window is lost (closed), the user will
have to click the “Close speaker notes” button in the top-right to
reset the state. This should be much more reliable.

Long-term, a better solution would be to let the speaker notes fetch
the current URL using JavaScript instead of doing it via an actual
page navigation. That should allow us to react to “pagehide” events
again (since they won’t fire on every page transition).
2023-01-12 12:31:26 +01:00
Martin Geisler bd1c8edc3c Merge pull request #159 from fbornhofen/speaker-notes
Speaker notes: cosmetic fixes for compund-types.md, borrowing.md
2023-01-12 11:38:43 +01:00
Martin Geisler ff86e67fb1 Merge pull request #157 from ilyagr/speaker-notes
Add speaker notes about error examples
2023-01-12 07:31:29 +01:00
Martin Geisler d037d7b5c7 Merge pull request #133 from rastringer/patch-1
Adds speaker notes to Compound Types section
2023-01-11 15:51:53 +01:00
Martin Geisler 6019a946d9 Merge pull request #154 from fbornhofen/speaker-notes
Speaker notes for box.md, rc.md, option-result.md
2023-01-11 14:49:03 +01:00
Martin Geisler 1085e9c20b Add speaker notes to exercise pages
The notes link to the corresponding solutions.
2023-01-11 12:49:59 +01:00
Martin Geisler d1422e93c2 Merge pull request #149 from fbornhofen/speaker-notes-string
Add speaker notes for string.md
2023-01-10 19:55:59 +01:00
Martin Geisler 08af7574bb Add instructions about how to run the course
I think we need a chapter “before the course” which gives people some
background information about how to run the course. This is the start
of this chapter, we might expand it in the future as we find more
things to communicate here.
2023-01-10 19:12:57 +01:00
Martin Geisler 4e746482f2 Merge pull request #148 from fbornhofen/speaker-notes-if-let
Add speaker notes for if-let-expressions.md
2023-01-10 18:58:53 +01:00
Martin Geisler 1b3eaec5e7 Merge pull request #141 from brandonpollack23/static_const
Added notes, runtime constant eval, and footnoes to static-and-const.md
2023-01-10 18:53:46 +01:00
Martin Geisler 0d5232358b Remove dangling footnote 2023-01-10 18:52:37 +01:00
Martin Geisler 20c0a37949 Merge pull request #139 from brandonpollack23/rust_ecosystem
Add more info and footnotes to rust-ecosystem.md
2023-01-10 17:51:44 +01:00
Martin Geisler 637b785714 Merge pull request #138 from brandonpollack23/cargo_page
Added some more detail on rustup.
2023-01-10 17:50:56 +01:00
Martin Geisler 3eee86f76d Merge pull request #143 from fbornhofen/speaker-notes-copy-2
Rephrase copy/clone speaker notes
2023-01-10 17:47:27 +01:00
Martin Geisler c994340a8f Merge pull request #142 from fbornhofen/speaker-notes-fbornhofen
Add example for underscore syntax with generics (type-inference.md)
2023-01-10 17:46:20 +01:00
Martin Geisler 6b874844ca Merge pull request #144 from fbornhofen/speaker-notes-rvo
Add speaker notes about RVO in borrowing.md
2023-01-10 17:45:39 +01:00
Martin Geisler 9448ae3e19 Merge pull request #146 from fbornhofen/speaker-notes-variant-payloads
Add speaker notes for variant-payloads.md
2023-01-10 17:44:49 +01:00
Martin Geisler 09048753ef Merge pull request #147 from fbornhofen/speaker-notes-enum-sizes
Expand enum sizes example and add speaker notes
2023-01-10 17:44:07 +01:00
Martin Geisler a5d31d759f Merge pull request #145 from fbornhofen/speaker-notes-shared-unique-borrows
Add speaker notes for shared and unique borrows
2023-01-10 16:14:54 +01:00
Martin Geisler e29c3bfb99 Merge pull request #123 from ilyagr/username_or_error
Error handling: clarify printing of Result
2023-01-10 10:21:43 +01:00
Martin Geisler 9746af91fa Merge pull request #140 from brandonpollack23/variables
Added some speaker notes to variables.md
2023-01-10 09:31:22 +01:00
Martin Geisler e43dec24fd Tighten language 2023-01-10 09:29:57 +01:00
Martin Geisler bee9cdab92 Merge pull request #136 from fbornhofen/speaker-notes-variables
Add speaker notes for scopes-shadowing.md
2023-01-09 18:44:29 +01:00
Martin Geisler c5824aece0 Merge pull request #134 from fbornhofen/speaker-notes-fbornhofen
Speaker notes for lifetimes-function-calls.md
2023-01-09 18:43:56 +01:00
Martin Geisler c2462b4af0 Merge pull request #135 from fbornhofen/speaker-notes-fbornhofen-references
Add bullet point about mutable references
2023-01-09 17:20:28 +01:00
Martin Geisler 3ff2d5f43a Merge pull request #118 from google/exercise-code-snippets
Explain why exercises are not editable
2023-01-09 14:42:54 +01:00
Martin Geisler affb2526fe Explain why exercises are not editable
From a discussion in #23.
2023-01-09 14:41:48 +01:00
Martin Geisler bf657f5ff0 Show expanded speaker notes on print page
The `/print.html` page is concatenates all pages in the book and can
be reached from the printer icon in the top-right corner.

On this page, we will have many speaker notes. Since the page is for
people who want all information in one place, I think it makes sense
to render all these notes in their expanded form.

I wrote the logic for this as a separate little function since it has
to be different: we don’t want to add an `id` attribute to the
generated headers (since there will be more than one of them) and we
don’t want to generate links to open the notes into a separate window.
2023-01-09 14:37:07 +01:00
Martin Geisler 029aa8b139 Merge pull request #117 from google/thread-speaker-notes
Add notes to threads.md
2023-01-09 14:33:16 +01:00
Martin Geisler e835ee6cdf Add notes to threads.md
From the discussion in #63.
2023-01-09 14:32:04 +01:00
Martin Geisler 1162c554c0 Merge pull request #128 from google/speaker-notes
Add speaker notes for the first few slides
2023-01-09 14:28:50 +01:00
Martin Geisler 7e0670e6b7 Merge pull request #126 from marshallpierce/patch-2
Use rustls instead of openssl
2023-01-07 14:50:18 +01:00
Martin Geisler ca0f475fad Merge pull request #127 from imichael2e2/main
Update broken links
2023-01-07 14:49:11 +01:00
Martin Geisler e074b8c87f Merge pull request #122 from marshallpierce/patch-1
Create an empty Vec rather than pre-allocating
2023-01-06 17:51:56 +01:00
Martin Geisler 9a68434cac Merge pull request #49 from ilyagr/patch-1
`anyhow`: Remove `ReadUsernameError::IoError`
2023-01-05 15:57:17 +01:00
Martin Geisler 6e8942ef12 Merge pull request #112 from google/speaker-notes-closed
Show speaker notes as closed by default
2023-01-05 10:48:09 +01:00
Martin Geisler 59e4a912ca Merge pull request #113 from google/no-speaker-notes-on-mobile
Hide speaker note popup link on mobile
2023-01-05 10:08:15 +01:00
Martin Geisler 8feb6b4ad4 Merge pull request #109 from rhapsodyai/fixes-99
Fixes: #99
2023-01-05 09:08:03 +01:00
Martin Geisler 019e464ba8 Hide speaker note popup link on mobile
This uses the same media query as the rest of the mdbook theme:
devices with a width less than 1080px (mobiles) will not see the link
to open speaker notes in a new window.
2023-01-05 08:27:19 +01:00
Martin Geisler 986d607d1e Show speaker notes as closed by default
This makes it clearer that the notes are extra content.
2023-01-05 08:06:09 +01:00
Martin Geisler 15f88b3700 Merge pull request #107 from google/speaker-notes
Add support for speaker notes
2023-01-05 07:48:01 +01:00
Martin Geisler d5359fa92a 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.
2023-01-05 07:46:18 +01:00
Martin Geisler c2c11531a5 Merge pull request #96 from zhouwfang/simplify-solution-to-prefix-matching
Simplify the solution to prefix matching
2023-01-04 09:11:58 +01:00
Martin Geisler bffd70a90e Merge pull request #104 from liao02x/patch-1
fix typo in deriving-error-enums.md
2023-01-04 09:10:18 +01:00
Martin Geisler eee3fb6302 Merge pull request #101 from google/course-target-audience
Explain who the course is for
2023-01-03 18:10:09 +01:00
Martin Geisler 571c87283d Explain how the course can be used
From a discussion on Twitter:
https://twitter.com/bluxte/status/1610297443324727298.
2023-01-03 16:55:33 +01:00
Martin Geisler 78766a6bf6 Merge pull request #98 from google/simplify-publish
Simplify the publish workflow
2023-01-03 15:57:50 +01:00
Martin Geisler 499657c830 Simplify the publish workflow
This removes a bunch of boiler-plate comments which were left from the
template I used originally.

It also simplifies the name to just “Publish” since I feel this fits
better for what we do here.
2023-01-03 15:49:21 +01:00
Martin Geisler 9d41acf22d Merge pull request #97 from google/cargo-test
Run `cargo test` on pull requests
2023-01-03 15:47:48 +01:00
Martin Geisler a0a1398b9b Simplify workflow name
Now that we multiple jobs, this will look better in the GitHut output:
“Build / mdbook (pull_request)” and “Test / mdbook (pull_request)”.
2023-01-03 14:46:25 +01:00