1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
//! Changelog formatters for different output formats.
//!
//! **What**: Provides formatters that convert changelog data structures into
//! various standard formats like Keep a Changelog, Conventional Commits, and custom templates.
//!
//! **How**: Each formatter implements the formatting logic for a specific changelog
//! standard, taking `Changelog` structures and producing formatted markdown strings.
//!
//! **Why**: To support multiple changelog formats and conventions while maintaining
//! a unified internal representation of changelog data.
//!
//! # Available Formatters
//!
//! - **Keep a Changelog**: Standard format following <https://keepachangelog.com>
//! - **Conventional Commits**: Automatic grouping by commit type
//! - **Custom Template**: User-defined templates with variable substitution
//!
//! # Example
//!
//! ```rust,ignore
//! use sublime_pkg_tools::changelog::formatter::KeepAChangelogFormatter;
//! use sublime_pkg_tools::changelog::{Changelog, ChangelogSection, ChangelogEntry, SectionType};
//! use sublime_pkg_tools::config::ChangelogConfig;
//! use chrono::Utc;
//!
//! // Create a changelog with sections and entries
//! let mut changelog = Changelog::new(Some("my-package"), "1.0.0", Some("0.9.0"), Utc::now());
//!
//! // Add features section
//! let mut features = ChangelogSection::new(SectionType::Features);
//! features.add_entry(ChangelogEntry {
//! description: "Add new API endpoint".to_string(),
//! commit_hash: "abc123".to_string(),
//! short_hash: "abc123".to_string(),
//! commit_type: Some("feat".to_string()),
//! scope: None,
//! breaking: false,
//! author: "John Doe".to_string(),
//! references: vec!["#123".to_string()],
//! date: Utc::now(),
//! });
//! changelog.add_section(features);
//!
//! // Format as Keep a Changelog
//! let config = ChangelogConfig::default();
//! let formatter = KeepAChangelogFormatter::new(&config);
//! let formatted = formatter.format(&changelog);
//!
//! // Output:
//! // ## [1.0.0] - 2024-01-15
//! //
//! // ### Added
//! // - Add new API endpoint (abc123) (#123)
//! ```
// Public exports
pub use ConventionalCommitsFormatter;
pub use CustomTemplateFormatter;
pub use KeepAChangelogFormatter;
// Tests module - located in tests.rs