Python API Reference¶
Reference documentation for python-mdma, generated
from docstrings in the mdma-python repository.
mdma — a typed Markdown templating format.
See https://github.com/ (project README) for the full language specification.
MdmaError
¶
MdmaSyntaxError
¶
MissingInputError
¶
Bases: MdmaError
A required input (no default) was not supplied at render time.
Source code in mdma/errors.py
MdmaTypeError
¶
Bases: MdmaError
An input value's runtime type does not match its declared type.
Source code in mdma/errors.py
MdmaReferenceError
¶
Bases: MdmaError
A block or variable reference could not be resolved.
Source code in mdma/errors.py
FilterError
¶
DuplicateNameError
¶
Bases: MdmaError
Two items in a <multiple:> block computed the same <name:> value.
Source code in mdma/errors.py
render(source, inputs=None)
¶
Render an .mdma source string against an inputs object.
Returns a dict mapping each block name to its rendered string. A
<multiple:> block renders to a list of strings, or -- if it also
declares <name:> -- to a dict keyed by each item's computed name.
Source code in mdma/renderer.py
render_file(path, inputs=None)
¶
Read path as UTF-8 and render it. Equivalent to render(Path(path).read_text(), inputs).
Source code in mdma/renderer.py
write_output(result, output_dir, block=None)
¶
Write one or all rendered blocks from a render() result to .md files.
block=None (default) writes every top-level block; block="name" writes
only that one. A string-valued block is written to {output_dir}/{block}.md.
A <multiple:> block (list or <name:>-keyed dict) is written to
{output_dir}/{block}/, one file per item -- {name}.md if the block
declared <name:>, otherwise {index}.md.
Raises MdmaReferenceError if block isn't a key in result.