Skip to content

Commit a0eb603

Browse files
authored
mix help app:APP: Always try loading apps and support Erlang apps (#14894)
1 parent 0df110c commit a0eb603

File tree

2 files changed

+22
-4
lines changed

2 files changed

+22
-4
lines changed

lib/mix/lib/mix/tasks/help.ex

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,10 +114,19 @@ defmodule Mix.Tasks.Help do
114114
loadpaths!()
115115
app = String.to_atom(app)
116116

117+
# If the application is not available, attempt to load it from Erlang/Elixir
118+
if is_nil(Application.spec(app, :vsn)) do
119+
try do
120+
Mix.ensure_application!(app)
121+
rescue
122+
_ -> :ok
123+
end
124+
end
125+
117126
if modules = Application.spec(app, :modules) do
118127
for module <- modules,
119128
not (module |> Atom.to_string() |> String.starts_with?("Elixir.Mix.Tasks.")),
120-
{:docs_v1, _, :elixir, "text/markdown", %{"en" => <<doc::binary>>}, _, _} <-
129+
{:docs_v1, _, _, "text/markdown", %{"en" => <<doc::binary>>}, _, _} <-
121130
[Code.fetch_docs(module)] do
122131
leading = doc |> String.split(["\n\n", "\r\n\r\n"], parts: 2) |> hd()
123132
"# #{inspect(module)}\n#{leading}\n"

lib/mix/test/mix/tasks/help_test.exs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -199,14 +199,23 @@ defmodule Mix.Tasks.HelpTest do
199199
in_tmp(context.test, fn ->
200200
output =
201201
capture_io(fn ->
202-
Mix.Tasks.Help.run(["app:mix"])
202+
Mix.Tasks.Help.run(["app:iex"])
203203
end)
204204

205-
assert output =~ "# Mix\n\nMix is a build tool"
205+
assert output =~ "# IEx\n\nElixir's interactive shell."
206+
207+
if System.otp_release() >= "27" do
208+
output =
209+
capture_io(fn ->
210+
Mix.Tasks.Help.run(["app:parsetools"])
211+
end)
212+
213+
assert output =~ "# :leex"
214+
end
206215
end)
207216
end
208217

209-
test "help unknown app:APP", context do
218+
test "help app:UNKNOWN", context do
210219
in_tmp(context.test, fn ->
211220
Mix.Tasks.Help.run(["app:foobar"])
212221
assert_received {:mix_shell, :error, ["Application foobar does not exist or is not loaded"]}

0 commit comments

Comments
 (0)