diff --git a/lib/iex/lib/iex/introspection.ex b/lib/iex/lib/iex/introspection.ex index b8656a19109..7f793a23c50 100644 --- a/lib/iex/lib/iex/introspection.ex +++ b/lib/iex/lib/iex/introspection.ex @@ -263,7 +263,7 @@ defmodule IEx.Introspection do {:docs_v1, _, :erlang, "application/erlang+html", _, _, _} = erl_docs -> :shell_docs.render(module, erl_docs) |> IO.puts() - {:docs_v1, _, _, format, %{} = doc, metadata, _} -> + {:docs_v1, _, _, format, doc, metadata, _} when is_map(doc) or doc == :none -> print_doc([inspect(module)], [], format, doc, metadata) {:docs_v1, _, _, _, _, _, _} -> diff --git a/lib/iex/test/iex/helpers_test.exs b/lib/iex/test/iex/helpers_test.exs index 80f71a44d32..b53cc6ace22 100644 --- a/lib/iex/test/iex/helpers_test.exs +++ b/lib/iex/test/iex/helpers_test.exs @@ -364,6 +364,51 @@ defmodule IEx.HelpersTest do end end + @tag :erlang_doc + # TODO remove once we require Erlang/OTP 27+ + @tag skip: System.otp_release() < "27" + test "erlang -moduledoc" do + filename = "sample.erl" + + code = ~s''' + -module(sample). + -moduledoc "Module documentation.". + ''' + + with_file(filename, code, fn -> + assert c(filename, ".") == [:sample] + + help = capture_iex("h(:sample)") + assert help =~ "Module documentation." + end) + after + cleanup_modules([:sample]) + end + + @tag :erlang_doc + # TODO remove once we require Erlang/OTP 27+ + @tag skip: System.otp_release() < "27" + test "erlang -doc" do + filename = "sample.erl" + + code = ~s''' + -module(sample). + -export([hello/0]). + + -doc "Function documentation.". + hello() -> world. + ''' + + with_file(filename, code, fn -> + assert c(filename, ".") == [:sample] + + help = capture_iex("h(:sample.hello)") + assert help =~ "Function documentation." + end) + after + cleanup_modules([:sample]) + end + test "prints module documentation" do assert "\n IEx.Helpers\n\nWelcome to Interactive Elixir" <> _ = capture_io(fn -> h(IEx.Helpers) end)