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
7 changes: 6 additions & 1 deletion lib/mix/lib/mix/tasks/help.ex
Original file line number Diff line number Diff line change
Expand Up @@ -112,14 +112,19 @@ 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
if is_nil(Application.spec(app, :vsn)) 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

Expand Down
35 changes: 35 additions & 0 deletions lib/mix/test/mix/tasks/help_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down