Skip to content

Commit b973cfc

Browse files
committed
Omit external links from search data
1 parent b5b224c commit b973cfc

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

lib/ex_doc/formatter/html/search_data.ex

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ defmodule ExDoc.Formatter.HTML.SearchData do
1818
["searchData=" | ExDoc.Utils.to_json(data)]
1919
end
2020

21+
defp extra(%{url: _}), do: []
22+
2123
defp extra(%{search_data: search_data} = map) when is_list(search_data) do
2224
Enum.map(search_data, fn item ->
2325
link =
@@ -31,10 +33,6 @@ defmodule ExDoc.Formatter.HTML.SearchData do
3133
end)
3234
end
3335

34-
defp extra(%{url: url} = map) do
35-
[encode("#{map.id}", map.title, :extras, url)]
36-
end
37-
3836
defp extra(map) do
3937
{intro, sections} = extract_sections_from_markdown(map.source)
4038

test/ex_doc/formatter/html/search_data_test.exs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,12 @@ defmodule ExDoc.Formatter.HTML.SearchDataTest do
204204
Section _1_ content.
205205
""")
206206

207-
config = %ExDoc.Config{output: "#{c.tmp_dir}/doc", extras: [readme_path]}
207+
extras = [
208+
readme_path,
209+
"Elixir": [url: "https://elixir-lang.org"]
210+
]
211+
212+
config = %ExDoc.Config{output: "#{c.tmp_dir}/doc", extras: extras}
208213
[item1, item2] = search_data([], config)["items"]
209214

210215
assert item1["ref"] == "readme.html"

0 commit comments

Comments
 (0)