Skip to content

Docs updates for .ex/.exs plugin behavior - #15809

Merged
josevalim merged 4 commits into
elixir-lang:mainfrom
evnp:format-ex-exs-plugins-docs-and-test-updates
Aug 29, 2026
Merged

Docs updates for .ex/.exs plugin behavior#15809
josevalim merged 4 commits into
elixir-lang:mainfrom
evnp:format-ex-exs-plugins-docs-and-test-updates

Conversation

@evnp

@evnp evnp commented Aug 29, 2026

Copy link
Copy Markdown
Contributor

This adds a section to Mix Format docs based on discussion here: #15742

I believe this is helpful because the current behavior of mix format seems a bit unintuitive when it comes to plugins targeting .ex/.exs file types. I had read the docs thoroughly beforehand, so this addition is what would have helped shortcut me to full understanding. It would have saved at least one person (me) some time figuring things out through experimentation and discussion.

I've tried to be as accurate and terse as I can with the technical wording, but am of course happy to revise and be further informed of gaps in my understanding! Just hope this is helpful to others working with plugins going forward.

The following test cases are added, to cover these aspects of mix format behavior:

  • a plugin that targets .ex/.exs disables baseline code formatting of these files
  • a plugin that targets .ex/.exs disables sigil-plugin formatting in these files
  • a plugin that calls Code.format_string! may be used to restore both baseline code formatting and sigil-plugin formatting
bin/elixirc lib/mix/lib/mix/tasks/format.ex -o lib/elixir/ebin && for line in 621 651 684 718 748 781 811 840; do TRACE=1 LINE=$line bin/elixir lib/mix/test/mix/tasks/format_test.exs; done | grep -E '\([0-9\.]+ms\) \[L#\d+\]'

  * test using plugin from .formatter.exs which targets .ex files disables standard Elixir code formatting (24.3ms) [L#621]
  * test using multiple plugins from .formatter.exs which target .ex files disables standard Elixir code formatting (23.1ms) [L#651]
  * test using multiple plugins from .formatter.exs which target both .ex files and sigils within them disables both standard Elixir code formatting and plugin sigil formatting [  * test using multiple plugins from .formatter.exs which target both .ex files and sigils within them disables both standard Elixir code formatting and plugin sigil formatting (23.3ms) [L#684]
  * test using plugin from .formatter.exs which targets .ex files with another plugin to do standard Elixir code formatting first (23.5ms) [L#718]
  * test using multiple plugins from .formatter.exs which target .ex files with another plugin to do standard Elixir code formatting first (23.5ms) [L#748]
  * test using multiple plugins from .formatter.exs which target .ex files with another plugin to do standard Elixir code formatting in the middle (23.1ms) [L#781]
  * test using a plugins from .formatter.exs which target .ex files with another plugin to do standard Elixir code formatting last (20.9ms) [L#811]
  * test using multiple plugins from .formatter.exs which target both .ex files and sigils within them to do standard Elixir code formatting first; also enables plugin sigil form  * test using multiple plugins from .formatter.exs which target both .ex files and sigils within them to do standard Elixir code formatting first; also enables plugin sigil formatting (22.6ms) [L#840]

Here is a screen capture of the new section added to the docs:

Screenshot 2026-08-29 at 8 12 10 AM

@josevalim

Copy link
Copy Markdown
Member

Can you please update the PR to only have the docs? The tests are unnecessary because they are all consequence of a single decision of overriding the formatter, which is already tested. Thanks!

@evnp

evnp commented Aug 29, 2026

Copy link
Copy Markdown
Contributor Author

Sure thing, done in 9e365c4. Left the commits for posterity since it sounds like PRs are squashed anyway, but lmk if you prefer dropping them entirely.

@evnp evnp changed the title Docs and test updates for .ex/.exs plugin behavior Docs updates for .ex/.exs plugin behavior Aug 29, 2026
Clarify behavior of custom Elixir formatters and their interaction with baseline formatting.
@josevalim
josevalim merged commit 26f6dbd into elixir-lang:main Aug 29, 2026
@josevalim

Copy link
Copy Markdown
Member

💚 💙 💜 💛 ❤️

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

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants