blame_rs/
lib.rs

1//! # blame-rs
2//!
3//! A Rust library for line-by-line authorship tracking in revisioned text content.
4//!
5//! This crate provides a Git-style blame/annotate algorithm that determines which revision
6//! introduced each line in a document by analyzing a sequence of revisions.
7//!
8//! ## Features
9//!
10//! - **Generic metadata**: Attach any metadata type to revisions (commit hashes, authors, timestamps, etc.)
11//! - **Multiple diff algorithms**: Support for Myers and Patience algorithms via the `similar` crate
12//! - **Forward tracking**: Efficiently traces line origins from oldest to newest revision
13//!
14//! ## Example
15//!
16//! ```rust
17//! use blame_rs::{blame, BlameRevision};
18//!
19//! #[derive(Clone, Debug)]
20//! struct CommitInfo {
21//!     hash: String,
22//!     author: String,
23//! }
24//!
25//! let revisions = vec![
26//!     BlameRevision {
27//!         content: "line 1\nline 2",
28//!         metadata: CommitInfo {
29//!             hash: "abc123".to_string(),
30//!             author: "Alice".to_string(),
31//!         },
32//!     },
33//!     BlameRevision {
34//!         content: "line 1\nline 2\nline 3",
35//!         metadata: CommitInfo {
36//!             hash: "def456".to_string(),
37//!             author: "Bob".to_string(),
38//!         },
39//!     },
40//! ];
41//!
42//! let result = blame(&revisions).unwrap();
43//! for line in result.lines() {
44//!     println!("{}: {}", line.revision_metadata.author, line.content);
45//! }
46//! ```
47
48mod blame;
49mod types;
50
51pub use blame::{blame, blame_with_options};
52pub use types::{BlameError, BlameLine, BlameOptions, BlameResult, BlameRevision, DiffAlgorithm};