Skip to content

Commit f0ebedc

Browse files
authored
Fix h for Erlang module with -doc but no -moduledoc (#13587)
1 parent f23434e commit f0ebedc

File tree

2 files changed

+46
-1
lines changed

2 files changed

+46
-1
lines changed

lib/iex/lib/iex/introspection.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ defmodule IEx.Introspection do
263263
{:docs_v1, _, :erlang, "application/erlang+html", _, _, _} = erl_docs ->
264264
:shell_docs.render(module, erl_docs) |> IO.puts()
265265

266-
{:docs_v1, _, _, format, %{} = doc, metadata, _} ->
266+
{:docs_v1, _, _, format, doc, metadata, _} when is_map(doc) or doc == :none ->
267267
print_doc([inspect(module)], [], format, doc, metadata)
268268

269269
{:docs_v1, _, _, _, _, _, _} ->

lib/iex/test/iex/helpers_test.exs

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,51 @@ defmodule IEx.HelpersTest do
364364
end
365365
end
366366

367+
@tag :erlang_doc
368+
# TODO remove once we require Erlang/OTP 27+
369+
@tag skip: System.otp_release() < "27"
370+
test "erlang -moduledoc" do
371+
filename = "sample.erl"
372+
373+
code = ~s'''
374+
-module(sample).
375+
-moduledoc "Module documentation.".
376+
'''
377+
378+
with_file(filename, code, fn ->
379+
assert c(filename, ".") == [:sample]
380+
381+
help = capture_iex("h(:sample)")
382+
assert help =~ "Module documentation."
383+
end)
384+
after
385+
cleanup_modules([:sample])
386+
end
387+
388+
@tag :erlang_doc
389+
# TODO remove once we require Erlang/OTP 27+
390+
@tag skip: System.otp_release() < "27"
391+
test "erlang -doc" do
392+
filename = "sample.erl"
393+
394+
code = ~s'''
395+
-module(sample).
396+
-export([hello/0]).
397+
398+
-doc "Function documentation.".
399+
hello() -> world.
400+
'''
401+
402+
with_file(filename, code, fn ->
403+
assert c(filename, ".") == [:sample]
404+
405+
help = capture_iex("h(:sample.hello)")
406+
assert help =~ "Function documentation."
407+
end)
408+
after
409+
cleanup_modules([:sample])
410+
end
411+
367412
test "prints module documentation" do
368413
assert "\n IEx.Helpers\n\nWelcome to Interactive Elixir" <>
369414
_ = capture_io(fn -> h(IEx.Helpers) end)

0 commit comments

Comments
 (0)