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::{
15    AdrEntry, HOME_NOTE, VaultNote, VaultSummary, note_name, render_home, render_note,
16};
17
18/// A render target for the graph.
19#[derive(Debug, Clone, Copy, PartialEq, Eq)]
20pub enum Target {
21    /// Static documentation website (ADRs, blueprints, AI context pages).
22    DocsSite,
23    /// Obsidian-compatible markdown vault.
24    ObsidianVault,
25}
26
27impl Target {
28    /// Stable CLI name for this target.
29    #[must_use]
30    pub fn as_str(self) -> &'static str {
31        match self {
32            Self::DocsSite => "docs",
33            Self::ObsidianVault => "obsidian",
34        }
35    }
36
37    /// Parse a target from its CLI name.
38    #[must_use]
39    pub fn parse(s: &str) -> Option<Self> {
40        match s {
41            "docs" => Some(Self::DocsSite),
42            "obsidian" => Some(Self::ObsidianVault),
43            _ => None,
44        }
45    }
46}
47
48#[cfg(test)]
49mod tests {
50    use super::Target;
51
52    #[test]
53    fn target_names_are_stable() {
54        assert_eq!(Target::DocsSite.as_str(), "docs");
55        assert_eq!(Target::ObsidianVault.as_str(), "obsidian");
56        assert_eq!(Target::parse("docs"), Some(Target::DocsSite));
57        assert_eq!(Target::parse("obsidian"), Some(Target::ObsidianVault));
58        assert_eq!(Target::parse("nope"), None);
59    }
60}