[1]https://elixir-lang.org/getting-started/mix-otp/docs-tests-a...
Here's an example:
##Examples
iex> user = Repo.insert!(%MyApp.User{id: 1, some_state: "whatever"})
...> {:ok, user} = MyApp.Users.DataTransformer.transform_with_effects(user)
...> Repo.one(where: MyApp.User.id == 1).some_state
"new state"Sphinx also has additional doc testing methods that let you test the code examples in your actual docs: http://www.sphinx-doc.org/en/stable/ext/doctest.html
Or to put it another way, the way to learn how to use Clojure's Spec is not from the names of functions in the Clojure Spec source code. It's from reading blogs and watching videos and listening to podcasts and reading the documentation. And the bar for Clojure Spec is pretty low. It just has to be better than JavaDoc.
More seriously, keeping comments up to date is hard, but there's no alternative if you want to maintain a public API.