cartulary 0.3.0-alpha.1

The knowledge layer of your project — decisions, issues, docs, all in one place.
Documentation
//! Ports for rendering user-facing concept documentation.
//!
//! [`Renderer`] turns Markdown source into a target-specific string
//! (terminal, HTML, ...). [`LinkResolver`] is used by a renderer impl
//! to translate `concept://`, `adr://`, `ddr://` and `issue://` links
//! into target-appropriate output. The two ports are split because the
//! same renderer family (a Markdown walker) is reused across targets;
//! only the link resolution differs per target.

/// Render Markdown source to a target-specific output string.
///
/// Implementations live under `infra/driven/doc/render/` (terminal,
/// HTML). The use case [`super::show::show`] depends only on this
/// trait — it does not know whether the output is ANSI-coloured text
/// or HTML.
pub trait Renderer {
    fn render(&self, source: &str) -> String;
}

/// Translate a typed link to its target-specific output substring.
///
/// The renderer parses Markdown links of the form
/// `[text](scheme://target)` and delegates the rendering to this
/// port. The terminal adapter returns just `text` (the scheme is
/// dropped); the HTML adapter wraps it in an `<a>` tag and may look
/// up record metadata for `adr://`, `ddr://`, `issue://` schemes.
///
/// `scheme` is one of `concept`, `adr`, `ddr`, `issue` (more may be
/// added).
pub trait LinkResolver {
    fn render_link(&self, text: &str, scheme: &str, target: &str) -> String;
}