Skip to content

Commit

Permalink
Update documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
fmtbot committed Jan 19, 2024
1 parent f4a2919 commit 1e50572
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
6 changes: 4 additions & 2 deletions dev/_sources/api.rst.txt
Original file line number Diff line number Diff line change
Expand Up @@ -139,14 +139,16 @@ without implementing them yourself. For example::
template <> struct fmt::formatter<color>: formatter<string_view> {
// parse is inherited from formatter<string_view>.

auto format(color c, format_context& ctx) const;
auto format(color c, format_context& ctx) const
-> format_parse_context::iterator;
};

// color.cc:
#include "color.h"
#include <fmt/format.h>

auto fmt::formatter<color>::format(color c, format_context& ctx) const {
auto fmt::formatter<color>::format(color c, format_context& ctx) const
-> format_parse_context::iterator {
string_view name = "unknown";
switch (c) {
case color::red: name = "red"; break;
Expand Down
6 changes: 4 additions & 2 deletions dev/api.html
Original file line number Diff line number Diff line change
Expand Up @@ -340,14 +340,16 @@ <h3>Compile-Time Format String Checks<a class="headerlink" href="#compile-time-f
<span class="k">template</span><span class="w"> </span><span class="o">&lt;&gt;</span><span class="w"> </span><span class="k">struct</span><span class="w"> </span><span class="nc">fmt</span><span class="o">::</span><span class="n">formatter</span><span class="o">&lt;</span><span class="n">color</span><span class="o">&gt;:</span><span class="w"> </span><span class="n">formatter</span><span class="o">&lt;</span><span class="n">string_view</span><span class="o">&gt;</span><span class="w"> </span><span class="p">{</span>
<span class="w"> </span><span class="c1">// parse is inherited from formatter&lt;string_view&gt;.</span>

<span class="w"> </span><span class="k">auto</span><span class="w"> </span><span class="n">format</span><span class="p">(</span><span class="n">color</span><span class="w"> </span><span class="n">c</span><span class="p">,</span><span class="w"> </span><span class="n">format_context</span><span class="o">&amp;</span><span class="w"> </span><span class="n">ctx</span><span class="p">)</span><span class="w"> </span><span class="k">const</span><span class="p">;</span>
<span class="w"> </span><span class="k">auto</span><span class="w"> </span><span class="n">format</span><span class="p">(</span><span class="n">color</span><span class="w"> </span><span class="n">c</span><span class="p">,</span><span class="w"> </span><span class="n">format_context</span><span class="o">&amp;</span><span class="w"> </span><span class="n">ctx</span><span class="p">)</span><span class="w"> </span><span class="k">const</span>
<span class="w"> </span><span class="o">-&gt;</span><span class="w"> </span><span class="n">format_parse_context</span><span class="o">::</span><span class="n">iterator</span><span class="p">;</span>
<span class="p">};</span>

<span class="c1">// color.cc:</span>
<span class="cp">#include</span><span class="w"> </span><span class="cpf">&quot;color.h&quot;</span>
<span class="cp">#include</span><span class="w"> </span><span class="cpf">&lt;fmt/format.h&gt;</span>

<span class="k">auto</span><span class="w"> </span><span class="n">fmt</span><span class="o">::</span><span class="n">formatter</span><span class="o">&lt;</span><span class="n">color</span><span class="o">&gt;::</span><span class="n">format</span><span class="p">(</span><span class="n">color</span><span class="w"> </span><span class="n">c</span><span class="p">,</span><span class="w"> </span><span class="n">format_context</span><span class="o">&amp;</span><span class="w"> </span><span class="n">ctx</span><span class="p">)</span><span class="w"> </span><span class="k">const</span><span class="w"> </span><span class="p">{</span>
<span class="k">auto</span><span class="w"> </span><span class="n">fmt</span><span class="o">::</span><span class="n">formatter</span><span class="o">&lt;</span><span class="n">color</span><span class="o">&gt;::</span><span class="n">format</span><span class="p">(</span><span class="n">color</span><span class="w"> </span><span class="n">c</span><span class="p">,</span><span class="w"> </span><span class="n">format_context</span><span class="o">&amp;</span><span class="w"> </span><span class="n">ctx</span><span class="p">)</span><span class="w"> </span><span class="k">const</span>
<span class="w"> </span><span class="o">-&gt;</span><span class="w"> </span><span class="n">format_parse_context</span><span class="o">::</span><span class="n">iterator</span><span class="w"> </span><span class="p">{</span>
<span class="w"> </span><span class="n">string_view</span><span class="w"> </span><span class="n">name</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">&quot;unknown&quot;</span><span class="p">;</span>
<span class="w"> </span><span class="k">switch</span><span class="w"> </span><span class="p">(</span><span class="n">c</span><span class="p">)</span><span class="w"> </span><span class="p">{</span>
<span class="w"> </span><span class="k">case</span><span class="w"> </span><span class="no">color</span><span class="o">::</span><span class="no">red</span><span class="p">:</span><span class="w"> </span><span class="n">name</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">&quot;red&quot;</span><span class="p">;</span><span class="w"> </span><span class="k">break</span><span class="p">;</span>
Expand Down

0 comments on commit 1e50572

Please sign in to comment.