That's similar to what the official docs do: https://doc.rust-lang.org/std/fmt/fn.format.html  And it's not trivial to assert in doc tests without all the boilterplate.    The main thing here is to explain the syntax. The rest is obvious.