Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Eep 48 markdown #1100

Merged
merged 33 commits into from
Oct 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
d33f099
Vendor Erlang/OTP shell_docs rendering
garazdawi Oct 1, 2021
ddc37bd
Implement markdown rendering
garazdawi Oct 1, 2021
0d7ab9d
Add lookup of docs for types and use edoc chunks
garazdawi Oct 4, 2021
56b6ba9
Add eep48 to elvis ignore list
garazdawi Oct 5, 2021
046f76e
Fix compilation before Erlang/OTP 23
garazdawi Oct 5, 2021
c2012ea
Fix dialyzer error
garazdawi Oct 5, 2021
ac75964
Fix a bunch of doc rendering issues
garazdawi Oct 5, 2021
40a2280
Fix Erlang/OTP < 23 dialyzer issue
garazdawi Oct 5, 2021
c583613
Introduce local group_leader for doc to capture output
garazdawi Oct 7, 2021
f1cfe5b
Add els_utils:find_modules for fetching all variants of a module
garazdawi Oct 8, 2021
f98d438
Build edoc doc-chunks in user cache directory
garazdawi Oct 8, 2021
317d385
Check all variants of a module for docs before generating
garazdawi Oct 8, 2021
4efb101
Remove dead markup
garazdawi Oct 8, 2021
95aec6c
Polish fetching of type documentation
garazdawi Oct 8, 2021
773ae3e
Do not include private functions when generating edoc
garazdawi Oct 8, 2021
43c0750
Do not generate hr if no other docs are to be shown
garazdawi Oct 8, 2021
41c079e
Fix testcases
garazdawi Oct 8, 2021
b62dcd0
Change -type poi location and create poi for builtin types
garazdawi Oct 8, 2021
a75d9e4
Include type docs in completion
garazdawi Oct 17, 2021
3607c8b
Fix crash when macro definition cannot be found
garazdawi Oct 18, 2021
0fb84e4
Indentation fix
garazdawi Oct 18, 2021
92fa84f
Remove dead code from eep48 module
garazdawi Oct 18, 2021
9156248
Do not render docs for functions/types with none docs
garazdawi Oct 18, 2021
ae61200
Fix completion testcases
garazdawi Oct 18, 2021
a0fa304
Fix testcases
garazdawi Oct 20, 2021
7b705a4
Add specs to all els_eep48 functions
garazdawi Oct 23, 2021
77bd8c7
Fix rename of opaque types
garazdawi Oct 23, 2021
6b9c1ba
Add rename_opaque testcase
garazdawi Oct 23, 2021
736006a
Add testing of edoc completion docs
garazdawi Oct 24, 2021
a84d93f
Fix sending of unicode text in els_client
garazdawi Oct 24, 2021
e854f2e
Expand testing of documentation for completion items
garazdawi Oct 24, 2021
bb57290
Added test for hover documentation
garazdawi Oct 24, 2021
923b5dc
Fix line length issues
garazdawi Oct 25, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/els_core/src/els_stdio.erl
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ init({Cb, IoDevice}) ->

-spec send(atom() | pid(), binary()) -> ok.
send(IoDevice, Payload) ->
io:format(IoDevice, "~s", [Payload]).
io:format(IoDevice, "~ts", [Payload]).

%%==============================================================================
%% Listener loop function
Expand Down
27 changes: 19 additions & 8 deletions apps/els_core/src/els_utils.erl
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
, filename_to_atom/1
, find_header/1
, find_module/1
, find_modules/1
, fold_files/4
, halt/1
, lookup_document/1
Expand Down Expand Up @@ -113,16 +114,26 @@ find_header(Id) ->
%% @doc Look for a module in the DB
-spec find_module(atom()) -> {ok, uri()} | {error, any()}.
find_module(Id) ->
case find_modules(Id) of
{ok, [Uri | _]} ->
{ok, Uri};
Else ->
Else
end.

%% @doc Look for all versions of a module in the DB
-spec find_modules(atom()) -> {ok, [uri()]} | {error, any()}.
find_modules(Id) ->
{ok, Candidates} = els_dt_document_index:lookup(Id),
case [Uri || #{kind := module, uri := Uri} <- Candidates] of
[Uri] ->
{ok, Uri};
[_|_] = Uris ->
[Uri|_] = prioritize_uris(Uris),
{ok, Uri};
[] ->
FileName = atom_to_list(Id) ++ ".erl",
els_indexing:find_and_index_file(FileName)
[] ->
FileName = atom_to_list(Id) ++ ".erl",
case els_indexing:find_and_index_file(FileName) of
{ok, Uri} -> {ok, [Uri]};
Error -> Error
end;
Uris ->
{ok, prioritize_uris(Uris)}
end.

%% @doc Look for a document in the DB.
Expand Down
11 changes: 7 additions & 4 deletions apps/els_lsp/priv/code_navigation/src/completion_resolve.erl
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
-module(completion_resolve).

-export([ call_1/0
, call_2/0
, main/0
]).

%% @doc Call me maybe
-spec call_1() -> 'ok'.
call_1() ->
ok.

call_2() ->
ok.

main() ->
completion_resolve:call_1(),
call_1(),
completion_resolve_2:call_1(),
file:write(a, b),
ok.

%% @doc Call me sometime
-spec call_2() -> 'ok'.
call_2() ->
ok.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

-export([ call_1/0 ]).

%% @doc I just met you
-spec call_1() -> 'ok'.
call_1() ->
ok.
20 changes: 20 additions & 0 deletions apps/els_lsp/priv/code_navigation/src/completion_resolve_type.erl
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
-module(completion_resolve).

-export([ call_3/3
]).

-opaque myopaque() :: term().
%% This is my opaque

-type mytype() :: completion_resolve_type:myopaque().
%% This is my type

-export_type([myopaque/0]).

-spec call_3({mytype(), completion_resolve_type:myopaque()},
completion_resolve_type_2:mytype(list()),
completion_resolve_type_2:myopaque(list())) ->
file:name_all().
call_3(_A, _B, _C) ->
ok.

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
-module(completion_resolve_2).

-type mytype(T) :: [T].
%% Hello
-opaque myopaque(T) :: [T].
%% Is there anybody in there

-export_type([mytype/1,myopaque/1]).
6 changes: 5 additions & 1 deletion apps/els_lsp/priv/code_navigation/src/hover_docs.erl
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
-module(hover_docs).

-export([ multiple_clauses/1 ]).
-export([ multiple_clauses/1, edoc/0 ]).

multiple_clauses(L) when is_list(L) ->
42;
multiple_clauses(#{data := Data}) ->
Data;
multiple_clauses(X) ->
X - 12.

%% @doc An edoc hover item
-spec edoc() -> ok.
edoc() -> ok.
13 changes: 13 additions & 0 deletions apps/els_lsp/priv/code_navigation/src/hover_docs_caller.erl
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,23 @@ implicit_funs() ->
{fun local_call/2,
fun hover_docs:multiple_clauses/1}.

remote_call_edoc() ->
hover_docs:edoc().

remote_call_otp() ->
file:write(a, b).

local_call_edoc() ->
edoc().

local_call() ->
ok.

-spec local_call(integer(), any()) -> tuple();
(float(), any()) -> tuple().
local_call(Arg1, Arg2) ->
{Arg1, Arg2}.

%% @doc An edoc hover item
-spec edoc() -> ok.
edoc() -> ok.
24 changes: 24 additions & 0 deletions apps/els_lsp/priv/code_navigation/src/hover_type.erl
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
-module(hover_type).

-type type_a() :: any().
-opaque opaque_type_a() :: any().

-spec f(type_a()) -> ok.
f(_) ->
ok.

-spec g(hover_type_remote:type_a()) -> ok.
g(_) ->
ok.

-spec h(opaque_type_a()) -> ok.
h(_) ->
ok.

-spec i(hover_type_remote:opaque_type_a()) -> ok.
i(_) ->
ok.

-spec j(doesnt:exist()) -> ok.
j(_) ->
ok.
9 changes: 9 additions & 0 deletions apps/els_lsp/priv/code_navigation/src/hover_type_remote.erl
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
-module(hover_type_remote).

-type type_a() :: atom().

-export_type([ type_a/0 ]).

-opaque opaque_type_a() :: atom().

-export_type([ opaque_type_a/0 ]).
18 changes: 18 additions & 0 deletions apps/els_lsp/src/els_completion_provider.erl
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,17 @@ resolve(#{ <<"kind">> := ?COMPLETION_ITEM_KIND_FUNCTION
, binary_to_atom(Function, utf8)
, Arity),
CompletionItem#{documentation => els_markup_content:new(Entries)};
resolve(#{ <<"kind">> := ?COMPLETION_ITEM_KIND_TYPE_PARAM
, <<"data">> := #{ <<"module">> := Module
, <<"type">> := Type
, <<"arity">> := Arity
}
} = CompletionItem) ->
Entries = els_docs:type_docs('remote'
, binary_to_atom(Module, utf8)
, binary_to_atom(Type, utf8)
, Arity),
CompletionItem#{ documentation => els_markup_content:new(Entries) };
resolve(CompletionItem) ->
CompletionItem.

Expand Down Expand Up @@ -511,6 +522,13 @@ resolve_definition(Uri, #{kind := 'function', id := {F, A}} = POI, ArityOnly) ->
, <<"arity">> => A
},
completion_item(POI, Data, ArityOnly);
resolve_definition(Uri, #{kind := 'type_definition', id := {T, A}} = POI,
ArityOnly) ->
Data = #{ <<"module">> => els_uri:module(Uri)
, <<"type">> => T
, <<"arity">> => A
},
completion_item(POI, Data, ArityOnly);
resolve_definition(_Uri, POI, ArityOnly) ->
completion_item(POI, ArityOnly).

Expand Down
Loading