diff --git a/lib/mix/lib/mix/tasks/help.ex b/lib/mix/lib/mix/tasks/help.ex index fe44223960..e3895756e7 100644 --- a/lib/mix/lib/mix/tasks/help.ex +++ b/lib/mix/lib/mix/tasks/help.ex @@ -114,10 +114,19 @@ defmodule Mix.Tasks.Help do loadpaths!() app = String.to_atom(app) + # If the application is not available, attempt to load it from Erlang/Elixir + if is_nil(Application.spec(app, :vsn)) do + try do + Mix.ensure_application!(app) + rescue + _ -> :ok + end + end + if modules = Application.spec(app, :modules) do for module <- modules, not (module |> Atom.to_string() |> String.starts_with?("Elixir.Mix.Tasks.")), - {:docs_v1, _, :elixir, "text/markdown", %{"en" => <>}, _, _} <- + {:docs_v1, _, _, "text/markdown", %{"en" => <>}, _, _} <- [Code.fetch_docs(module)] do leading = doc |> String.split(["\n\n", "\r\n\r\n"], parts: 2) |> hd() "# #{inspect(module)}\n#{leading}\n" diff --git a/lib/mix/test/mix/tasks/help_test.exs b/lib/mix/test/mix/tasks/help_test.exs index 3d4f3a3a00..c48f8c17a0 100644 --- a/lib/mix/test/mix/tasks/help_test.exs +++ b/lib/mix/test/mix/tasks/help_test.exs @@ -199,14 +199,23 @@ defmodule Mix.Tasks.HelpTest do in_tmp(context.test, fn -> output = capture_io(fn -> - Mix.Tasks.Help.run(["app:mix"]) + Mix.Tasks.Help.run(["app:iex"]) end) - assert output =~ "# Mix\n\nMix is a build tool" + assert output =~ "# IEx\n\nElixir's interactive shell." + + if System.otp_release() >= "27" do + output = + capture_io(fn -> + Mix.Tasks.Help.run(["app:parsetools"]) + end) + + assert output =~ "# :leex" + end end) end - test "help unknown app:APP", context do + test "help app:UNKNOWN", context do in_tmp(context.test, fn -> Mix.Tasks.Help.run(["app:foobar"]) assert_received {:mix_shell, :error, ["Application foobar does not exist or is not loaded"]}