-
Notifications
You must be signed in to change notification settings - Fork 327
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
Fix some crashes on Erlang docs #1143
Conversation
Hi @erszcz, sorry for delay. These errors happens on edoc app, right? I rebased my branch with master and added a couple workarounds, perhaps they fixed the problem you were running into. I just tested this on OTP 23.0-rc3 and couldn't reproduce it, could you double-check please? |
$ /Users/erszcz/work/elixir-lang/ex_doc/ex_doc edoc "0.11-wip" _build/default/lib/edoc/ebin --main edoc ** (FunctionClauseError) no function clause matching in ExDoc.Autolink.fragment/4 The following arguments were given to ExDoc.Autolink.fragment/4: # 1 :no_tool # 2 :type # 3 :proplist # 4 0 (ex_doc 0.22.0-dev) lib/ex_doc/autolink.ex:418: ExDoc.Autolink.fragment/4 (ex_doc 0.22.0-dev) lib/ex_doc/autolink.ex:314: anonymous fn/6 in ExDoc.Autolink.do_typespec/2 (elixir 1.10.2) lib/regex.ex:733: Regex.apply_list/5 (elixir 1.10.2) lib/regex.ex:728: Regex.apply_list/5 (elixir 1.10.2) lib/regex.ex:670: Regex.do_replace/4 (ex_doc 0.22.0-dev) lib/ex_doc/autolink.ex:321: anonymous fn/6 in ExDoc.Autolink.do_typespec/2 (elixir 1.10.2) lib/regex.ex:733: Regex.apply_list/5 (elixir 1.10.2) lib/regex.ex:728: Regex.apply_list/5
$ $ /Users/erszcz/work/elixir-lang/ex_doc/ex_doc edoc "0.11-wip" _build/default/lib/edoc/ebin --main edoc ... ** (TokenMissingError) nofile:1: missing terminator: end (for "do" starting at line 1) (elixir 1.10.2) lib/code.ex:645: Code.format_string!/2 (ex_doc 0.22.0-dev) lib/ex_doc/autolink.ex:279: ExDoc.Autolink.typespec/2 (elixir 1.10.2) lib/enum.ex:1396: Enum."-map/2-lists^map/1-0-"/2 (ex_doc 0.22.0-dev) lib/ex_doc/formatter/html.ex:86: anonymous fn/5 in ExDoc.Formatter.HTML.render_all/4 (elixir 1.10.2) lib/enum.ex:2111: Enum."-reduce/3-lists^foldl/2-0-"/3 (ex_doc 0.22.0-dev) lib/ex_doc/formatter/html.ex:83: anonymous fn/4 in ExDoc.Formatter.HTML.render_all/4 (elixir 1.10.2) lib/enum.ex:1396: Enum."-map/2-lists^map/1-0-"/2
Hi, @wojtekmach! I've checked again after you rebased and I still had to apply the patches. One of them fixes returning The other one bypasses a call to I'm still working on the chunk format, so it might be the case that I'm outputting something that causes ExDoc to fail while OTP modules at the same time are processed properly. Let's keep this PR open to track necessary fixes and once I'm sure the format is OK, see which of them are still necessary - what do you think? |
how are you generating the docs? I was using this test: https://github.com/elixir-lang/ex_doc/blob/wm-erlang/test/otp_docs_test.exs on 23.0-rc2 with a couple different apps and there were no failures. |
In this particular case it doesn't matter if the chunks are generated by OTP Please have a look at erszcz@2745a06 for extra debugging info. With these extra printouts:
But:
We can't rely only on |
On 5 May 2020, at 15:26, Radek Szymczyszyn ***@***.***> wrote:
We can't rely only on :code.lib_dir() and Erlang module path in the definition of tool/1, because Erlang modules may very well be found outside of the Erlang/OTP installation directory.
That makes sense, thanks!
|
I've found the reason why 8449a69 is necessary. The Rebar3 plugin implements a Here's the raw error with some extra debug info:
|
I've played with the idea of sidestepping Another idea would be to introduce |
what we're planning to do is introduce a defmodule ExDoc.Language.Elixir do
@behaviour ExDoc.Language
@impl true
def format_typespec(ast) do
ast |> Macro.to_string() |> Code.format_string!()
end
end
defmodule ExDoc.Language.Erlang do
@behaviour ExDoc.Language
@impl true
def format_typespec(ast) do
:erl_pp.format(ast)
end
end |
This is superseded by #1291. I'm closing this one. |
Hey, this is a follow up to erlef/documentation-wg#4 (comment). This just fixes the crashes, but might not be a real solution.