From 4114bbfd1db9c3ff43f7fdbf6298bed063fbcdf1 Mon Sep 17 00:00:00 2001 From: Bryan Paxton <39971740+starbelly@users.noreply.github.com> Date: Mon, 7 Aug 2023 00:43:06 -0500 Subject: [PATCH] Fix generating search_data.json for undocumented Erlang functions --- lib/ex_doc/formatter/html/search_data.ex | 4 ++++ test/ex_doc/formatter/html/erlang_test.exs | 5 ++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/ex_doc/formatter/html/search_data.ex b/lib/ex_doc/formatter/html/search_data.ex index d081d06d1..1f434c098 100644 --- a/lib/ex_doc/formatter/html/search_data.ex +++ b/lib/ex_doc/formatter/html/search_data.ex @@ -108,6 +108,10 @@ defmodule ExDoc.Formatter.HTML.SearchData do extract_sections_from_markdown(doc) end + defp extract_sections("application/erlang+html", %{rendered_doc: nil}) do + {nil, []} + end + defp extract_sections("application/erlang+html", %{rendered_doc: doc}) do {clean_html(doc), []} end diff --git a/test/ex_doc/formatter/html/erlang_test.exs b/test/ex_doc/formatter/html/erlang_test.exs index 341fdb287..d993c9278 100644 --- a/test/ex_doc/formatter/html/erlang_test.exs +++ b/test/ex_doc/formatter/html/erlang_test.exs @@ -16,7 +16,7 @@ defmodule ExDoc.Formatter.HTML.ErlangTest do %% @doc %% foo module. -module(foo). - -export([foo/1]). + -export([foo/1, bar/0]). -export_type([t/0]). %% @doc @@ -24,6 +24,9 @@ defmodule ExDoc.Formatter.HTML.ErlangTest do -spec foo(atom()) -> atom(). foo(X) -> X. + -spec bar() -> baz. + bar() -> baz. + -type t() :: atom(). %% t/0 type. """)