Commit Graph

5807 Commits

Author SHA1 Message Date
Chris Krycho
d8f0f5b450 Ch. 15.5: account for improved error message
Previously, the error message from the compiler only suggested changing
the `impl` to use `&mut self`, but a (very helpful!) update to the error
message suggests changing both the `impl` and the `trait` definitions,
which is much better in the general case since changing one without the
other will just produce a new error message: a point the original text
points to with its suggestion to try and see what happens.

Account for the new error message by keeping the framing of the reason
as avoiding breaking the trait contract, but now explicitly in terms of
good testing habits.

Fixes #4140
2024-12-06 16:46:35 -07:00
Chris Krycho
139538d7da Merge pull request #4138 from rust-lang/code-style-updates-Here
Document use of rustfmt and dprint for formatting
2024-12-05 14:03:11 -07:00
Chris Krycho
18ef30b087 Document use of rustfmt and dprint for formatting 2024-12-05 13:58:40 -07:00
Chris Krycho
cdfa587656 Merge pull request #4137 from rust-lang/fix-nostarch-mdbook-trpl
tools: fix nostarch build reference to mdbook-trpl
2024-12-05 13:01:41 -07:00
Chris Krycho
ec5b76b8b0 tools: fix nostarch build reference to mdbook-trpl
Note that this is not urgent to land upstream because the script in
question is one only we run.
2024-12-05 12:27:12 -07:00
Chris Krycho
2f3bdf28e7 Merge pull request #4136 from dane/ch04-reword-it
Revise sentence to not refer to two subjects as it
2024-12-05 12:19:24 -07:00
Chris Krycho
9900d976bb Merge pull request #4135 from rust-lang/mdbook-fixes
infra: improve mdbook preprocessing infrastructure
2024-12-05 10:23:00 -07:00
Chris Krycho
7435e9f487 infra: use new version of pulldown-cmark-to-cmark
This fixes escaping of `|` in a table. Bonus trivia: comment formatting
in the Cargo.toml for `mdbook_trpl`.
2024-12-05 09:37:01 -07:00
Chris Krycho
a523b611e9 infra: fix output for simple mode preprocessors
Stop using the `pulldown-cmark` parser to rewrite the listings. Instead,
find the tags and parse them with the DOM parser, and then rewrite the
lines of the string directly.
2024-12-05 09:37:01 -07:00
Chris Krycho
1882cfbb12 infra: remove extra leading > in simple preprocessor output
Preprocessors using `pulldown-cmark-to-cmark` do not yet perform round
trips 100% correctly, and insert leading spaces and an extra initial `>`
for block quotes, so strip those. Once that is fixed upstream, this will
become a no-op, and can be removed then.
2024-12-05 09:37:01 -07:00
Chris Krycho
2e8392d297 infra: update dependencies for mdbook preprocessors
This (in principle) lets us get better support for round-tripping and
therefore less hoop-jumping to get the desired Markdown output after
preprocessing some text. This intentionally keeps the rendering the same
as it was on previous versions.
2024-12-05 09:37:01 -07:00
Chris Krycho
7dafbb6507 infra: decouple preprocessors from current mdbook version
Instead of using `mdbook:new_cmark_parser`, provide our own utility
function which does the same thing. This allows us to preprocess the
text using versions of `pulldown-cmark` and `pulldown-cmark-to-cmark`
different from those used by `mdbook` itself so long as we take care
that the configuration continues to match.
2024-12-05 09:37:01 -07:00
Chris Krycho
902612b6d2 infra: create mdbook-trpl-figure preprocessor
Building on the shared infra from `mdbook_trpl`, this preprocessor takes
nicely accessible and semantic HTML input like this:

    <figure>
    
    <img src="https://www.example.com/something.jpg">
    
    <figcaption>Figure 12-34: An illustration of something</figcaption>
    
    </figure>
    
It produces output like this:

    <img src="https://www.example.com/something.jpg">
    
    Figure 12-34: An illustration of something

This matches what we need for the nostarch output. Accordingly, wire up
the `nostarch/book.toml` to use this. There is no need to worry about
ordering of the two preprocessors, because in `Simple` mode the listing
preprocessor emits plain text output for listings (much as this does for
figures).
2024-12-05 09:37:01 -07:00
Chris Krycho
901627b9b4 infra: use anyhow for error reporting
mdbook already does this, and anyhow has nice error reporting.
2024-12-05 09:37:01 -07:00
Chris Krycho
9e2673a008 infra: share infrastructure for mdbook preprocessors
- Create an `mdbook_trpl` library package which hosts shared concerns
  for the packages, e.g. error and config handling.
- Move `mdbook-trpl-note` and `mdbook-trpl-listing` into the new shared
  package, with binaries at `src/bin/(note|listing)/main.rs` and the
  existing libraries at `src/note/mod.rs` and `src/listing/mod.rs` with
  their associated tests.
- Extract their actual shared pieces into the crate root.
- Update `tools/nostarch.sh` to build all the bins in `mdbook_trpl` at
  one time.

At the moment, this doesn't do a lot except trim down the number of
packages in the repository, but it sets things up nicely to support more
preprocessors (which I am going to add shortly).
2024-12-05 09:37:01 -07:00
Dane Harrigan
d65bd3cc31 Revise annotations to not refer to subjects as it 2024-12-05 10:44:47 -05:00
Dane Harrigan
bf43b7a516 Revise sentence to not refer to two subjects as it 2024-12-05 10:44:47 -05:00
Chris Krycho
397d181acc Merge pull request #4134 from rust-lang/chris-krycho-added
Add Chris Krycho (me!) to the nostarch book.toml authors
2024-12-04 17:11:03 -07:00
Chris Krycho
8ab103d510 Add Chris Krycho (me!) to the nostarch book.toml authors 2024-12-04 17:06:57 -07:00
Chris Krycho
a7d9b28521 Merge pull request #4133 from rust-lang/dprint-config
infra: `dprint fmt` dprint config itself
2024-12-04 17:04:34 -07:00
Chris Krycho
63a31763d9 Merge pull request #4132 from rust-lang/ignore-internal-links
Ch. 17: ignore internal links
2024-12-04 17:04:28 -07:00
Chris Krycho
69f7761152 infra: dprint fmt dprint config itself 2024-12-04 17:01:07 -07:00
Chris Krycho
303918057a Ch. 17: ignore internal links 2024-12-04 16:58:33 -07:00
Chris Krycho
d8068458f6 Merge pull request #4130 from Dahuage/main
fix: fix a garden-path expression that can be confusing.
2024-12-04 12:19:04 -07:00
Chris Krycho
b6ef8eb6b5 Update src/ch21-01-single-threaded.md 2024-12-04 12:09:09 -07:00
Dahuage
d10bac898c fix: fix a garden-path expression that can be confusing.
Fix a garden-path expression that can be confusing for those who are familiar with referring to packages using dots, especially when English is a second language for the reader.
2024-12-04 10:44:16 +08:00
Chris Krycho
5860a322b9 Merge pull request #4129 from rust-lang/compatibility-improvement
Ch. 18: use “dyn compatibility” instead of “object safety”
2024-12-03 15:52:52 -07:00
Chris Krycho
1611a39557 Ch. 18: use “dyn compatibility” instead of “object safety”
- Introduce the concept at the end of 18.2 when discussing the tradeoffs
  of dynamic dispatch, with a link to the reference. The link is not
  currently valid, because of the versioning timeline, but it will be
  when this stabilizes!
- In 18.3, simply replace “object safe” with “dyn compatible”. There is
  still probably not enough discussion of it, but with the introduction
  and link in 18.2, it is *probably* enough for now?
2024-12-03 15:49:22 -07:00
Chris Krycho
d83137d9ac Merge pull request #4125 from rust-lang/dprint
infra: introduce dprint for easier formatting
2024-12-03 10:00:54 -07:00
Chris Krycho
1366453611 Merge pull request #4124 from danmou/patch-1
Correct chapter numbers in introduction
2024-12-03 07:34:20 -07:00
Chris Krycho
838b6610e0 Merge pull request #4127 from rust-lang/commit-summary-ignore-vscode-zed
infra: ignore VS Code and Zed settings
2024-12-03 07:33:46 -07:00
Chris Krycho
951cbf6f2a infra: ignore VS Code and Zed settings 2024-12-03 07:05:57 -07:00
Chris Krycho
587b3e40b4 infra: add .git-blame-ignore-revs file w/the formatting commit 2024-12-02 16:15:45 -07:00
Chris Krycho
3a30e4c1fb Apply dprint fmt to active files in the repo 2024-12-02 16:09:20 -07:00
Chris Krycho
105d3fb514 infra: introduce dprint for easier formatting
No more need to manually wrap lines? GREAT.
2024-12-02 16:09:20 -07:00
Chris Krycho
b1be1fe87d Ch. 18: unwrap a link split across two lines
This appears to still work with pulldown-cmark, but not necessarily in
all renderers, and (more to the point at present) is not compatible with
dprint, which does not like the line wrapping that way!
2024-12-02 15:25:30 -07:00
Daniel Mouritzen
0dfa24c1fe Correct chapter numbers in introduction 2024-12-02 23:10:11 +01:00
Chris Krycho
5d395b70da Merge pull request #3745 from SergioRibera/main
Adding reference to an actively maintained Spanish translation
2024-12-02 10:20:04 -07:00
Chris Krycho
54eb0a93a5 Merge pull request #4123 from rust-lang/tweak-phrase-commit-log
Ch. 2: tweak a phrase to avoid derailing some readers
2024-12-02 10:19:41 -07:00
Chris Krycho
f347bb5e0e Ch. 2: tweak a phrase to avoid derailing some readers
Multiple people have filed or commented on issues over the past few
years (at least #3782, #4101, #4090, and #3921; and possibly others I
have not found) because seeing “compare” here led them to jump ahead to
the conversion (in the next paragraph). The text was technically correct
as it stood, but since it kept derailing/hijacking people’s train of
thought, tweaking it seems helpful.
2024-12-02 10:16:07 -07:00
Chris Krycho
614c19cb40 Merge pull request #4122 from rust-lang/fix-inverted-shadowing
Fix more inverted uses of “shadowed”
2024-12-02 09:22:15 -07:00
Chris Krycho
b2e71e8818 Fix more inverted uses of “shadowed”
Follow-on for #3773 and #4121: I missed how the rest of this paragraph
also had “shadowed” inverted!
2024-12-02 09:16:41 -07:00
Chris Krycho
810d8ede33 Merge pull request #4121 from rust-lang/error-fixes-shadowing
Fix a couple inverted uses of “shadowed”
2024-12-02 08:55:44 -07:00
Chris Krycho
e945e17d91 Fix a couple inverted uses of “shadowed”
Fixes #3773.
2024-12-02 08:51:19 -07:00
Chris Krycho
61d741742c Merge branch 'main' into main 2024-12-02 07:35:06 -07:00
Chris Krycho
e16fc30f5c Merge pull request #4118 from rust-lang/push-tskzrxpsrmox
Fix confusion between variable `hello` and string `"hello"`
2024-11-27 14:23:48 -07:00
Chris Krycho
daf8d828cc Fix confusion between variable hello and string "hello"
Fixes #3803
2024-11-27 14:19:33 -07:00
Chris Krycho
ef5b909a2c Merge pull request #4117 from rust-lang/push-mnoxkxzvzqpv
Ch. 17: fix some wording issues
2024-11-27 12:34:38 -07:00
Chris Krycho
294b80dda8 Ch. 17: fix some wording issues 2024-11-27 10:53:03 -07:00
Chris Krycho
fb46a07bf3 Merge pull request #3809 from octavioooooo/patch-1
Rephrase for clarity
2024-11-27 09:15:05 -07:00