cartulary 0.3.0-alpha.1

The knowledge layer of your project — decisions, issues, docs, all in one place.
Documentation
/// What a companion *is*, in domain terms.
///
/// The first three variants are the standardised slots — issues
/// typically grow a `plan.md` (implementation plan), an
/// `implementation-notes.md` (technical gotchas), and a
/// `design-decision.md` (alternatives considered). They are
/// recognised by filename and the CLI knows how to render their
/// text content.
///
/// `Other` is the open extension point: every other file in the
/// issue directory (mockups, images, business docs, …) is
/// acknowledged as a companion. Its content stays opaque to the
/// domain — the CLI does not render it via `show --file`, but
/// downstream consumers (site generation) can still copy it through.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum CompanionKind {
    Plan,
    ImplementationNotes,
    DesignDecision,
    Other,
}

impl CompanionKind {
    /// `true` for the three standardised kinds, `false` for `Other`.
    /// Used by the CLI to decide between rendering text content and
    /// refusing an addressing request.
    pub fn is_managed(&self) -> bool {
        !matches!(self, CompanionKind::Other)
    }
}

#[cfg(test)]
pub mod strategy {
    use super::CompanionKind;
    use proptest::prelude::*;

    /// Generate any `CompanionKind` variant.
    pub fn companion_kind() -> impl Strategy<Value = CompanionKind> {
        prop_oneof![
            Just(CompanionKind::Plan),
            Just(CompanionKind::ImplementationNotes),
            Just(CompanionKind::DesignDecision),
            Just(CompanionKind::Other),
        ]
    }
}

#[cfg(test)]
mod tests {
    use super::*;
    use proptest::prelude::*;

    proptest! {
        #[test]
        fn is_managed_is_false_only_for_other(kind in strategy::companion_kind()) {
            prop_assert_eq!(kind.is_managed(), !matches!(kind, CompanionKind::Other));
        }
    }

    #[test]
    fn standardised_variants_are_managed() {
        assert!(CompanionKind::Plan.is_managed());
        assert!(CompanionKind::ImplementationNotes.is_managed());
        assert!(CompanionKind::DesignDecision.is_managed());
    }

    #[test]
    fn other_is_not_managed() {
        assert!(!CompanionKind::Other.is_managed());
    }
}