Skip to content

Commit

Permalink
docs: change group_for_docs in ex_doc.exs, to use :group metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
frazze-jobb committed Feb 8, 2025
1 parent 254972a commit 0493b29
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions make/ex_doc.exs
Original file line number Diff line number Diff line change
Expand Up @@ -72,47 +72,47 @@ modules =

titles =
modules
|> Enum.reduce(
|> Enum.reduce(
[],
fn module, acc ->
case Code.fetch_docs(module) do
{:docs_v1, _, :erlang, _, _, %{:titles => ts}, _} ->
{:docs_v1, _, :erlang, _, _, _, fun_docs} ->
ts = for {{type,_,_},_,_,_,%{group: group}}<-fun_docs, do: {type, group}
acc ++ ts

_ ->
acc
end
acc
end
end
)
|> Enum.group_by(fn e -> elem(e, 0) end)

groups_for_docs =
Enum.map(
Access.get(titles, :type, []),
Enum.sort(Access.get(titles, :type, [])),
fn {:type, title} ->
{"Types: #{title}",
fn a ->
a[:kind] == :type && String.equivalent?(Access.get(a, :title, ""), title)
a[:kind] == :type && String.equivalent?(Access.get(a, :group, ""), title)
end}
end
) ++
[Types: &(&1[:kind] == :type)] ++
Enum.map(
Access.get(titles, :callback, []),
Enum.sort(Access.get(titles, :callback, [])),
fn {:callback, title} ->
{"Callbacks: #{title}",
fn a ->
a[:kind] == :callback && String.equivalent?(Access.get(a, :title, ""), title)
a[:kind] == :callback && String.equivalent?(Access.get(a, :group, ""), title)
end}
end
) ++
[Callbacks: &(&1[:kind] == :callback)] ++
Enum.map(
Access.get(titles, :function, []),
Enum.sort(Access.get(titles, :function, [])),
fn {:function, title} ->
{"#{title}",
fn a ->
a[:kind] == :function && String.equivalent?(Access.get(a, :title, ""), title)
a[:kind] == :function && String.equivalent?(Access.get(a, :group, ""), title)
end}
end
)
Expand Down

0 comments on commit 0493b29

Please sign in to comment.