Skip to content

Commit

Permalink
Fix mix task autolink for tasks with underscores (#1898)
Browse files Browse the repository at this point in the history
  • Loading branch information
zachdaniel authored May 1, 2024
1 parent f8075a3 commit fdace93
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/ex_doc/autolink.ex
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ defmodule ExDoc.Autolink do

defp mix_task(name, string, mode, config) do
{module, url, visibility} =
if name =~ ~r/^[a-z][a-z0-9]*(\.[a-z][a-z0-9]*)*$/ do
if name =~ ~r/^[a-z][a-z0-9_]*(\.[a-z][a-z0-9_]*)*$/ do
parts = name |> String.split(".") |> Enum.map(&Macro.camelize/1)
module = Module.concat([Mix, Tasks | parts])

Expand Down
3 changes: 3 additions & 0 deletions test/ex_doc/language/elixir_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,9 @@ defmodule ExDoc.Language.ElixirTest do
assert autolink_doc("`mix compile.elixir`") ==
~s|<a href="https://hexdocs.pm/mix/Mix.Tasks.Compile.Elixir.html"><code class="inline">mix compile.elixir</code></a>|

assert autolink_doc("`mix task_with_docs`") ==
~s|<a href=\"Mix.Tasks.TaskWithDocs.html\"><code class=\"inline\">mix task_with_docs</code></a>|

assert autolink_doc("`mix help compile.elixir`") ==
~s|<a href="https://hexdocs.pm/mix/Mix.Tasks.Compile.Elixir.html"><code class="inline">mix help compile.elixir</code></a>|

Expand Down

0 comments on commit fdace93

Please sign in to comment.