Proposal: Introduce help catalogs

It’s already possible to include dynamic content in documentation, but it’s a bit tricky to do that since you need to ensure that whatever code you’re using is already loaded. This could get even more complicated in Elixir core because of bootstrapping, but correct me @josevalim, if I’m wrong.

Here’s an example:

defmodule DocHelpers do
  def list_guards do
    ~w(is_atom/1 is_binary/1 length/1)
  end
end

defmodule DynDoc do
  @doc """
  Guards

  Not all expressions are allowed in guard clauses.

  List of allowed expressions:

  #{Enum.map_join(DocHelpers.list_guards(), "\n", &"  * #{&1}")}
  """
  def guards, do: @doc
end

and the output:

iex(5)> h DynDoc.guards

                                  def guards()

Guards

Not all expressions are allowed in guard clauses.

List of allowed expressions:

  • is_atom/1
  • is_binary/1
  • length/1
1 Like