Skip to content

iex: Fix h for Erlang module with -doc but no -moduledoc #13587

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/iex/lib/iex/introspection.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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, _, _, _, _, _, _} ->
Expand Down
45 changes: 45 additions & 0 deletions lib/iex/test/iex/helpers_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down