Skip to content

Conversation

@ruslandoga
Copy link
Contributor

@ruslandoga ruslandoga commented May 30, 2024


assert html =~
~s|-type</span> t() :: <a href=\"https://www.erlang.org/doc/man/erlang.html#t:atom/0\">atom</a>().|
~s|-type</span> t() :: <a href="https://www.erlang.org/doc/apps/erts/erlang.html#t:atom/0">atom</a>().|
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


assert html =~
~s|-type</span> t2() :: #rec{k1 :: <a href=\"https://www.erlang.org/doc/man/uri_string.html#t:uri_string/0\">uri_string:uri_string</a>(), k2 :: <a href=\"https://www.erlang.org/doc/man/uri_string.html#t:uri_string/0\">uri_string:uri_string</a>() \| undefined}.|
~s|-type</span> t2() :: #rec{k1 :: <a href="https://www.erlang.org/doc/apps/stdlib/uri_string.html#t:uri_string/0">uri_string:uri_string</a>(), k2 :: <a href="https://www.erlang.org/doc/apps/stdlib/uri_string.html#t:uri_string/0">uri_string:uri_string</a>() \| undefined}.|
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

test "m:module with Erlang module" do
assert autolink_doc("`m::array`") ==
~s|<a href="https://www.erlang.org/doc/man/array.html"><code class="inline">:array</code></a>|
~s|<a href="https://www.erlang.org/doc/apps/stdlib/array.html"><code class="inline">:array</code></a>|
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

test "erlang stdlib function" do
assert autolink_doc("`:lists.all/2`") ==
~s|<a href="https://www.erlang.org/doc/man/lists.html#all/2"><code class="inline">:lists.all/2</code></a>|
~s|<a href="https://www.erlang.org/doc/apps/stdlib/lists.html#all/2"><code class="inline">:lists.all/2</code></a>|
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

test "m:module with Erlang module and fragment" do
assert autolink_doc("`m::array#fragment`") ==
~s|<a href="https://www.erlang.org/doc/man/array.html#fragment"><code class="inline">:array</code></a>|
~s|<a href="https://www.erlang.org/doc/apps/stdlib/array.html#fragment"><code class="inline">:array</code></a>|
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And this is good as well. :) I checked, I just didn't comment. My bad. :)

test "erlang callback" do
assert autolink_doc("`c::gen_server.handle_call/3`") ==
~s|<a href="https://www.erlang.org/doc/man/gen_server.html#c:handle_call/3"><code class="inline">:gen_server.handle_call/3</code></a>|
~s|<a href="https://www.erlang.org/doc/apps/stdlib/gen_server.html#c:handle_call/3"><code class="inline">:gen_server.handle_call/3</code></a>|
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

test "OTP module", c do
assert autolink_extra("`m:rpc`", c) ==
~s|<a href="https://www.erlang.org/doc/man/rpc.html"><code class="inline">rpc</code></a>|
~s|<a href="https://www.erlang.org/doc/apps/kernel/rpc.html"><code class="inline">rpc</code></a>|
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

~s|record(<a href="https://www.erlang.org/doc/man/erlang.html#t:module/0">module</a>())| <>
~s| -> [[{<a href="https://www.erlang.org/doc/man/erlang.html#t:module/0">module</a>(),| <>
~s| <a href="https://www.erlang.org/doc/man/erlang.html#t:atom/0">atom</a>()}]].|
~s|record(<a href="https://www.erlang.org/doc/apps/erts/erlang.html#t:module/0">module</a>())| <>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

c
) ==
~S|foo() -> #{<a href="https://www.erlang.org/doc/man/erlang.html#t:atom/0">atom</a>() := <a href="https://www.erlang.org/doc/man/sets.html#t:set/1">sets:set</a>(<a href="https://www.erlang.org/doc/man/erlang.html#t:integer/0">integer</a>()), <a href="https://www.erlang.org/doc/man/erlang.html#t:float/0">float</a>() => <a href="#t:t/0">t</a>()}.|
~S|foo() -> #{<a href="https://www.erlang.org/doc/apps/erts/erlang.html#t:atom/0">atom</a>() := <a href="https://www.erlang.org/doc/apps/stdlib/sets.html#t:set/1">sets:set</a>(<a href="https://www.erlang.org/doc/apps/erts/erlang.html#t:integer/0">integer</a>()), <a href="https://www.erlang.org/doc/apps/erts/erlang.html#t:float/0">float</a>() => <a href="#t:t/0">t</a>()}.|
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

test "OTP private type", c do
assert autolink_spec(~S"-spec foo() -> array:array_indx().", c) ==
~s|foo() -> <a href="https://www.erlang.org/doc/man/array.html#t:array_indx/0">array:array_indx</a>().|
~s|foo() -> <a href="https://www.erlang.org/doc/apps/stdlib/array.html#t:array_indx/0">array:array_indx</a>().|
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

assert function1.doc_file =~ "mod.erl"

assert Erlang.autolink_spec(hd(function1.specs), current_kfa: {:function, :function1, 0}) ==
"function1() -> <a href=\"https://www.erlang.org/doc/man/erlang.html#type-atom\">atom</a>()."
Copy link
Contributor Author

@ruslandoga ruslandoga May 30, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These links weren't updated in the previous PR since I missed these EEP 0059 tests. I still can't make them run with my Erlang installation, (I installed Erlang 27.0 with docs and now these tests are included)

And it doesn't seem like CI is running them either since they passed when they shouldn't have in the prev PR. I guess CI needs Erlang 27.0 for these tests to run?

Copy link
Contributor Author

@ruslandoga ruslandoga May 30, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some of the tests are failing for me locally:

$ elixir -v
Erlang/OTP 27 [erts-15.0] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] [jit]

Elixir 1.17.0-rc.0 (a2600ea) (compiled with Erlang/OTP 27)

$ mix test test/ex_doc/retriever/erlang_test.exs 
Running ExUnit with seed: 710493, max_cases: 16

.

  1) test docs_from_modules/2 types (ExDoc.Retriever.ErlangTest)
     test/ex_doc/retriever/erlang_test.exs:274
     Assertion with == failed
     code:  assert type1.spec |> Erlang.autolink_spec(current_kfa: {:type, :type1, 0}) ==
              "type1() :: <a href=\"https://www.erlang.org/doc/man/erlang.html#type-atom\">atom</a>()."
     left:  "type1() :: <a href=\"https://www.erlang.org/doc/apps/erts/erlang.html#t:atom/0\">atom</a>()."
     right: "type1() :: <a href=\"https://www.erlang.org/doc/man/erlang.html#type-atom\">atom</a>()."
     stacktrace:
       test/ex_doc/retriever/erlang_test.exs:308: (test)

.

  2) test docs_from_modules/2 function with no docs is generated (ExDoc.Retriever.ErlangTest)
     test/ex_doc/retriever/erlang_test.exs:216
     ** (MatchError) no match of right hand side value: {[], []}
     code: {[mod], []} = Retriever.docs_from_modules([:mod], %ExDoc.Config{})
     stacktrace:
       test/ex_doc/retriever/erlang_test.exs:224: (test)

....

  3) test docs_from_modules/2 module with no docs is generated (ExDoc.Retriever.ErlangTest)
     test/ex_doc/retriever/erlang_test.exs:11
     match (=) failed
     code:  assert {[_], []} = Retriever.docs_from_modules([:mod], %ExDoc.Config{})
     left:  {[_], []}
     right: {[], []}
     stacktrace:
       test/ex_doc/retriever/erlang_test.exs:16: (test)

.

  4) test docs_from_modules/2 records (ExDoc.Retriever.ErlangTest)
     test/ex_doc/retriever/erlang_test.exs:318
     ** (MatchError) no match of right hand side value: {[], []}
     code: {[mod], []} = Retriever.docs_from_modules([:mod], config)
     stacktrace:
       test/ex_doc/retriever/erlang_test.exs:337: (test)

.
Finished in 0.4 seconds (0.4s async, 0.00s sync)
12 tests, 4 failures

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They passed for me here but I am running against Erlang main. I will try to reproduce on a 27 release later!

@ruslandoga ruslandoga marked this pull request as ready for review May 30, 2024 10:35
@josevalim josevalim merged commit d1b0950 into elixir-lang:main May 30, 2024
@josevalim
Copy link
Member

💚 💙 💜 💛 ❤️

@ruslandoga ruslandoga deleted the otp-remove-man branch May 30, 2024 12:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants