Skip to content

Commit 009bc89

Browse files
committed
Use clearer name on ExDoc.DocAST
1 parent 99d61c2 commit 009bc89

File tree

3 files changed

+8
-9
lines changed

3 files changed

+8
-9
lines changed

lib/ex_doc/doc_ast.ex

+6-8
Original file line numberDiff line numberDiff line change
@@ -113,19 +113,16 @@ defmodule ExDoc.DocAST do
113113
@doc """
114114
Returns text content from the given AST.
115115
"""
116-
def text_from_ast(ast) do
116+
def text(ast) do
117117
ast
118-
|> do_text_from_ast()
118+
|> do_text()
119119
|> IO.iodata_to_binary()
120120
|> String.trim()
121121
end
122122

123-
def do_text_from_ast(ast) when is_list(ast) do
124-
Enum.map(ast, &do_text_from_ast/1)
125-
end
126-
127-
def do_text_from_ast(ast) when is_binary(ast), do: ast
128-
def do_text_from_ast({_tag, _attr, ast, _meta}), do: text_from_ast(ast)
123+
defp do_text(ast) when is_list(ast), do: Enum.map(ast, &do_text/1)
124+
defp do_text(ast) when is_binary(ast), do: ast
125+
defp do_text({_tag, _attr, ast, _meta}), do: text(ast)
129126

130127
@doc """
131128
Wraps a list of HTML nodes into `<section>` tags whenever `matcher` returns true.
@@ -160,6 +157,7 @@ defmodule ExDoc.DocAST do
160157
@doc """
161158
Highlights a DocAST converted to string.
162159
"""
160+
# TODO: Could this be done over the AST instead?
163161
def highlight(html, language, opts \\ []) do
164162
highlight_info = language.highlight_info()
165163

lib/ex_doc/formatter/html.ex

+1-1
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,7 @@ defmodule ExDoc.Formatter.HTML do
422422
:error -> {nil, ast}
423423
end
424424

425-
title_text = title_ast && ExDoc.DocAST.text_from_ast(title_ast)
425+
title_text = title_ast && ExDoc.DocAST.text(title_ast)
426426
title_html = title_ast && ExDoc.DocAST.to_string(title_ast)
427427
content_html = autolink_and_render(ast, language, [file: input] ++ autolink_opts, opts)
428428

lib/ex_doc/formatter/html/search_data.ex

+1
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ defmodule ExDoc.Formatter.HTML.SearchData do
117117
}
118118
end
119119

120+
# TODO: Perform this via DocAST and remove doc_format (and perhaps source_doc)
120121
defp extract_sections("text/markdown", %{source_doc: %{"en" => doc}}) do
121122
extract_sections_from_markdown(doc)
122123
end

0 commit comments

Comments
 (0)