Skip to content

Commit af30285

Browse files
committed
Group modules by app for umbrella projects by default
1 parent 81b6cfe commit af30285

File tree

3 files changed

+26
-1
lines changed

3 files changed

+26
-1
lines changed

Diff for: README.md

+2
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,8 @@ It is also possible to specify multiple `ebin` directories in the case of _umbre
120120
$ 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
121121
```
122122

123+
If multiple `ebin` directories are specified, modules are grouped by application by default. It is possible to override this behaviour by providing a custom `groups_per_modules` option.
124+
123125
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.
124126

125127
<!-- tabs-close -->

Diff for: lib/ex_doc/config.ex

+15-1
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,10 @@ defmodule ExDoc.Config do
115115

116116
{groups_for_docs, options} = Keyword.pop(options, :groups_for_docs, [])
117117
{groups_for_extras, options} = Keyword.pop(options, :groups_for_extras, [])
118-
{groups_for_modules, options} = Keyword.pop(options, :groups_for_modules, [])
118+
apps = Keyword.get(options, :apps, [])
119+
120+
{groups_for_modules, options} =
121+
Keyword.pop(options, :groups_for_modules, default_groups_for_modules(apps))
119122

120123
{skip_undefined_reference_warnings_on, options} =
121124
Keyword.pop(
@@ -278,4 +281,15 @@ defmodule ExDoc.Config do
278281
defp append_slash(url) do
279282
if :binary.last(url) == ?/, do: url, else: url <> "/"
280283
end
284+
285+
defp default_groups_for_modules([_app]) do
286+
[]
287+
end
288+
289+
defp default_groups_for_modules(apps) do
290+
Enum.map(apps, fn app ->
291+
Application.load(app)
292+
{app, Application.spec(app, :modules)}
293+
end)
294+
end
281295
end

Diff for: test/ex_doc/cli_test.exs

+9
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ defmodule ExDoc.CLITest do
33
import ExUnit.CaptureIO
44

55
@ebin "_build/test/lib/ex_doc/ebin"
6+
@ebin2 "_build/test/lib/makeup/ebin"
67

78
defp run(args) do
89
with_io(fn -> ExDoc.CLI.main(args, &{&1, &2, &3}) end)
@@ -64,6 +65,14 @@ defmodule ExDoc.CLITest do
6465
assert catch_exit(run(["ExDoc"])) == {:shutdown, 1}
6566
end
6667

68+
test "multiple apps" do
69+
{[{"ExDoc", "1.2.3", html}, {"ExDoc", "1.2.3", epub}], _io} =
70+
run(["ExDoc", "1.2.3", @ebin, @ebin2])
71+
72+
assert [:ex_doc, :makeup] = Enum.sort(Keyword.get(html, :apps))
73+
assert [:ex_doc, :makeup] = Enum.sort(Keyword.get(epub, :apps))
74+
end
75+
6776
test "arguments that are not aliased" do
6877
File.write!("not_aliased.exs", ~s([key: "val"]))
6978

0 commit comments

Comments
 (0)