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