Skip to content

Commit 81b6cfe

Browse files
committed
Add ability to specify multiple apps from CLI
1 parent 4bc56b9 commit 81b6cfe

File tree

3 files changed

+19
-23
lines changed

3 files changed

+19
-23
lines changed

Diff for: README.md

+6
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,12 @@ You can use ExDoc via the command line.
114114
GITHUB_REPO => ecto
115115
```
116116

117+
It is also possible to specify multiple `ebin` directories in the case of _umbrella_ projects:
118+
119+
```bash
120+
$ ex_doc "PROJECT_NAME" "PROJECT_VERSION" _build/dev/lib/app1/ebin _build/dev/lib/app2/ebin -m "PROJECT_MODULE" -u "https://github.com/GITHUB_USER/GITHUB_REPO" -l path/to/logo.png
121+
```
122+
117123
You can specify a config file via the `--config` option, both Elixir and Erlang formats are supported. Invoke `ex_doc` without arguments to learn more.
118124

119125
<!-- tabs-close -->

Diff for: lib/ex_doc/cli.ex

+5-11
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,9 @@ defmodule ExDoc.CLI do
6969
end
7070

7171
defp generate(args, opts, generator) do
72-
[project, version, source_beam] = parse_args(args)
72+
[project, version | source_beams] = parse_args(args)
7373

74-
Code.prepend_path(source_beam)
74+
Code.prepend_paths(source_beams)
7575

7676
for path <- Keyword.get_values(opts, :paths),
7777
path <- Path.wildcard(path) do
@@ -80,8 +80,8 @@ defmodule ExDoc.CLI do
8080

8181
opts =
8282
opts
83-
|> Keyword.put(:source_beam, source_beam)
84-
|> Keyword.put(:apps, [app(source_beam)])
83+
|> Keyword.put(:source_beam, source_beams)
84+
|> Keyword.put(:apps, Enum.map(source_beams, &app/1))
8585
|> merge_config()
8686
|> normalize_formatters()
8787

@@ -166,13 +166,7 @@ defmodule ExDoc.CLI do
166166
end
167167
end
168168

169-
defp parse_args([_project, _version, _source_beam] = args), do: args
170-
171-
defp parse_args([_, _, _ | _]) do
172-
IO.puts("Too many arguments.\n")
173-
print_usage()
174-
exit({:shutdown, 1})
175-
end
169+
defp parse_args([_project, _version | _source_beams] = args), do: args
176170

177171
defp parse_args(_) do
178172
IO.puts("Too few arguments.\n")

Diff for: test/ex_doc/cli_test.exs

+8-12
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ defmodule ExDoc.CLITest do
1717
formatter: "html",
1818
formatters: ["html", "epub"],
1919
apps: [:ex_doc],
20-
source_beam: @ebin
20+
source_beam: [@ebin]
2121
]}
2222

2323
assert epub ==
@@ -26,7 +26,7 @@ defmodule ExDoc.CLITest do
2626
formatter: "epub",
2727
formatters: ["html", "epub"],
2828
apps: [:ex_doc],
29-
source_beam: @ebin
29+
source_beam: [@ebin]
3030
]}
3131
end
3232

@@ -39,7 +39,7 @@ defmodule ExDoc.CLITest do
3939
formatter: "epub",
4040
formatters: ["epub", "html"],
4141
apps: [:ex_doc],
42-
source_beam: @ebin
42+
source_beam: [@ebin]
4343
]}
4444

4545
assert html ==
@@ -48,7 +48,7 @@ defmodule ExDoc.CLITest do
4848
formatter: "html",
4949
formatters: ["epub", "html"],
5050
apps: [:ex_doc],
51-
source_beam: @ebin
51+
source_beam: [@ebin]
5252
]}
5353
end
5454

@@ -60,10 +60,6 @@ defmodule ExDoc.CLITest do
6060
assert io == "ExDoc v#{ExDoc.version()}\n"
6161
end
6262

63-
test "too many arguments" do
64-
assert catch_exit(run(["ExDoc", "1.2.3", "/", "kaboom"])) == {:shutdown, 1}
65-
end
66-
6763
test "too few arguments" do
6864
assert catch_exit(run(["ExDoc"])) == {:shutdown, 1}
6965
end
@@ -98,7 +94,7 @@ defmodule ExDoc.CLITest do
9894
logo: "logo.png",
9995
main: "Main",
10096
output: "html",
101-
source_beam: "#{@ebin}",
97+
source_beam: ["#{@ebin}"],
10298
source_ref: "abcdefg",
10399
source_url: "http://example.com/username/project"
104100
]
@@ -127,7 +123,7 @@ defmodule ExDoc.CLITest do
127123
extras: ["README.md"],
128124
formatter: "html",
129125
formatters: ["html"],
130-
source_beam: @ebin
126+
source_beam: [@ebin]
131127
]
132128
after
133129
File.rm!("test.exs")
@@ -155,7 +151,7 @@ defmodule ExDoc.CLITest do
155151
formatter: "html",
156152
formatters: ["html"],
157153
logo: "opts_logo.png",
158-
source_beam: @ebin
154+
source_beam: [@ebin]
159155
]
160156
after
161157
File.rm!("test.exs")
@@ -192,7 +188,7 @@ defmodule ExDoc.CLITest do
192188
extras: ["README.md"],
193189
formatter: "html",
194190
formatters: ["html"],
195-
source_beam: @ebin
191+
source_beam: [@ebin]
196192
]
197193
after
198194
File.rm!("test.config")

0 commit comments

Comments
 (0)