Credence.Pattern.PreferHeredocForMultiLineDoc
(credence v0.4.2)
Copy Markdown
Detects @doc, @moduledoc, and @typedoc strings that contain
escaped newlines (\n) and should use heredoc syntax instead.
LLMs generate documentation as single-line strings with \n escapes
because that's how Python docstrings work. In Elixir, multi-line
documentation should use the heredoc (""") syntax for readability.
Bad
@doc "Finds the second largest number in a list.\nThe list must have at least two distinct values.\n"Good
@doc """
Finds the second largest number in a list.
The list must have at least two distinct values.
"""Auto-fix
Converts single-line @doc/@moduledoc/@typedoc strings containing
\n escapes into heredoc format. The fixer preserves indentation and
strips unnecessary trailing \n (since heredocs naturally end with a
newline). Strings containing \"\"\" are left unchanged.