Readmix (readmix v0.6.2)

Readmix is a tool for generating and maintaining documentation with dynamic content.

It allows you to embed special tags in your markdown or other text files that will be processed and replaced with generated content.

Basic Usage

# Create a new Readmix instance
rdmx = Readmix.new([])

# Update a file containing Readmix blocks
Readmix.update_file(rdmx, "README.md")

Block Format

Readmix blocks are defined in HTML comments with a special rdmx prefix:

<!-- rdmx my_namespace:my_action param1:"value1" param2:$my_var -->
This content will be replaced by the generator.
<!-- rdmx my_namespace:my_action -->

Configuration

You can configure Readmix with custom generators, variables, and scope modules:

Readmix.new(
  generators: %{my_namespace: MyGeneratorModule},
  vars: %{my_var: "hello"},
  env: [MyScope | Readmix.default_scopes()]
)

Summary

Types

block()

t()

@type t() :: %Readmix{
  backup_fun: function(),
  resolver: function(),
  vars: %{optional(atom()) => term()}
}

Functions

blocks_to_iodata(rdmx, blocks)

default_backup_directory()

Returns the default backup directory for updated files.

Readmix will append the otp_app name to the path so it is safe to use the same directory for multiple applications.

default_scopes()

Returns the default scopes used for built-in generators.

If you need to configure your own scopes but want to use default Readmix scopes as well, include these in the configuration:

# config/dev.exs
import Config

config :readmix,
  scopes: [MyScope1, MyScope2 | Readmix.default_scopes()]

format_error(e)

new(opts)

parse_string(string, source_path \\ nil)

transform_string(rdmx, string, opts \\ [])

transform_string_to_iodata(rdmx, string, opts \\ [])

update_file(rdmx, path)