Guide for Claude Code when working with this Elixir/Rust markdown formatter.
mix check && mix test- Run all quality checks and tests before committingmix format- Format Elixir code (run after any changes)mix deps.get && mix compile- Setup dependencies and compile
mix check- Runs format, credo, dialyzer, cargo fmt, cargo clippymix credo- Static analysismix dialyzer- Type checking
cargo build- Build the NIFcargo test- Run Rust testscargo fmt && cargo clippy- Format and lint Rust code
Fast markdown formatting via Rust NIF:
- DprintMarkdownFormatter - Main public API with Mix.exs config support
- DprintMarkdownFormatter.Native - Rustler NIF wrapper
- DprintMarkdownFormatter.Sigil -
~Msigil for embedded markdown - Rust NIF -
native/dprint_markdown_formatter/wraps dprint-plugin-markdown
- High-performance Rust formatting via Rustler
- Module attribute formatting (
@moduledoc,@doc, etc.) - Mix format integration
- Configurable formatting options
- Precompiled binaries for fast installation
def project do
[
dprint_markdown_formatter: [
line_width: 100,
text_wrap: "never",
emphasis_kind: "underscores",
format_module_attributes: true # Enable @moduledoc, @doc formatting
]
]
end:line_width- Max line width (default: 80):text_wrap- "always", "never", "maintain" (default: "always"):emphasis_kind- "asterisks", "underscores" (default: "asterisks"):strong_kind- "asterisks", "underscores" (default: "asterisks"):unordered_list_kind- "dashes", "asterisks" (default: "dashes"):format_module_attributes- Configure attribute formatting:nil(default) - Skip all formattingtrue- Format:moduledoc,:doc,:typedoc,:shortdoc,:deprecatedfalse- Skip all formatting[:moduledoc, :doc, :custom]- Format specific attributes only
- Maximize privacy - Use
defpfor non-essential functions - Order functions - Public first, then private under "# Private helpers"
- Add type specs - Include
@specfor all public functions
- Maximize privacy - Use
@typepfor internal types - Public types only - Keep
@typefor types used by other modules - Group related types - Place type definitions near their usage
- Always run
mix formatafter file changes - Run
mix checkafter Elixir changes - Run
cargo fmt && cargo clippyafter Rust changes - Test with
mix testbefore committing
Following recent improvements, the codebase maintains strict privacy boundaries:
- 13 internal types are private (
@typep) in Config, Native, and Validator modules - Internal validation functions are private (
defp) in Validator module - Public API surface is minimal - only expose what other modules need
- Cross-module dependencies follow a clear hierarchy: Main → Config/Error/Validator/Native