Skip to content
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
11 changes: 10 additions & 1 deletion lib/mix/lib/mix/tasks/help.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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" => <<doc::binary>>}, _, _} <-
{:docs_v1, _, _, "text/markdown", %{"en" => <<doc::binary>>}, _, _} <-
[Code.fetch_docs(module)] do
leading = doc |> String.split(["\n\n", "\r\n\r\n"], parts: 2) |> hd()
"# #{inspect(module)}\n#{leading}\n"
Expand Down
15 changes: 12 additions & 3 deletions lib/mix/test/mix/tasks/help_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -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"]}
Expand Down
Loading