Skip to content

Commit 7dbc937

Browse files
Use Struct instead of __struct__/0 in sidebar (#1446)
Closes #1433
1 parent e1da25c commit 7dbc937

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

lib/ex_doc/formatter/html/templates.ex

+8-1
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,14 @@ defmodule ExDoc.Formatter.HTML.Templates do
146146
defp sidebar_entries({group, nodes}) do
147147
nodes =
148148
for node <- nodes do
149-
%{id: "#{node.name}/#{node.arity}", anchor: URI.encode(node.id)}
149+
id =
150+
if "struct" in node.annotations do
151+
node.signature
152+
else
153+
"#{node.name}/#{node.arity}"
154+
end
155+
156+
%{id: id, anchor: URI.encode(node.id)}
150157
end
151158

152159
%{key: HTML.text_to_id(group), name: group, nodes: nodes}

test/ex_doc/formatter/html/templates_test.exs

+1
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,7 @@ defmodule ExDoc.Formatter.HTML.TemplatesTest do
218218
assert content =~ ~r("id":"CompiledWithDocs".*"key":"functions".*"example/2")ms
219219
assert content =~ ~r("id":"CompiledWithDocs".*"key":"functions".*"example_without_docs/0")ms
220220
assert content =~ ~r("id":"CompiledWithDocs.Nested")ms
221+
assert content =~ ~r(\{"anchor":"__struct__/0","id":"%CompiledWithDocs\{\}"\})ms
221222
end
222223

223224
test "outputs nodes grouped based on metadata" do

0 commit comments

Comments
 (0)