erlalign_docs (erlalign v0.1.3)

View Source

EDoc to OTP-27 documentation attribute converter for Erlang.

Converts EDoc-style @doc comments and type documentation to OTP-27 compatible -doc attributes. Handles HTML markup conversion to Markdown, cross-references, and proper attribute formatting.

Options supported:

For format_code/2: - line_length: N - Width for line wrapping (default: 80, 0 = no wrapping) - keep_separators: boolean() - Keep separator lines (default: false)

For process_file/2: - line_length: N - Width for line wrapping (default: 80, 0 = no wrapping) - keep_separators: boolean() - Keep separator lines (default: false) - output: FilePath - Output file path (default: overwrites input file)

Summary

Functions

Convert an EDoc @doc block to an OTP-27 -doc attribute. --------------------------------------------------------------------

Convert EDoc markup to Markdown. --------------------------------------------------------------------

Format Erlang source code, converting @doc blocks to -doc attributes.

Format collected lines as a -doc attribute. --------------------------------------------------------------------

Format @see references as Markdown. --------------------------------------------------------------------

Check if the current OTP version supports documentation conversion. Returns true if OTP version >= 27, false otherwise. --------------------------------------------------------------------

Get the current OTP version. --------------------------------------------------------------------

Parse an EDoc @doc block from Erlang source lines. --------------------------------------------------------------------

Process an Erlang file, converting @doc blocks to -doc attributes.

Wrap lines to specified width. --------------------------------------------------------------------

Functions

convert_doc_block(TextLines)

Convert an EDoc @doc block to an OTP-27 -doc attribute. --------------------------------------------------------------------

convert_doc_block(TextLines, SeeRefs)

convert_doc_block(TextLines, SeeRefs, Opts)

convert_to_markdown(TextLines)

Convert EDoc markup to Markdown. --------------------------------------------------------------------

format_code(Content)

Format Erlang source code, converting @doc blocks to -doc attributes.

Takes source code as a binary string and returns the modified code.

This function only performs the conversion if the OTP version is >= 27. For earlier versions, returns the original code unchanged.

Options: - {line_length, N} - Width for line wrapping (default: 80, 0 = no wrapping) - {keep_separators, boolean()} - Keep %%---- lines (default: false)

format_code(Content, Opts)

format_doc_attribute(Lines)

Format collected lines as a -doc attribute. --------------------------------------------------------------------

format_doc_attribute(Lines, Kind)

format_see_refs(Refs)

Format @see references as Markdown. --------------------------------------------------------------------

is_otp_version_supported()

Check if the current OTP version supports documentation conversion. Returns true if OTP version >= 27, false otherwise. --------------------------------------------------------------------

otp_version()

Get the current OTP version. --------------------------------------------------------------------

parse_doc_block(Lines, StartIdx)

Parse an EDoc @doc block from Erlang source lines. --------------------------------------------------------------------

parse_doc_block(Lines, StartIdx, Prefix)

process_file(InputPath)

Process an Erlang file, converting @doc blocks to -doc attributes.

Reads the file, applies documentation conversion, and writes the result. Returns 'ok' on success or {error, Reason} on failure.

This function only performs the conversion if the OTP version is >= 27. For earlier versions, returns ok without modifying the file.

Options: - {line_length, N} - Width for line wrapping (default: 80, 0 = no wrapping) - {keep_separators, boolean()} - Keep %%---- lines (default: false) - {output, FilePath} - Output file path (default: overwrites input file)

process_file(InputPath, Opts)

wrap_lines(Lines, Width)

Wrap lines to specified width. --------------------------------------------------------------------