Skip to content

Commit

Permalink
Update documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
fmtbot committed Mar 30, 2024
1 parent 046db55 commit 26c6387
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 39 deletions.
19 changes: 10 additions & 9 deletions dev/_sources/syntax.rst.txt
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,7 @@ Range Format Specifications
Format specifications for range types have the following syntax:

.. productionlist:: sf
range_format_spec: [":" ["n"][`range_type`][`range_underlying_spec`]]
range_format_spec: ["n"][`range_type`][`range_underlying_spec`]

The ``'n'`` option formats the range without the opening and closing brackets.

Expand All @@ -500,23 +500,24 @@ The available presentation types for `range_type` are:
+---------+----------------------------------------------------------+
| Type | Meaning |
+=========+==========================================================+
| none | Default format. |
+---------+----------------------------------------------------------+
| ``'s'`` | String format. The range is formatted as a string. |
+---------+----------------------------------------------------------+
| ``'?s'``| Debug format. The range is formatted as an escaped |
| | string. |
+---------+----------------------------------------------------------+
| none | Default format. The range is formatted with a separator. |
+---------+----------------------------------------------------------+

If `range_type` is ``'s'`` or ``'?s'``, the range element type must be a character type. The
``'n'`` option and `range_underlying_spec` are mutually exclusive with ``'s'`` and ``'?s'``.
If `range_type` is ``'s'`` or ``'?s'``, the range element type must be a
character type. The ``'n'`` option and `range_underlying_spec` are mutually
exclusive with ``'s'`` and ``'?s'``.

The `range_underlying_spec` is parsed based on the formatter of the range's
reference type.
element type.

By default, a range of characters or strings is printed escaped and quoted. But
if any `range_underlying_spec` is provided (even if it is empty), then the characters
or strings are printed according to the provided specification.
By default, a range of characters or strings is printed escaped and quoted.
But if any `range_underlying_spec` is provided (even if it is empty), then
the characters or strings are printed according to the provided specification.

Examples::

Expand Down
38 changes: 8 additions & 30 deletions dev/syntax.html
Original file line number Diff line number Diff line change
Expand Up @@ -690,40 +690,18 @@
<h2>Range Format Specifications<a class="headerlink" href="#range-format-specifications" title="Permalink to this headline"></a></h2>
<p>Format specifications for range types have the following syntax:</p>
<pre>
<strong id="grammar-token-sf-range_format_spec"><span id="grammar-token-range-format-spec"></span>range_format_spec</strong> ::= [&quot;:&quot; [&quot;n&quot;][<code class="xref docutils literal notranslate"><span class="pre">range_type</span></code>][<code class="xref docutils literal notranslate"><span class="pre">range_underlying_spec</span></code>]]
<strong id="grammar-token-sf-range_format_spec"><span id="grammar-token-range-format-spec"></span>range_format_spec</strong> ::= [&quot;n&quot;][<code class="xref docutils literal notranslate"><span class="pre">range_type</span></code>][<code class="xref docutils literal notranslate"><span class="pre">range_underlying_spec</span></code>]
</pre>
<p>The <code class="docutils literal notranslate"><span class="pre">'n'</span></code> option formats the range without the opening and closing brackets.</p>
<p>The available presentation types for <code class="xref cpp cpp-any docutils literal notranslate"><span class="pre">range_type</span></code> are:</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 13%" />
<col style="width: 87%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>Type</p></th>
<th class="head"><p>Meaning</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">'s'</span></code></p></td>
<td><p>String format. The range is formatted as a string.</p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">'?s'</span></code></p></td>
<td><p>Debug format. The range is formatted as an escaped
string.</p></td>
</tr>
<tr class="row-even"><td><p>none</p></td>
<td><p>Default format. The range is formatted with a separator.</p></td>
</tr>
</tbody>
</table>
<p>If <code class="xref cpp cpp-any docutils literal notranslate"><span class="pre">range_type</span></code> is <code class="docutils literal notranslate"><span class="pre">'s'</span></code> or <code class="docutils literal notranslate"><span class="pre">'?s'</span></code>, the range element type must be a character type. The
<code class="docutils literal notranslate"><span class="pre">'n'</span></code> option and <code class="xref cpp cpp-any docutils literal notranslate"><span class="pre">range_underlying_spec</span></code> are mutually exclusive with <code class="docutils literal notranslate"><span class="pre">'s'</span></code> and <code class="docutils literal notranslate"><span class="pre">'?s'</span></code>.</p>
<p>If <code class="xref cpp cpp-any docutils literal notranslate"><span class="pre">range_type</span></code> is <code class="docutils literal notranslate"><span class="pre">'s'</span></code> or <code class="docutils literal notranslate"><span class="pre">'?s'</span></code>, the range element type must be a
character type. The <code class="docutils literal notranslate"><span class="pre">'n'</span></code> option and <code class="xref cpp cpp-any docutils literal notranslate"><span class="pre">range_underlying_spec</span></code> are mutually
exclusive with <code class="docutils literal notranslate"><span class="pre">'s'</span></code> and <code class="docutils literal notranslate"><span class="pre">'?s'</span></code>.</p>
<p>The <code class="xref cpp cpp-any docutils literal notranslate"><span class="pre">range_underlying_spec</span></code> is parsed based on the formatter of the range’s
reference type.</p>
<p>By default, a range of characters or strings is printed escaped and quoted. But
if any <code class="xref cpp cpp-any docutils literal notranslate"><span class="pre">range_underlying_spec</span></code> is provided (even if it is empty), then the characters
or strings are printed according to the provided specification.</p>
element type.</p>
<p>By default, a range of characters or strings is printed escaped and quoted.
But if any <code class="xref cpp cpp-any docutils literal notranslate"><span class="pre">range_underlying_spec</span></code> is provided (even if it is empty), then
the characters or strings are printed according to the provided specification.</p>
<p>Examples:</p>
<div class="highlight-c++ notranslate"><div class="highlight"><pre><span></span><span class="n">fmt</span><span class="o">::</span><span class="n">format</span><span class="p">(</span><span class="s">&quot;{}&quot;</span><span class="p">,</span><span class="w"> </span><span class="n">std</span><span class="o">::</span><span class="n">vector</span><span class="p">{</span><span class="mi">10</span><span class="p">,</span><span class="w"> </span><span class="mi">20</span><span class="p">,</span><span class="w"> </span><span class="mi">30</span><span class="p">});</span>
<span class="c1">// Result: [10, 20, 30]</span>
Expand Down

0 comments on commit 26c6387

Please sign in to comment.