diff --git a/lib/mix/lib/mix/tasks/help.ex b/lib/mix/lib/mix/tasks/help.ex index e3895756e7..18e15b2df3 100644 --- a/lib/mix/lib/mix/tasks/help.ex +++ b/lib/mix/lib/mix/tasks/help.ex @@ -112,6 +112,7 @@ defmodule Mix.Tasks.Help do def run(["app:" <> app]) do loadpaths!() + app = String.to_atom(app) # If the application is not available, attempt to load it from Erlang/Elixir @@ -119,7 +120,11 @@ defmodule Mix.Tasks.Help do try do Mix.ensure_application!(app) rescue - _ -> :ok + _ -> + # Otherwise, it may be a dep or the current project not yet compiled + if Mix.Project.get() do + Mix.Task.run("compile") + end end end diff --git a/lib/mix/test/mix/tasks/help_test.exs b/lib/mix/test/mix/tasks/help_test.exs index c48f8c17a0..e29e47e656 100644 --- a/lib/mix/test/mix/tasks/help_test.exs +++ b/lib/mix/test/mix/tasks/help_test.exs @@ -222,6 +222,41 @@ defmodule Mix.Tasks.HelpTest do end) end + defmodule ExampleProject do + def project do + [ + app: :sample, + version: "0.1.0" + ] + end + end + + test "help app:APP for current project", context do + in_tmp(context.test, fn -> + Mix.Project.push(ExampleProject) + File.mkdir_p!("lib") + + File.write!("lib/example.ex", ~s''' + defmodule Example do + @moduledoc """ + This is an example module. + """ + end + ''') + + output = + capture_io(fn -> + Mix.Tasks.Help.run(["app:sample"]) + end) + + assert output =~ """ + # Example + + This is an example module. + """ + end) + end + test "help Elixir MODULE", context do in_tmp(context.test, fn -> output =