@@ -158,7 +158,7 @@ defmodule ElixirLS.LanguageServer.Providers.ExecuteCommand.LlmDocsAggregator do
158158 documentation: callback_info [ :documentation ] || "" ,
159159 spec: callback_info [ :spec ] ,
160160 kind: callback_info [ :kind ] ,
161- metadata: callback_info [ :metadata ] || % { }
161+ metadata: format_metadata_section ( callback_info [ :metadata ] )
162162 }
163163 end )
164164
@@ -213,7 +213,7 @@ defmodule ElixirLS.LanguageServer.Providers.ExecuteCommand.LlmDocsAggregator do
213213 % {
214214 type: "moduledoc" ,
215215 content: moduledoc_content ,
216- metadata: moduledoc_metadata
216+ metadata: format_metadata_section ( moduledoc_metadata )
217217 }
218218 else
219219 nil
@@ -255,7 +255,7 @@ defmodule ElixirLS.LanguageServer.Providers.ExecuteCommand.LlmDocsAggregator do
255255 signature: "#{ name } /#{ arity } " ,
256256 doc: nil ,
257257 specs: [ ] ,
258- metadata: % { }
258+ metadata: ""
259259 }
260260 end )
261261
@@ -370,7 +370,7 @@ defmodule ElixirLS.LanguageServer.Providers.ExecuteCommand.LlmDocsAggregator do
370370 % {
371371 module: module_name ,
372372 moduledoc: moduledoc_content ,
373- moduledoc_metadata: moduledoc_metadata ,
373+ moduledoc_metadata: format_metadata_section ( moduledoc_metadata ) ,
374374 functions: functions_list ,
375375 macros: macros_list ,
376376 types: types_list ,
@@ -403,7 +403,7 @@ defmodule ElixirLS.LanguageServer.Providers.ExecuteCommand.LlmDocsAggregator do
403403 arity: doc_arity ,
404404 signature: "#{ function } /#{ doc_arity } " ,
405405 doc: extract_doc ( doc ) ,
406- metadata: metadata ,
406+ metadata: format_metadata_section ( metadata ) ,
407407 specs: Map . get ( specs , { name , doc_arity } , [ ] )
408408 }
409409 end )
@@ -439,7 +439,7 @@ defmodule ElixirLS.LanguageServer.Providers.ExecuteCommand.LlmDocsAggregator do
439439 arity: doc_arity ,
440440 spec: Map . get ( type_specs_by_name_arity , { name , doc_arity } ) ,
441441 documentation: doc_content || "" ,
442- metadata: metadata
442+ metadata: format_metadata_section ( metadata )
443443 }
444444 end )
445445 end
@@ -469,7 +469,7 @@ defmodule ElixirLS.LanguageServer.Providers.ExecuteCommand.LlmDocsAggregator do
469469 signature: format_function_signature ( module , name , arity , metadata ) ,
470470 doc: extract_doc ( doc ) ,
471471 specs: [ ] ,
472- metadata: metadata
472+ metadata: format_metadata_section ( metadata )
473473 }
474474
475475 _ ->
@@ -485,7 +485,7 @@ defmodule ElixirLS.LanguageServer.Providers.ExecuteCommand.LlmDocsAggregator do
485485 type: Atom . to_string ( name ) ,
486486 arity: arity ,
487487 doc: extract_doc ( doc ) ,
488- metadata: metadata
488+ metadata: format_metadata_section ( metadata )
489489 }
490490
491491 _ ->
@@ -501,7 +501,7 @@ defmodule ElixirLS.LanguageServer.Providers.ExecuteCommand.LlmDocsAggregator do
501501 arity: arity ,
502502 kind: kind ,
503503 doc: extract_doc ( doc ) ,
504- metadata: metadata
504+ metadata: format_metadata_section ( metadata )
505505 }
506506
507507 _ ->
@@ -549,11 +549,9 @@ defmodule ElixirLS.LanguageServer.Providers.ExecuteCommand.LlmDocsAggregator do
549549 documentation: extract_doc ( callback_info . doc ) ,
550550 spec: callback_info . callback ,
551551 kind: callback_info . kind ,
552- metadata: callback_info . metadata
552+ metadata: format_metadata_section ( callback_info . metadata )
553553 }
554554
555- callback_result = Map . put ( callback_result , :metadata , callback_info . metadata )
556-
557555 callback_result
558556 end )
559557 end
@@ -687,6 +685,10 @@ defmodule ElixirLS.LanguageServer.Providers.ExecuteCommand.LlmDocsAggregator do
687685 |> Enum . join ( "\n " )
688686 end
689687
688+ defp format_metadata_section ( metadata ) when is_binary ( metadata ) and metadata != "" do
689+ if String . trim ( metadata ) != "" , do: metadata , else: ""
690+ end
691+
690692 defp format_metadata_section ( metadata ) when is_map ( metadata ) and metadata != % { } do
691693 metadata_md = MarkdownUtils . get_metadata_md ( metadata )
692694 if metadata_md != "" , do: "\n \n " <> metadata_md , else: ""
0 commit comments