Abbaye

at bb4e6ed

use std::path::PathBuf;

use serde::Deserialize;

use crate::{
    builders::AnyBuilder, changelog::ChangelogConfig, version_extractors::AnyVersionExtractor,
};

/// General website metadata.
#[derive(Debug, Deserialize)]
pub struct SiteConfig {
    /// Display name of the project, used in page titles and headings.
    pub name: String,
    /// Path to the README file rendered on each version page.
    /// Defaults to `README.md` in the current working directory.
    pub readme: Option<PathBuf>,
}

/// A full configuration for the Abbaye site generator.
///
/// Here's a sample configuration that works well as a starting point for rust projects:
///
/// ```toml
/// [site]
/// name = "Abbaye"
///
/// [version_extractor]
/// type = "cargo" # extract version from Cargo.toml
///
/// [changelog]
/// # let's use the default changelog extractor
///
/// [[builders]]
/// type = "cargo" # calls `cargo build --release` for each target
/// targets = ["x86_64-unknown-linux-gnu", "x86_64-unknown-linux-musl"]
/// [[builders]]
/// type = "cargo_doc" # generates documentation using `cargo doc`
/// no_deps = true
///
/// [[builders]]
/// type = "archive" # creates a compressed tarball of the source code
/// ```
///
/// You can learn more about each builder type in the [builders module documentation](crate::builders).
///
#[derive(Debug, Deserialize)]
pub struct AbbayeConfig {
    pub site: SiteConfig,
    pub version_extractor: AnyVersionExtractor,
    pub changelog: ChangelogConfig,
    pub builders: Vec<AnyBuilder>,
    #[serde(default = "abbaye2_output_dir")]
    pub output_dir: Option<PathBuf>,
}

fn abbaye2_output_dir() -> Option<PathBuf> {
    Some(PathBuf::from("public"))
}