Skip to content

Commit

Permalink
Add kind, name, arity and module to metadata used in groups_for_docs
Browse files Browse the repository at this point in the history
  • Loading branch information
garazdawi authored and wojtekmach committed Dec 4, 2023
1 parent b630899 commit 9deb0aa
Showing 1 changed file with 27 additions and 4 deletions.
31 changes: 27 additions & 4 deletions lib/ex_doc/retriever.ex
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,14 @@ defmodule ExDoc.Retriever do
(source_doc && doc_ast(content_type, source_doc, file: source.path, line: doc_line + 1)) ||
function_data.doc_fallback.()

group = GroupMatcher.match_function(groups_for_docs, metadata)
group =
GroupMatcher.match_function(
groups_for_docs,
Map.merge(
%{kind: type, name: name, arity: arity, module: module_data.module},
metadata
)
)

%ExDoc.FunctionNode{
id: nil_or_name(name, arity),
Expand Down Expand Up @@ -323,7 +330,15 @@ defmodule ExDoc.Retriever do
doc_ast = doc_ast(content_type, source_doc, file: source.path, line: doc_line + 1)

metadata = Map.put(metadata, :__doc__, :callback)
group = GroupMatcher.match_function(groups_for_docs, metadata)

group =
GroupMatcher.match_function(
groups_for_docs,
Map.merge(
%{kind: kind, name: name, arity: arity, module: module_data.module},
metadata
)
)

%ExDoc.FunctionNode{
id: "c:" <> nil_or_name(name, arity),
Expand Down Expand Up @@ -355,7 +370,7 @@ defmodule ExDoc.Retriever do

defp get_type(type_entry, source, groups_for_docs, module_data, annotations_for_docs) do
{:docs_v1, _, _, content_type, _, module_metadata, _} = module_data.docs
{{_, name, arity}, anno, _signature, source_doc, metadata} = type_entry
{{kind, name, arity}, anno, _signature, source_doc, metadata} = type_entry
doc_line = anno_line(anno)
source = anno_file(anno, source)
annotations = annotations_from_metadata(metadata, module_metadata)
Expand All @@ -369,7 +384,15 @@ defmodule ExDoc.Retriever do

doc_ast = doc_ast(content_type, source_doc, file: source.path, line: doc_line + 1)
metadata = Map.put(metadata, :__doc__, :type)
group = GroupMatcher.match_function(groups_for_docs, metadata)

group =
GroupMatcher.match_function(
groups_for_docs,
Map.merge(
%{kind: kind, name: name, arity: arity, module: module_data.module},
metadata
)
)

%ExDoc.TypeNode{
id: "t:" <> nil_or_name(name, arity),
Expand Down

0 comments on commit 9deb0aa

Please sign in to comment.