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

Add edoc_parse_enabled to config #1464

Merged
merged 2 commits into from
Dec 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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: 2 additions & 0 deletions apps/els_core/src/els_config.erl
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ do_initialize(RootUri, Capabilities, InitOptions, {ConfigPath, Config}) ->

RefactorErl = maps:get("refactorerl", Config, notconfigured),
Providers = maps:get("providers", Config, #{}),
EdocParseEnabled = maps:get("edoc_parse_enabled", Config, true),

%% Initialize and start Wrangler
case maps:get("wrangler", Config, notconfigured) of
Expand Down Expand Up @@ -236,6 +237,7 @@ do_initialize(RootUri, Capabilities, InitOptions, {ConfigPath, Config}) ->
ok = set(elvis_config_path, ElvisConfigPath),
ok = set(compiler_telemetry_enabled, CompilerTelemetryEnabled),
ok = set(edoc_custom_tags, EDocCustomTags),
ok = set(edoc_parse_enabled, EdocParseEnabled),
ok = set(incremental_sync, IncrementalSync),
ok = set(
indexing,
Expand Down
6 changes: 3 additions & 3 deletions apps/els_core/src/els_dodger.erl
Original file line number Diff line number Diff line change
Expand Up @@ -567,7 +567,7 @@ quickscan_form([{'-', _L}, {'if', La} | _Ts]) ->
kill_form(La);
quickscan_form([{'-', _L}, {atom, La, elif} | _Ts]) ->
kill_form(La);
quickscan_form([{'-', _L}, {atom, La, else} | _Ts]) ->
quickscan_form([{'-', _L}, {atom, La, 'else'} | _Ts]) ->
kill_form(La);
quickscan_form([{'-', _L}, {atom, La, endif} | _Ts]) ->
kill_form(La);
Expand Down Expand Up @@ -791,13 +791,13 @@ scan_form([{'-', _L}, {atom, La, elif} | Ts], Opt) ->
{atom, La, 'elif'}
| scan_macros(Ts, Opt)
];
scan_form([{'-', _L}, {atom, La, else} | Ts], Opt) ->
scan_form([{'-', _L}, {atom, La, 'else'} | Ts], Opt) ->
[
{atom, La, ?pp_form},
{'(', La},
{')', La},
{'->', La},
{atom, La, else}
{atom, La, 'else'}
| scan_macros(Ts, Opt)
];
scan_form([{'-', _L}, {atom, La, endif} | Ts], Opt) ->
Expand Down
54 changes: 39 additions & 15 deletions apps/els_lsp/src/els_docs.erl
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
-type application_type() :: 'local' | 'remote'.

%%==============================================================================
%% Dialyer Ignores (due to upstream bug, see ERL-1262
%% Dialyzer Ignores (due to upstream bug, see ERL-1262
%%==============================================================================
-dialyzer({nowarn_function, function_docs/4}).

Expand Down Expand Up @@ -103,18 +103,33 @@ docs(_M, _POI) ->
-spec function_docs(application_type(), atom(), atom(), non_neg_integer()) ->
[els_markup_content:doc_entry()].
function_docs(Type, M, F, A) ->
%% call via ?MODULE to enable mocking in tests
case ?MODULE:eep48_docs(function, M, F, A) of
{ok, Docs} ->
[{text, Docs}];
{error, not_available} ->
%% We cannot fetch the EEP-48 style docs, so instead we create
%% something similar using the tools we have.
case edoc_parse_enabled() of
true ->
%% call via ?MODULE to enable mocking in tests
case ?MODULE:eep48_docs(function, M, F, A) of
{ok, Docs} ->
[{text, Docs}];
{error, not_available} ->
%% We cannot fetch the EEP-48 style docs, so instead we create
%% something similar using the tools we have.
Sig = {h2, signature(Type, M, F, A)},
L = [
function_clauses(M, F, A),
specs(M, F, A),
edoc(M, F, A)
],
case lists:append(L) of
[] ->
[Sig];
Docs ->
[Sig, {text, "---"} | Docs]
end
end;
false ->
Sig = {h2, signature(Type, M, F, A)},
L = [
function_clauses(M, F, A),
specs(M, F, A),
edoc(M, F, A)
specs(M, F, A)
],
case lists:append(L) of
[] ->
Expand All @@ -127,11 +142,16 @@ function_docs(Type, M, F, A) ->
-spec type_docs(application_type(), atom(), atom(), non_neg_integer()) ->
[els_markup_content:doc_entry()].
type_docs(_Type, M, F, A) ->
%% call via ?MODULE to enable mocking in tests
case ?MODULE:eep48_docs(type, M, F, A) of
{ok, Docs} ->
[{text, Docs}];
{error, not_available} ->
case edoc_parse_enabled() of
true ->
%% call via ?MODULE to enable mocking in tests
case ?MODULE:eep48_docs(type, M, F, A) of
{ok, Docs} ->
[{text, Docs}];
{error, not_available} ->
type(M, F, A)
end;
false ->
type(M, F, A)
end.

Expand Down Expand Up @@ -495,3 +515,7 @@ spawn_group_proxy(Acc) ->
M ->
spawn_group_proxy([M | Acc])
end.

-spec edoc_parse_enabled() -> boolean().
edoc_parse_enabled() ->
true == els_config:get(edoc_parse_enabled).
Loading