Skip to content

Commit 820a9c8

Browse files
committed
use new struct for node group
1 parent 4e78878 commit 820a9c8

File tree

2 files changed

+16
-12
lines changed

2 files changed

+16
-12
lines changed

lib/ex_doc/nodes.ex

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,6 @@ defmodule ExDoc.ModuleNode do
2626

2727
@typep annotation :: atom()
2828

29-
# TODO: Maybe this is worth its own module
30-
@type doc_group :: %{
31-
title: String.t() | atom(),
32-
description: String.t() | nil,
33-
doc: ExDoc.DocAST.t() | nil,
34-
rendered_doc: String.t() | nil
35-
}
36-
3729
@type t :: %__MODULE__{
3830
id: String.t(),
3931
title: String.t(),
@@ -49,7 +41,7 @@ defmodule ExDoc.ModuleNode do
4941
moduledoc_file: String.t(),
5042
source_path: String.t() | nil,
5143
source_url: String.t() | nil,
52-
docs_groups: [doc_group],
44+
docs_groups: [ExDoc.DocGroupNode.t()],
5345
docs: [ExDoc.DocNode.t()],
5446
typespecs: [ExDoc.DocNode.t()],
5547
type: atom(),
@@ -93,9 +85,20 @@ defmodule ExDoc.DocNode do
9385
signature: String.t(),
9486
specs: [ExDoc.Language.spec_ast()],
9587
annotations: [annotation()],
96-
group: String.t() | ExDoc.ModuleNode.doc_group() | nil,
88+
group: String.t() | ExDoc.DocGroupNode.t() | nil,
9789
doc_file: String.t(),
9890
doc_line: non_neg_integer(),
9991
source_url: String.t() | nil
10092
}
10193
end
94+
95+
defmodule ExDoc.DocGroupNode do
96+
defstruct title: nil, description: nil, doc: nil, rendered_doc: nil
97+
98+
@type t :: %__MODULE__{
99+
title: String.t() | atom(),
100+
description: String.t() | nil,
101+
doc: ExDoc.DocAST.t() | nil,
102+
rendered_doc: String.t() | nil
103+
}
104+
end

lib/ex_doc/retriever.ex

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -312,11 +312,12 @@ group = normalize_group(group_for_doc.(metadata) || doc_data.default_group)
312312
text -> doc_ast("text/markdown", %{"en" => text}, [])
313313
end
314314

315-
Map.merge(group, %{
315+
%ExDoc.DocGroupNode{
316+
title: group.title,
316317
description: description,
317318
doc: doc_ast,
318319
rendered_doc: nil
319-
})
320+
}
320321
end
321322

322323
## General helpers

0 commit comments

Comments
 (0)