Skip to content

Commit a724571

Browse files
committed
Add support for h AnyModule.__info__. Closes #1230
1 parent 3f3e86d commit a724571

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

lib/iex/lib/iex/helpers.ex

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,12 +99,26 @@ defmodule IEx.Helpers do
9999
h Enum.all?/2
100100
h Enum.all?
101101
"""
102+
# Special case for `h AnyModule.__info__/1`
103+
defmacro h({ :/, _, [{ { :., _, [_mod, :__info__] }, _, [] }, 1] }) do
104+
quote do
105+
IEx.Introspection.h(Module, :__info__, 1)
106+
end
107+
end
108+
102109
defmacro h({ :/, _, [{ { :., _, [mod, fun] }, _, [] }, arity] }) do
103110
quote do
104111
IEx.Introspection.h(unquote(mod), unquote(fun), unquote(arity))
105112
end
106113
end
107114

115+
# Special case for `h AnyModule.__info__`
116+
defmacro h({ { :., _, [_mod, :__info__] }, _, [] }) do
117+
quote do
118+
IEx.Introspection.h(Module, :__info__, 1)
119+
end
120+
end
121+
108122
defmacro h({ { :., _, [mod, fun] }, _, [] }) do
109123
quote do
110124
IEx.Introspection.h(unquote(mod), unquote(fun))

lib/iex/test/iex/helpers_test.exs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,13 @@ defmodule IEx.HelpersTest do
4343
== "* def pwd()\n\nPrints the current working directory.\n\n"
4444
end
4545

46+
test "h helper __info__" do
47+
h_output_module = capture_io(fn -> h Module.__info__ end)
48+
assert capture_io(fn -> h Module.UnlikelyTo.Exist.__info__ end) == h_output_module
49+
assert capture_io(fn -> h Module.UnlikelyTo.Exist.__info__/1 end) == h_output_module
50+
assert capture_io(fn -> h __info__ end) == "No docs for __info__ have been found\n"
51+
end
52+
4653
test "t helper" do
4754
assert capture_io(fn -> t ExUnit end) == "No types for ExUnit have been found\n"
4855

0 commit comments

Comments
 (0)