Skip to content

Commit c21be2b

Browse files
committed
Auto merge of #13168 - leonzchang:handlebars-v4, r=epage
chore(deps): update rust crate handlebars to `v4.5.0` In the latest version of `handlebars`, rules for whitespace auto elimination is to check if the directive `{{# xxx}}`` and ``{{/ xxx}}` is holding a whole line, with leading and trailing whitespaces counted, and then remove the trailing NEWLINE (See [`template.rs`](https://github.com/sunng87/handlebars-rust/blob/9d7d5556287e31e4148841a56e0981b64a679fb6/src/template.rs#L568-L889)). ```md {{#options}} <--- this newline will be removed after a standalone block {{#option "`-o` _outdir_"}} <--- this newline will be removed Some content {{/option}} <--- this newline will be removed {{/options}} <--- this newline will be removed ``` This PR changes includes (fixes #13162): 1. update `handlebars` crate to `v4.5.0`. 2. add extra NEWLINE to helper blocks `options`, `option` to align with the new strip rules, preserving the original behavior. 3. update doc(the rest handlebars expression) to align with the new strip rules..
2 parents 9a77459 + b96b244 commit c21be2b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+68
-441
lines changed

Cargo.lock

+56-63
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ git2-curl = "0.19.0"
4848
gix = { version = "0.56.0", default-features = false, features = ["blocking-http-transport-curl", "progress-tree", "revision"] }
4949
gix-features-for-configuration-only = { version = "0.35.0", package = "gix-features", features = [ "parallel" ] }
5050
glob = "0.3.1"
51-
handlebars = { version = "3.5.5", features = ["dir_source"] }
51+
handlebars = { version = "4.5.0", features = ["dir_source"] }
5252
hex = "0.4.3"
5353
hmac = "0.12.1"
5454
home = "0.5.5"

crates/mdman/doc/out/mdman.md

-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ man page:
4949
- Other helpers include:
5050
- `{{lower value}}` Converts the given value to lowercase.
5151

52-
5352
## OPTIONS
5453

5554
<dl>

crates/mdman/src/format/md.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@ impl super::Formatter for MdFormatter {
3030
}
3131

3232
fn render_options_start(&self) -> &'static str {
33-
"<dl>"
33+
"<dl>\n"
3434
}
3535

3636
fn render_options_end(&self) -> &'static str {
37-
"</dl>"
37+
"</dl>\n"
3838
}
3939

4040
fn render_option(&self, params: &[&str], block: &str, man_name: &str) -> Result<String, Error> {
@@ -67,7 +67,7 @@ impl super::Formatter for MdFormatter {
6767
let rendered_block = self.render_html(block)?;
6868
write!(
6969
result,
70-
"<dd class=\"option-desc\">{}</dd>\n",
70+
"<dd class=\"option-desc\">{}</dd>\n\n",
7171
unwrap_p(&rendered_block)
7272
)?;
7373
Ok(result)

crates/mdman/src/format/text.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@ impl super::Formatter for TextFormatter {
2626
fn render_options_start(&self) -> &'static str {
2727
// Tell pulldown_cmark to ignore this.
2828
// This will be stripped out later.
29-
"<![CDATA["
29+
"<![CDATA[\n"
3030
}
3131

3232
fn render_options_end(&self) -> &'static str {
33-
"]]>"
33+
"]]>\n"
3434
}
3535

3636
fn render_option(
@@ -46,7 +46,7 @@ impl super::Formatter for TextFormatter {
4646
let trimmed: Vec<_> = rendered_options.iter().map(|o| o.trim()).collect();
4747
// Wrap in HTML tags, they will be stripped out during rendering.
4848
Ok(format!(
49-
"<dt>{}</dt>\n<dd>{}</dd>\n<br>\n",
49+
"<dt>{}</dt>\n<dd>\n{}</dd>\n<br>\n",
5050
trimmed.join(", "),
5151
block
5252
))

crates/mdman/tests/compare/links.md

+1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ Shortcut unknown: [shortcut unknown]
3232

3333
{{> links-include}}
3434

35+
3536
## OPTIONS
3637

3738
{{#options}}

crates/mdman/tests/compare/options.md

+1
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ A named argument.
4646

4747
{{> options-common}}
4848

49+
4950
## EXAMPLES
5051

5152
1. An example

crates/mdman/tests/compare/vars.md

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
{{*set foo="Bar"}}
44

5+
56
{{foo}}
67

78
{{lower foo}}

src/doc/man/cargo-rustc.md

+1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ See <https://doc.rust-lang.org/rustc/index.html> for documentation on rustc
2424
flags.
2525

2626
{{> description-one-target }}
27+
2728
To pass flags to all compiler processes spawned by Cargo, use the `RUSTFLAGS`
2829
[environment variable](../reference/environment-variables.html) or the
2930
`build.rustflags` [config value](../reference/config.html).

src/doc/man/cargo-rustdoc.md

+1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ See <https://doc.rust-lang.org/rustdoc/index.html> for documentation on rustdoc
2424
flags.
2525

2626
{{> description-one-target }}
27+
2728
To pass flags to all rustdoc processes spawned by Cargo, use the
2829
`RUSTDOCFLAGS` [environment variable](../reference/environment-variables.html)
2930
or the `build.rustdocflags` [config value](../reference/config.html).

src/doc/src/commands/cargo-add.md

-8
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
# cargo-add(1)
2-
32
## NAME
43

54
cargo-add --- Add dependencies to a Cargo.toml manifest file
@@ -67,7 +66,6 @@ which is defined by the <code>registry.default</code> config key which defaults
6766
<code>crates-io</code>.</dd>
6867

6968

70-
7169
</dl>
7270

7371
### Section options
@@ -166,7 +164,6 @@ terminal.</li>
166164
<p>May also be specified with the <code>term.color</code>
167165
<a href="../reference/config.html">config value</a>.</dd>
168166

169-
170167
</dl>
171168

172169
### Manifest Options
@@ -177,7 +174,6 @@ terminal.</li>
177174
<code>Cargo.toml</code> file in the current directory or any parent directory.</dd>
178175

179176

180-
181177
<dt class="option-term" id="option-cargo-add--p"><a class="option-anchor" href="#option-cargo-add--p"></a><code>-p</code> <em>spec</em></dt>
182178
<dt class="option-term" id="option-cargo-add---package"><a class="option-anchor" href="#option-cargo-add---package"></a><code>--package</code> <em>spec</em></dt>
183179
<dd class="option-desc">Add dependencies to only the specified package.</dd>
@@ -206,7 +202,6 @@ See the <a href="cargo-fetch.html">cargo-fetch(1)</a> command to download depend
206202
offline.</p>
207203
<p>May also be specified with the <code>net.offline</code> <a href="../reference/config.html">config value</a>.</dd>
208204

209-
210205
</dl>
211206

212207
### Common Options
@@ -249,19 +244,16 @@ requires the <code>-Z unstable-options</code> flag to enable (see
249244

250245
</dl>
251246

252-
253247
## ENVIRONMENT
254248

255249
See [the reference](../reference/environment-variables.html) for
256250
details on environment variables that Cargo reads.
257251

258-
259252
## EXIT STATUS
260253

261254
* `0`: Cargo succeeded.
262255
* `101`: Cargo failed to complete.
263256

264-
265257
## EXAMPLES
266258

267259
1. Add `regex` as a dependency

src/doc/src/commands/cargo-bench.md

-22
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
# cargo-bench(1)
2-
32
## NAME
43

54
cargo-bench --- Execute benchmarks of a package
@@ -80,7 +79,6 @@ as a whole.</dd>
8079

8180
</dl>
8281

83-
8482
### Package Selection
8583

8684
By default, when no package selection options are given, the packages selected
@@ -109,12 +107,10 @@ double quotes around each pattern.</dd>
109107
<dd class="option-desc">Benchmark all members in the workspace.</dd>
110108

111109

112-
113110
<dt class="option-term" id="option-cargo-bench---all"><a class="option-anchor" href="#option-cargo-bench---all"></a><code>--all</code></dt>
114111
<dd class="option-desc">Deprecated alias for <code>--workspace</code>.</dd>
115112

116113

117-
118114
<dt class="option-term" id="option-cargo-bench---exclude"><a class="option-anchor" href="#option-cargo-bench---exclude"></a><code>--exclude</code> <em>SPEC</em>…</dt>
119115
<dd class="option-desc">Exclude the specified packages. Must be used in conjunction with the
120116
<code>--workspace</code> flag. This flag may be specified multiple times and supports
@@ -125,7 +121,6 @@ single quotes or double quotes around each pattern.</dd>
125121

126122
</dl>
127123

128-
129124
### Target Selection
130125

131126
When no target selection options are given, `cargo bench` will build the
@@ -160,7 +155,6 @@ is set when the integration test is built so that it can use the
160155
[`env` macro](https://doc.rust-lang.org/std/macro.env.html) to locate the
161156
executable.
162157

163-
164158
Passing target selection flags will benchmark only the specified
165159
targets.
166160

@@ -184,7 +178,6 @@ and supports common Unix glob patterns.</dd>
184178
<dd class="option-desc">Benchmark all binary targets.</dd>
185179

186180

187-
188181
<dt class="option-term" id="option-cargo-bench---example"><a class="option-anchor" href="#option-cargo-bench---example"></a><code>--example</code> <em>name</em>…</dt>
189182
<dd class="option-desc">Benchmark the specified example. This flag may be specified multiple times
190183
and supports common Unix glob patterns.</dd>
@@ -230,7 +223,6 @@ manifest settings for the target.</dd>
230223

231224
</dl>
232225

233-
234226
### Feature Selection
235227

236228
The feature flags allow you to control which features are enabled. When no
@@ -259,7 +251,6 @@ be specified multiple times, which enables all specified features.</dd>
259251

260252
</dl>
261253

262-
263254
### Compilation Options
264255

265256
<dl>
@@ -275,19 +266,16 @@ target artifacts are placed in a separate directory. See the
275266
<a href="../guide/build-cache.html">build cache</a> documentation for more details.</dd>
276267

277268

278-
279269
<dt class="option-term" id="option-cargo-bench---profile"><a class="option-anchor" href="#option-cargo-bench---profile"></a><code>--profile</code> <em>name</em></dt>
280270
<dd class="option-desc">Benchmark with the given profile.
281271
See <a href="../reference/profiles.html">the reference</a> for more details on profiles.</dd>
282272

283273

284-
285274
<dt class="option-term" id="option-cargo-bench---ignore-rust-version"><a class="option-anchor" href="#option-cargo-bench---ignore-rust-version"></a><code>--ignore-rust-version</code></dt>
286275
<dd class="option-desc">Benchmark the target even if the selected Rust compiler is older than the
287276
required Rust version as configured in the project’s <code>rust-version</code> field.</dd>
288277

289278

290-
291279
<dt class="option-term" id="option-cargo-bench---timings=fmts"><a class="option-anchor" href="#option-cargo-bench---timings=fmts"></a><code>--timings=</code><em>fmts</em></dt>
292280
<dd class="option-desc">Output information how long each compilation takes, and track concurrency
293281
information over time. Accepts an optional comma-separated list of output
@@ -306,7 +294,6 @@ information about timing information.</li>
306294

307295

308296

309-
310297
</dl>
311298

312299
### Output Options
@@ -318,7 +305,6 @@ specified with the <code>CARGO_TARGET_DIR</code> environment variable, or the
318305
<code>build.target-dir</code> <a href="../reference/config.html">config value</a>.
319306
Defaults to <code>target</code> in the root of the workspace.</dd>
320307

321-
322308
</dl>
323309

324310
### Display Options
@@ -358,7 +344,6 @@ terminal.</li>
358344
<a href="../reference/config.html">config value</a>.</dd>
359345

360346

361-
362347
<dt class="option-term" id="option-cargo-bench---message-format"><a class="option-anchor" href="#option-cargo-bench---message-format"></a><code>--message-format</code> <em>fmt</em></dt>
363348
<dd class="option-desc">The output format for diagnostic messages. Can be specified multiple times
364349
and consists of comma-separated values. Valid values:</p>
@@ -382,7 +367,6 @@ coming from rustc are still emitted. Cannot be used with <code>human</code> or <
382367
</ul></dd>
383368

384369

385-
386370
</dl>
387371

388372
### Manifest Options
@@ -393,7 +377,6 @@ coming from rustc are still emitted. Cannot be used with <code>human</code> or <
393377
<code>Cargo.toml</code> file in the current directory or any parent directory.</dd>
394378

395379

396-
397380
<dt class="option-term" id="option-cargo-bench---frozen"><a class="option-anchor" href="#option-cargo-bench---frozen"></a><code>--frozen</code></dt>
398381
<dt class="option-term" id="option-cargo-bench---locked"><a class="option-anchor" href="#option-cargo-bench---locked"></a><code>--locked</code></dt>
399382
<dd class="option-desc">Either of these flags requires that the <code>Cargo.lock</code> file is
@@ -417,7 +400,6 @@ See the <a href="cargo-fetch.html">cargo-fetch(1)</a> command to download depend
417400
offline.</p>
418401
<p>May also be specified with the <code>net.offline</code> <a href="../reference/config.html">config value</a>.</dd>
419402

420-
421403
</dl>
422404

423405
### Common Options
@@ -460,7 +442,6 @@ requires the <code>-Z unstable-options</code> flag to enable (see
460442

461443
</dl>
462444

463-
464445
### Miscellaneous Options
465446

466447
The `--jobs` argument affects the building of the benchmark executable but
@@ -477,7 +458,6 @@ parallel jobs to the number of logical CPUs plus provided value. If
477458
a string <code>default</code> is provided, it sets the value back to defaults.
478459
Should not be 0.</dd>
479460

480-
481461
</dl>
482462

483463
While `cargo bench` involves compilation, it does not provide a `--keep-going`
@@ -493,13 +473,11 @@ stopping at the first failure. To "compile" as many benchmarks as possible, use
493473
See [the reference](../reference/environment-variables.html) for
494474
details on environment variables that Cargo reads.
495475

496-
497476
## EXIT STATUS
498477

499478
* `0`: Cargo succeeded.
500479
* `101`: Cargo failed to complete.
501480

502-
503481
## EXAMPLES
504482

505483
1. Build and execute all the benchmarks of the current package:

0 commit comments

Comments
 (0)