Skip to main content

rto_render/
lib.rs

1//! Renderers over the Roteiro graph. All outputs — docs site, Obsidian vault,
2//! and the optional MCP server (feature `mcp`) — are build products of the
3//! same store, so humans and agents always see the same data.
4
5mod docs;
6mod obsidian;
7
8#[cfg(feature = "mcp")]
9pub mod mcp;
10
11pub use docs::{
12    IndexEntry, RenderedAdr, markdown_to_html, render_adr, render_adr_index, render_doc,
13};
14pub use obsidian::{VaultNote, note_name, render_note};
15
16/// A render target for the graph.
17#[derive(Debug, Clone, Copy, PartialEq, Eq)]
18pub enum Target {
19    /// Static documentation website (ADRs, blueprints, AI context pages).
20    DocsSite,
21    /// Obsidian-compatible markdown vault.
22    ObsidianVault,
23}
24
25impl Target {
26    /// Stable CLI name for this target.
27    #[must_use]
28    pub fn as_str(self) -> &'static str {
29        match self {
30            Self::DocsSite => "docs",
31            Self::ObsidianVault => "obsidian",
32        }
33    }
34
35    /// Parse a target from its CLI name.
36    #[must_use]
37    pub fn parse(s: &str) -> Option<Self> {
38        match s {
39            "docs" => Some(Self::DocsSite),
40            "obsidian" => Some(Self::ObsidianVault),
41            _ => None,
42        }
43    }
44}
45
46#[cfg(test)]
47mod tests {
48    use super::Target;
49
50    #[test]
51    fn target_names_are_stable() {
52        assert_eq!(Target::DocsSite.as_str(), "docs");
53        assert_eq!(Target::ObsidianVault.as_str(), "obsidian");
54        assert_eq!(Target::parse("docs"), Some(Target::DocsSite));
55        assert_eq!(Target::parse("obsidian"), Some(Target::ObsidianVault));
56        assert_eq!(Target::parse("nope"), None);
57    }
58}