Raxol. Docs. ProseLint
(Raxol v2.9.2)
View Source
House prose rules for Markdown, as pure functions over file contents.
The rules encode style decisions that were previously enforced by hand and
kept regressing: three separate sweeps removed em-dashes from docs/ and each
time they came back, and the sweep that cleaned docs/ never covered
packages/ at all. A rule that lives in a checker cannot have that scope gap.
Three rules run by default, all errors:
:unicode_punctuation- em-dash, en-dash, and curly quotes. House style is ASCII (seedocs/development/ASCII_STANDARDS.md).:prose_dash---used as an em-dash substitute. Fenced code, inline code spans, and all-dash table cells are exempt, so CLI flags (mix ... -- --quick), Lua comments, and| -- |placeholders pass.:broken_link- a relative Markdown link whose target file or#anchordoes not resolve.
A fourth rule, :heading_case, is opt-in via headings: true and reports
warnings. It cannot be a default: distinguishing a Title Case heading from a
proper noun needs a dictionary, and on this repo the naive form flagged
## The Elm Architecture (TEA) and ### Stage 3: Output generation. It fires
only when every alphabetic word in the heading is capitalized and one of them
is in @title_case_words, which keeps it useful for a sweep without making the
default run noisy enough to ignore.
check_file/2 returns findings; the caller decides what is fatal.
Summary
Functions
Lint already-read content. Split out so tests do not touch disk.
Lint one Markdown file.
Check the relative documentation links inside a source file's @moduledoc
and @doc strings.
Render findings as display lines, two per finding (location, then the text).
Lint a list of candidate paths, keeping only the Markdown this repo owns.
Types
@type finding() :: %{ path: String.t(), line: pos_integer(), rule: atom(), severity: :error | :warning, message: String.t(), text: String.t() }
Functions
Lint already-read content. Split out so tests do not touch disk.
Lint one Markdown file.
Options: :root (repository root the path is relative to, default ".") and
:headings (run the opt-in heading-case rule, default false).
Check the relative documentation links inside a source file's @moduledoc
and @doc strings.
Moduledocs were unchecked, which is how Raxol.Telegram.Guardian shipped a
link four levels up that lands in packages/ rather than the repo root.
Nothing rendered it there either: a moduledoc is not displayed on a source
page, so the only reader who ever follows one of these is on hexdocs.
That makes ExDoc's resolution the rule. ExDoc rewrites a relative link only
when it names one of the app's configured :extras, matched by the extra's
repo-root-relative source path. So a valid link is one written exactly that
way, and two shapes are always broken:
- a
../-style path, which no extras entry can match, and - a path outside the package that owns the file, which cannot be an extra of that package because it does not ship in it.
Only path-like targets are considered (containing / or ending in .md).
Doc strings are full of bracket-and-paren text that is not a link at all --
CSS :after, \d+, [^/]+ -- and flagging those would make the rule noise.
Render findings as display lines, two per finding (location, then the text).
Returns lines rather than printing them so the Mix task can route them
through Mix.shell/0 and the hook script can put them on stderr.
Lint a list of candidate paths, keeping only the Markdown this repo owns.
Drops non-.md paths, node_modules/, and vendored copies, then sorts by
{path, line} so output is stable regardless of the order paths arrive in.
Lives here rather than in the Mix task because two entry points need it: the
task, and scripts/prose_lint.exs, which the pre-commit hook runs WITHOUT
Mix. Keeping selection next to the rules means the hook and CI cannot come to
different conclusions about which files are in scope.