cartulary 0.3.0-alpha.1

The knowledge layer of your project — decisions, issues, docs, all in one place.
Documentation
use std::path::PathBuf;

/// A free-form documentation tree mounted on the generated site.
///
/// Parsed from `[docs.<name>]` in `cartulary.toml`:
/// ```toml
/// [docs.pages]
/// type    = "markdown"
/// source  = "docs/pages"
/// publish = "/pages"
/// ```
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct DocsConfig {
    /// User-chosen name for this tree (e.g. `"pages"`).
    pub name: String,
    /// Content variant.
    pub kind: DocsKind,
    /// Directory to walk, resolved against the workspace root.
    pub source: PathBuf,
    /// URL prefix where pages from `source` get mounted.
    pub publish: String,
}

/// Content variant for a `[docs.<name>]` entry. Only `Markdown` for
/// now; the enum exists so the namespace can take other variants
/// without changing the schema.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum DocsKind {
    Markdown,
}

impl DocsKind {
    pub fn parse(s: &str) -> Result<Self, String> {
        match s {
            "markdown" => Ok(Self::Markdown),
            other => Err(format!("type must be \"markdown\", got {other:?}",)),
        }
    }
}