1
0
mirror of https://github.com/google/comprehensive-rust.git synced 2025-06-27 03:01:03 +02:00
Commit Graph

10 Commits

Author SHA1 Message Date
63d716de90 Preserve line numbers by not injecting a newline (#2653)
The `dbg!` macro, being deployed more widely in #2478, shows the line
number. But if we inject `#![allow(..)]\n` then the printed numbers do
not match those in the textarea. It turns out that `\n` is not required!

cc @egithinji
2025-02-21 15:32:31 -05:00
44a79741ff Be more consistent about tests vs. main (#2644)
The content slides all use `fn main`, with the exception of the testing
segment. But with this change, where it makes sense exercises use tests
instead, and not both tests and `fn main`.

A small change in `book.js` supports running tests when a code sample
does not have `fn main` but does have `#[test]`, so these work
naturally.

Fixes #1581.
2025-02-18 20:13:16 +00:00
af6dff53c2 update to mdbook-0.4.44 and sync book.js and index.hbs (#2610)
mdbook in CI pipeline is updated to mdbook-0.4.44
  - reran mdbook init --theme
  - keep playground improvements
- keep language selector and suggest edit / edit to translation button
text
  - improvement: toc is in separate js file, makes html file way smaller
  - additionally updated to mdbook-i18n-helpers-0.3.5

relevant upstream changes that are used:
- https://github.com/rust-lang/mdBook/pull/2414
- https://github.com/rust-lang/mdBook/pull/2421
- https://github.com/rust-lang/mdBook/pull/2454
- https://github.com/rust-lang/mdBook/pull/2463
2025-02-07 10:07:41 +01:00
5f7e0c3f64 Allow the 'unused' category of lints (#2571)
These sort of warnings can be distracting when commenting out a few
lines of code or demonstrating some other concept. They can be
re-enabled for a code block with `warnunused`.

I filed https://github.com/rust-lang/mdBook/issues/2527 to get behavior
like this upstream.
2025-01-20 12:47:50 -05:00
999490fae4 book.js: early return if response error (#2520)
It used to have a ugly error message shows that "Playground
Communication: Cannot read properties of undefined (reading 'trim')",
which is due to the fact that the response lacks stdout attr.

Issue: #2477

Signed-off-by: Alx-Lai <alexabc722@gmail.com>
2024-12-16 09:42:52 -05:00
5f2248bb92 Add "Execution: Add stderr block" again (#2503)
Reverts google/comprehensive-rust#2479, which is a revert of #2397.

I think the problem was not related to @Alx-Lai's change, the
[Playground was
slow](https://rust-lang.zulipchat.com/#narrow/channel/242791-t-infra/topic/playground.20incident.202024-12-03)
for everyone.
2024-12-06 14:21:44 +01:00
7d2bde6163 Revert "Execution: Add stderr block" (#2479)
Reverts google/comprehensive-rust#2397

I'm seeing

```
POST https://play.rust-lang.org/execute 500 (Internal Server Error)
```

on every request when trying to run code in the Playground. I'm not sure
why, but we need to revert this ASAP if others see the same.
2024-11-28 16:40:12 +01:00
beacea74ea Execution: Add stderr block (#2397)
Add a stderr block.
Pros:
  - we can make use of dbg macro in our code Cons:
  - there's a limitation that the compile message also shows

Applies patches from rust-lang/mdBook#1315 since the original change was
not merged by rust-lang.

Issue: #531

Signed-off-by: Alx-Lai <alexabc722@gmail.com>
2024-11-28 15:01:08 +01:00
e2c59ddbb5 Test translations using same source as for publish (#1492)
Before we would run `mdbook test` using the current Markdown sources.
This is subtly wrong: we publish the course using back-dated sources,
so we should therefore also run the tests using the same sources (this
ensures that the code snippets actually work).

After this commit, all translatable content lives in exactly two
directories:

- `src/`
- `third_party/`

We need to restore both directories when testing and when publishing.
This ensures consistency in the Markdown text and in the included
source code.

A new `.github/workflows/build.sh` script takes care of preparing the
two directories according to the date in the PO file (if any).

To ensure we can restore all of `third_party/` to an old commit, the
non-changing `third_party/mdbook/book.js` file has been moved to
`theme/book.js`. The file is generated by `mdbook init --theme`,
making it suitable for modification by the user (us). Symlinks have
been added to `third_party/mdbook/` to indicate that the files
ultimately came from upstream.
2024-01-04 17:04:44 +01:00
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