Formatting Elixir Doctests with a Custom Plugin

193
clicks
Formatting Elixir Doctests with a Custom Plugin

Source: angelika.me

Type: Post

Angelika Tyborska shared her development of a plugin named Doctest Formatter after receiving a request from a fellow developer. This plugin enables users to format Elixir code blocks specifically for doctests within their documentation. The plugin, which works with Elixir version 1.13.2 or higher, can be easily installed by adding it to the dependencies in 'mix.exs' and updating the '.formatter.exs' config file. Once installed, the user simply runs 'mix format' to format both their '.ex' files and the Elixir code in doctests located within '@doc' and '@moduledoc' attributes. The formatter also adjusts 'iex>' prompts to use '...' for lines following the first. While effective for static values in doctests, the plugin acknowledges some known limitations, inviting users to report any encountered bugs via its GitHub issue tracker.

© HashMerge 2024