Skip to content

Commit 9ba02a6

Browse files
committed
Link to the credo docs when app is not credo
1 parent 151becb commit 9ba02a6

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

lib/credo/check.ex

+9-6
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ defmodule Credo.Check do
339339
end
340340
end
341341

342-
module_doc = moduledoc(opts, __CALLER__.module)
342+
module_doc = moduledoc(opts, __CALLER__.module, Mix.Project.config()[:app])
343343

344344
quote do
345345
@moduledoc unquote(module_doc)
@@ -503,7 +503,7 @@ defmodule Credo.Check do
503503
end
504504
end
505505

506-
defp moduledoc(opts, module) do
506+
defp moduledoc(opts, module, app) do
507507
explanations = opts[:explanations]
508508

509509
base_priority = opts_to_string(opts[:base_priority]) || 0
@@ -526,13 +526,13 @@ defmodule Credo.Check do
526526
"""
527527
> #### This check is enabled by default. {: .tip}
528528
>
529-
> [Learn how to disable it](config_file.html#checks) via `.credo.exs`.
529+
> [Learn how to disable it](#{credo_docs_uri(app, "config_file.html#checks")}) via `.credo.exs`.
530530
"""
531531
else
532532
"""
533533
> #### This check is disabled by default. {: .neutral}
534534
>
535-
> [Learn how to enable it](config_file.html#checks) via `.credo.exs`.
535+
> [Learn how to enable it](#{credo_docs_uri(app, "config_file.html#checks")}) via `.credo.exs`.
536536
"""
537537
end
538538

@@ -613,12 +613,15 @@ defmodule Credo.Check do
613613
614614
## General Parameters
615615
616-
Like with all checks, [general params](check_params.html) can be applied.
616+
Like with all checks, [general params](#{credo_docs_uri(app, "check_params.html")}) can be applied.
617617
618-
Parameters can be configured via the [`.credo.exs` config file](config_file.html).
618+
Parameters can be configured via the [`.credo.exs` config file](#{credo_docs_uri(app, "config_file.html")}).
619619
"""
620620
end
621621

622+
defp credo_docs_uri(:credo, path), do: path
623+
defp credo_docs_uri(_other_app, path), do: "`e:credo:#{path}`"
624+
622625
defp opts_to_string(value) do
623626
{result, _} =
624627
value

0 commit comments

Comments
 (0)