Skip to content

Commit 6b511cc

Browse files
author
José Valim
committed
Remove @hidden in mix tasks
Instead, we can use the presence or abscence of @shortdoc to specify if the task should be shown or not.
1 parent 4ade0f9 commit 6b511cc

15 files changed

+16
-50
lines changed

lib/mix/lib/mix/task.ex

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,7 @@ defmodule Mix.Task do
2525
There are a couple attributes available in Mix tasks to
2626
configure them in Mix:
2727
28-
* `@shortdoc` - shows a short description that appears
29-
on `mix help`
30-
* `@hidden` - do not show the task in `mix help`
28+
* `@shortdoc` - makes the task public with a short description that appears on `mix help`
3129
* `@recursive` - run the task recursively in umbrella projects
3230
3331
"""
@@ -41,7 +39,7 @@ defmodule Mix.Task do
4139
@doc false
4240
defmacro __using__(_opts) do
4341
quote do
44-
Enum.each [:shortdoc, :hidden, :recursive],
42+
Enum.each [:shortdoc, :recursive],
4543
&Module.register_attribute(__MODULE__, &1, persist: true)
4644

4745
@behaviour Mix.Task
@@ -109,16 +107,6 @@ defmodule Mix.Task do
109107
end
110108
end
111109

112-
@doc """
113-
Checks if the task is hidden or not. Returns a boolean.
114-
"""
115-
def hidden?(module) when is_atom(module) do
116-
case List.keyfind module.__info__(:attributes), :hidden, 0 do
117-
{ :hidden, [bool] } -> bool
118-
_ -> false
119-
end
120-
end
121-
122110
@doc """
123111
Checks if the task should be run recursively for all sub-apps in
124112
umbrella projects. Returns `true`, `false` or `:both`.

lib/mix/lib/mix/tasks/app.start.ex

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
defmodule Mix.Tasks.App.Start do
22
use Mix.Task
33

4-
@hidden true
5-
@shortdoc "Start registered apps"
64
@recursive true
75

86
@moduledoc """

lib/mix/lib/mix/tasks/compile.app.ex

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
defmodule Mix.Tasks.Compile.App do
22
use Mix.Task
33

4-
@hidden true
5-
@shortdoc "Write .app file"
64
@recursive true
75

86
@moduledoc """

lib/mix/lib/mix/tasks/compile.elixir.ex

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -164,13 +164,11 @@ defmodule Mix.Tasks.Compile.Elixir do
164164
use Mix.Task
165165
alias Mix.Tasks.Compile.Erlang
166166

167-
@hidden true
168-
@shortdoc "Compile Elixir source files"
169167
@recursive true
170168
@manifest ".compile.elixir"
171169

172170
@moduledoc """
173-
A task to compile Elixir source files.
171+
Compiles Elixir source files.
174172
175173
Elixir is smart enough to recompile only files that changed
176174
and their dependencies. This means if `lib/a.ex` is invoking

lib/mix/lib/mix/tasks/compile.erlang.ex

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,11 @@ defmodule Mix.Tasks.Compile.Erlang do
55

66
use Mix.Task
77

8-
@hidden true
9-
@shortdoc "Compile Erlang source files"
108
@recursive true
119
@manifest ".compile.erlang"
1210

1311
@moduledoc """
14-
A task to compile Erlang source files.
12+
Compile Erlang source files.
1513
1614
When this task runs, it will first check the modification times of
1715
all files to be compiled and if they haven't been

lib/mix/lib/mix/tasks/compile.ex

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ defmodule Mix.Tasks.Compile do
3939
docs = lc module inlist modules,
4040
task = Mix.Task.task_name(module),
4141
match?("compile." <> _, task),
42-
doc = Mix.Task.shortdoc(module) do
43-
{ task, doc }
42+
doc = Mix.Task.moduledoc(module) do
43+
{ task, first_line(doc) }
4444
end
4545

4646
max = Enum.reduce docs, 0, fn({ task, _ }, acc) ->
@@ -93,4 +93,8 @@ defmodule Mix.Tasks.Compile do
9393
defp format(expression, args) do
9494
:io_lib.format(expression, args) |> iolist_to_binary
9595
end
96+
97+
defp first_line(doc) do
98+
String.split(doc, "\n", global: false) |> hd |> String.strip |> String.rstrip(?.)
99+
end
96100
end

lib/mix/lib/mix/tasks/compile.leex.ex

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,11 @@ defmodule Mix.Tasks.Compile.Leex do
33

44
use Mix.Task
55

6-
@hidden true
7-
@shortdoc "Compile Leex source files"
86
@recursive true
97
@manifest ".compile.leex"
108

119
@moduledoc """
12-
A task to compile Leex source files.
10+
Compile Leex source files.
1311
1412
When this task runs, it will check the modification time of every file, and
1513
if it has changed, the file will be compiled. Files will be

lib/mix/lib/mix/tasks/compile.yecc.ex

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,11 @@ defmodule Mix.Tasks.Compile.Yecc do
33

44
use Mix.Task
55

6-
@hidden true
7-
@shortdoc "Compile Yecc source files"
86
@recursive true
97
@manifest ".compile.yecc"
108

119
@moduledoc """
12-
A task to compile Yecc source files.
10+
Compile Yecc source files.
1311
1412
When this task runs, it will check the modification time of every file, and
1513
if it has changed, the file will be compiled. Files will be

lib/mix/lib/mix/tasks/deps.check.ex

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@ defmodule Mix.Tasks.Deps.Check do
33

44
import Mix.Deps, only: [loaded: 0, format_dep: 1, format_status: 1, check_lock: 2, ok?: 1]
55

6-
@hidden true
7-
@shortdoc "Check if all dependencies are valid"
8-
96
@moduledoc """
107
Checks if all dependencies are valid and if not, abort.
118
Prints the invalid dependencies' status before aborting.

lib/mix/lib/mix/tasks/deps.loadpaths.ex

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
defmodule Mix.Tasks.Deps.Loadpaths do
22
use Mix.Task
33

4-
@hidden true
5-
@shortdoc "Load all dependencies build paths"
6-
74
@moduledoc """
85
Loads all dependencies for the current build.
96
This is invoked directly by `loadpaths` when

0 commit comments

Comments
 (0)