Skip to main content

Crate mdt_core

Crate mdt_core 

Source
Expand description

mdt is a data-driven template engine for keeping documentation synchronized across your project. It uses comment-based template tags to define content once and distribute it to multiple locations — markdown files, code documentation comments (in any language), READMEs, mdbook docs, and more.

Re-exports§

pub use config::*;
pub use project::*;

Modules§

config
project

Structs§

Block
CheckResult
Result of checking a project for stale consumers.
OrderedFloat
A float wrapper that implements Eq via approximate comparison, allowing Argument to derive PartialEq cleanly.
Point
One place in a source file. This is taken from the [unist] crate with the Copy trait added.
Position
Location of a node in a source file. This is taken from the unist crate with the Copy trait added.
StaleEntry
A consumer entry that is out of date.
Transformer
UpdateResult
Result of updating a project.

Enums§

Argument
BlockType
MdtError
TransformerType

Functions§

apply_transformers
Apply a sequence of transformers to content.
build_blocks_from_groups
Build blocks from already-tokenized groups. This is the shared logic used by both markdown parsing and source file scanning.
build_blocks_from_groups_lenient
Like build_blocks_from_groups, but silently discards unclosed blocks instead of returning an error. Used for source files where HTML comments may appear in string literals without matching close tags.
check_project
Check whether all consumer blocks in the project are up to date. Consumer blocks that reference non-existent providers are silently skipped.
compute_updates
Compute the updated file contents for all consumer blocks.
extract_html_comments
Extract HTML comments (<!-- ... -->) from raw text content, returning Html nodes with correct byte positions. This is used for source files where the markdown AST parser won’t find HTML comments inside code comments.
get_html_nodes
parse
Parse markdown content and return all blocks (provider and consumer) found within it.
parse_source
Parse source code content (non-markdown) for mdt blocks by extracting HTML comments directly from the raw text.
render_template
Render provider content through minijinja using the given data context. If data is empty or the content has no template syntax, returns the content unchanged.
validate_transformers
Validate that all transformer arguments are well-formed. Returns an error for the first invalid transformer found.
write_updates
Write the updated contents back to disk.

Type Aliases§

AnyEmptyResult
AnyError
AnyResult
MdtResult