Readmix (readmix v0.1.1)

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 context modules:

Readmix.new(
  generators: %{my_namespace: MyGeneratorModule},
  vars: %{my_var: "hello"},
  contexts: [MyContext, Readmix.Contexts.Defaults]
)

Summary

Functions

Returns the list of modules used to define the context of execution. For now this only defines which variables are available for usage in blocks arguments.

Returns the mapping from namespace to generator used by default by Readmix if no :resolver or :generators option is given to Readmix.new/1.

Types

t()

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

Functions

blocks_to_iodata(rdmx, blocks)

default_contexts()

Returns the list of modules used to define the context of execution. For now this only defines which variables are available for usage in blocks arguments.

Those defaults are pulled with Application.fetch_env(:readmix, :contexts), which is a configuration value that you can define in config/dev.exs or config/runtime.exs.

If not configuration is defined, the default value is [Readmix.Contexts.Defaults].

default_generators()

Returns the mapping from namespace to generator used by default by Readmix if no :resolver or :generators option is given to Readmix.new/1.

Those defaults are pulled with Application.fetch_env(:readmix, :generators), which is a configuration value that you can define in config/dev.exs or config/runtime.exs.

If not configuration is defined, the default value is %{rdmx: Readmix.Generators.BuiltIn}.

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)