Skip to content

Commit

Permalink
Auto merge of #13168 - leonzchang:handlebars-v4, r=epage
Browse files Browse the repository at this point in the history
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..
  • Loading branch information
bors committed Dec 20, 2023
2 parents 9a77459 + b96b244 commit c21be2b
Show file tree
Hide file tree
Showing 42 changed files with 68 additions and 441 deletions.
119 changes: 56 additions & 63 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ git2-curl = "0.19.0"
gix = { version = "0.56.0", default-features = false, features = ["blocking-http-transport-curl", "progress-tree", "revision"] }
gix-features-for-configuration-only = { version = "0.35.0", package = "gix-features", features = [ "parallel" ] }
glob = "0.3.1"
handlebars = { version = "3.5.5", features = ["dir_source"] }
handlebars = { version = "4.5.0", features = ["dir_source"] }
hex = "0.4.3"
hmac = "0.12.1"
home = "0.5.5"
Expand Down
1 change: 0 additions & 1 deletion crates/mdman/doc/out/mdman.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ man page:
- Other helpers include:
- `{{lower value}}` Converts the given value to lowercase.


## OPTIONS

<dl>
Expand Down
6 changes: 3 additions & 3 deletions crates/mdman/src/format/md.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ impl super::Formatter for MdFormatter {
}

fn render_options_start(&self) -> &'static str {
"<dl>"
"<dl>\n"
}

fn render_options_end(&self) -> &'static str {
"</dl>"
"</dl>\n"
}

fn render_option(&self, params: &[&str], block: &str, man_name: &str) -> Result<String, Error> {
Expand Down Expand Up @@ -67,7 +67,7 @@ impl super::Formatter for MdFormatter {
let rendered_block = self.render_html(block)?;
write!(
result,
"<dd class=\"option-desc\">{}</dd>\n",
"<dd class=\"option-desc\">{}</dd>\n\n",
unwrap_p(&rendered_block)
)?;
Ok(result)
Expand Down
6 changes: 3 additions & 3 deletions crates/mdman/src/format/text.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ impl super::Formatter for TextFormatter {
fn render_options_start(&self) -> &'static str {
// Tell pulldown_cmark to ignore this.
// This will be stripped out later.
"<![CDATA["
"<![CDATA[\n"
}

fn render_options_end(&self) -> &'static str {
"]]>"
"]]>\n"
}

fn render_option(
Expand All @@ -46,7 +46,7 @@ impl super::Formatter for TextFormatter {
let trimmed: Vec<_> = rendered_options.iter().map(|o| o.trim()).collect();
// Wrap in HTML tags, they will be stripped out during rendering.
Ok(format!(
"<dt>{}</dt>\n<dd>{}</dd>\n<br>\n",
"<dt>{}</dt>\n<dd>\n{}</dd>\n<br>\n",
trimmed.join(", "),
block
))
Expand Down
1 change: 1 addition & 0 deletions crates/mdman/tests/compare/links.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ Shortcut unknown: [shortcut unknown]

{{> links-include}}


## OPTIONS

{{#options}}
Expand Down
1 change: 1 addition & 0 deletions crates/mdman/tests/compare/options.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ A named argument.

{{> options-common}}


## EXAMPLES

1. An example
Expand Down
1 change: 1 addition & 0 deletions crates/mdman/tests/compare/vars.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

{{*set foo="Bar"}}


{{foo}}

{{lower foo}}
1 change: 1 addition & 0 deletions src/doc/man/cargo-rustc.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ See <https://doc.rust-lang.org/rustc/index.html> for documentation on rustc
flags.

{{> description-one-target }}

To pass flags to all compiler processes spawned by Cargo, use the `RUSTFLAGS`
[environment variable](../reference/environment-variables.html) or the
`build.rustflags` [config value](../reference/config.html).
Expand Down
1 change: 1 addition & 0 deletions src/doc/man/cargo-rustdoc.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ See <https://doc.rust-lang.org/rustdoc/index.html> for documentation on rustdoc
flags.

{{> description-one-target }}

To pass flags to all rustdoc processes spawned by Cargo, use the
`RUSTDOCFLAGS` [environment variable](../reference/environment-variables.html)
or the `build.rustdocflags` [config value](../reference/config.html).
Expand Down
8 changes: 0 additions & 8 deletions src/doc/src/commands/cargo-add.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# cargo-add(1)

## NAME

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



</dl>

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


</dl>

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



<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>
<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>
<dd class="option-desc">Add dependencies to only the specified package.</dd>
Expand Down Expand Up @@ -206,7 +202,6 @@ See the <a href="cargo-fetch.html">cargo-fetch(1)</a> command to download depend
offline.</p>
<p>May also be specified with the <code>net.offline</code> <a href="../reference/config.html">config value</a>.</dd>


</dl>

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

</dl>


## ENVIRONMENT

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


## EXIT STATUS

* `0`: Cargo succeeded.
* `101`: Cargo failed to complete.


## EXAMPLES

1. Add `regex` as a dependency
Expand Down
22 changes: 0 additions & 22 deletions src/doc/src/commands/cargo-bench.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# cargo-bench(1)

## NAME

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

</dl>


### Package Selection

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



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



<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>
<dd class="option-desc">Exclude the specified packages. Must be used in conjunction with the
<code>--workspace</code> flag. This flag may be specified multiple times and supports
Expand All @@ -125,7 +121,6 @@ single quotes or double quotes around each pattern.</dd>

</dl>


### Target Selection

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


Passing target selection flags will benchmark only the specified
targets.

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



<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>
<dd class="option-desc">Benchmark the specified example. This flag may be specified multiple times
and supports common Unix glob patterns.</dd>
Expand Down Expand Up @@ -230,7 +223,6 @@ manifest settings for the target.</dd>

</dl>


### Feature Selection

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

</dl>


### Compilation Options

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



<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>
<dd class="option-desc">Benchmark with the given profile.
See <a href="../reference/profiles.html">the reference</a> for more details on profiles.</dd>



<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>
<dd class="option-desc">Benchmark the target even if the selected Rust compiler is older than the
required Rust version as configured in the project’s <code>rust-version</code> field.</dd>



<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>
<dd class="option-desc">Output information how long each compilation takes, and track concurrency
information over time. Accepts an optional comma-separated list of output
Expand All @@ -306,7 +294,6 @@ information about timing information.</li>




</dl>

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


</dl>

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



<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>
<dd class="option-desc">The output format for diagnostic messages. Can be specified multiple times
and consists of comma-separated values. Valid values:</p>
Expand All @@ -382,7 +367,6 @@ coming from rustc are still emitted. Cannot be used with <code>human</code> or <
</ul></dd>



</dl>

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



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


</dl>

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

</dl>


### Miscellaneous Options

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


</dl>

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


## EXIT STATUS

* `0`: Cargo succeeded.
* `101`: Cargo failed to complete.


## EXAMPLES

1. Build and execute all the benchmarks of the current package:
Expand Down
Loading

0 comments on commit c21be2b

Please sign in to comment.