Skip to content

Commit

Permalink
Move handling of missing source_line to Elixir backend
Browse files Browse the repository at this point in the history
types and callbacks always have source line numbers
  • Loading branch information
garazdawi committed Dec 21, 2023
1 parent 18a6a88 commit edfdcf2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 22 deletions.
8 changes: 4 additions & 4 deletions lib/ex_doc/language/elixir.ex
Original file line number Diff line number Diff line change
Expand Up @@ -77,16 +77,16 @@ defmodule ExDoc.Language.Elixir do

@impl true
def function_data(entry, module_data) do
{{kind, name, arity}, _anno, _signature, doc_content, metadata} = entry
{{kind, name, arity}, anno, _signature, _doc_content, metadata} = entry

if doc?(entry, module_data.type) do
function_data(kind, name, arity, doc_content, metadata, module_data)
function_data(kind, name, arity, anno, metadata, module_data)
else
:skip
end
end

def function_data(kind, name, arity, _doc_content, metadata, module_data) do
defp function_data(kind, name, arity, anno, metadata, module_data) do
extra_annotations =
case {kind, name, arity} do
{:macro, _, _} -> ["macro"]
Expand All @@ -104,7 +104,7 @@ defmodule ExDoc.Language.Elixir do
delegate_doc_ast(metadata[:delegate_to])
end,
extra_annotations: extra_annotations,
source_line: find_function_line(module_data, actual_def),
source_line: find_function_line(module_data, actual_def) || Source.anno_line(anno),
specs: specs(kind, name, actual_def, module_data)
}
end
Expand Down
21 changes: 3 additions & 18 deletions lib/ex_doc/retriever.ex
Original file line number Diff line number Diff line change
Expand Up @@ -242,13 +242,8 @@ defmodule ExDoc.Retriever do
doc_file = anno_file(anno, source)
doc_line = anno_line(anno)

## When do we not have a source_line?
source_url =
if function_data.source_line do
source_link(function_data[:source_file], source, function_data.source_line)
else
source_link(doc_file, source, doc_line)
end
source_link(function_data[:source_file], source, function_data.source_line)

annotations =
annotations_for_docs.(metadata) ++
Expand Down Expand Up @@ -331,13 +326,8 @@ defmodule ExDoc.Retriever do
doc_file = anno_file(anno, source)
doc_line = anno_line(anno)

## When do we not have a source_line?
source_url =
if callback_data.source_line do
source_link(callback_data[:source_file], source, callback_data.source_line)
else
source_link(doc_file, source, doc_line)
end
source_link(callback_data[:source_file], source, callback_data.source_line)

signature = signature(callback_data.signature)
specs = callback_data.specs
Expand Down Expand Up @@ -395,13 +385,8 @@ defmodule ExDoc.Retriever do

type_data = module_data.language.type_data(type_entry, module_data)

## When do we not have a source_line?
source_url =
if type_data.source_line do
source_link(type_data[:source_file], source, type_data.source_line)
else
source_link(doc_file, source, doc_line)
end
source_link(type_data[:source_file], source, type_data.source_line)

annotations = annotations_from_metadata(metadata, module_metadata)

Expand Down

0 comments on commit edfdcf2

Please sign in to comment.