Skip to content

fix: declare ex_doc as an optional dependency of the validator - #91

Merged
zachdaniel merged 1 commit into
ash-project:mainfrom
leonqadirie:fix/ex-doc-optional-dep
Oct 27, 2026
Merged

zachdaniel merged 1 commit into
ash-project:mainfrom
leonqadirie:fix/ex-doc-optional-dep

Conversation

@leonqadirie

@leonqadirie leonqadirie commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

UsageRules.Validator checks for ex_doc at compile time and uses formatter APIs introduced in ex_doc 0.40. Declaring ex_doc with only: [:dev, :test] hid this dependency from consumers, causing two failures:

  • Mix could compile usage_rules first, baking in the stub validate/1. Adding ex_doc later did not trigger recompilation, so validation failed with a misleading :earmark_parser_unavailable error until usage_rules was forcibly recompiled.
  • Consumers could use an older ex_doc version, causing an UndefinedFunctionError instead of an actionable error.

Declaring {:ex_doc, "~> 0.40", optional: true, runtime: false} gives Mix the dependency information needed for compilation and recompilation, and lets Hex reject incompatible ex_doc versions during mix deps.get. It also keeps ex_doc out of application startup.

ensure_ex_doc!/1 now recommends ~> 0.40. mix.lock is unchanged.

The validator branches on ex_doc's presence at usage_rules' own compile
time, but ex_doc was declared only: [:dev, :test], which does not
propagate to consumers. Two failures followed:

* Mix could compile usage_rules before ex_doc, baking in the stub
  validate/1; adding ex_doc later never triggered a recompile, so
  mix usage_rules.validate kept failing with a misleading
  :earmark_parser_unavailable error until a forced recompile.
* Consumers inherited no ex_doc version constraint, so an ex_doc
  without the 0.40 formatter API (ExDoc.Extras.build/2,
  ExDoc.Formatter.autolink/5) crashed at runtime with
  UndefinedFunctionError instead of an actionable message.

Declaring {:ex_doc, "~> 0.40", optional: true, runtime: false} fixes
both: Mix compiles ex_doc before usage_rules and recompiles usage_rules
when ex_doc is added, and the Hex resolver enforces the ~> 0.40 floor
for any consumer that also depends on ex_doc.
@leonqadirie
leonqadirie marked this pull request as ready for review October 27, 2026 16:46
@zachdaniel
zachdaniel merged commit f99cdbf into ash-project:main Oct 27, 2026
26 checks passed
@zachdaniel

Copy link
Copy Markdown
Contributor

🚀 Thank you for your contribution! 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants