embed-licensing 0.3.1

Embed licensing information of dependencies to comply with free software licenses
Documentation
// SPDX-FileCopyrightText: 2024 Simon Bruder <simon@sbruder.de>
//
// SPDX-License-Identifier: MPL-2.0

//! Proc-macro for embedding licensing information about a crate.
//!
//! It also exposes its internal functions that allow
//! either collecting licensing information at runtime (with [`collect()`]),
//! when in the directory of the manifest,
//! or collecting licensing information from a specific manifest file (with
//! [`collect_from_manifest`]).
//!
//! However, the recommended way to use this crate is the macro [`collect!`]:
//!
//! ```rust
//! # #[cfg(feature = "macros")]
//! # {
//! let licensing = embed_licensing::collect!();
//!
//! for package in licensing.packages {
//!     if let embed_licensing::CrateLicense::SpdxExpression(expr) = package.license {
//!         println!("{} {} ({})", package.name, package.version, expr);
//!     } else {
//!         println!("{} {} uses custom license", package.name, package.version);
//!     }
//! }
//! # }
//! ```

#![cfg_attr(docsrs, feature(doc_cfg))]
#![cfg_attr(docsrs, feature(doc_auto_cfg))]

pub use embed_licensing_core::{
    collect, collect_from_manifest, CollectConfig, CollectPlatform, Crate, CrateLicense, Error,
    Licensing,
};

/// Collect licensing information at build-time.
///
/// It takes the same arguments as [`CollectConfig`].
/// Please see the examples for the format.
///
/// # Examples
///
/// ```
/// # #[macro_use] extern crate embed_licensing_macros;
/// # use embed_licensing_core::*;
/// collect!(); // collect only normal dependencies
/// collect!(build); // collect normal and build dependencies
/// collect!(dev); // collect normal and (direct) development dependencies
/// collect!(build, dev); // collect normal, build and (direct) development dependencies
///
/// collect!(build = true); // boolean arguments can also be explicitly set to true
/// collect!(build = false); // … or to false (which is the default for `build`)
///
/// collect!(platform(any)); // collect dependencies regardless of platform
/// // only collect dependencies corresponding to the specified platform
/// collect!(platform(static(target = "aarch64-apple-darwin", cfg(target_os = "macos", target_family = "unix", unix))));
/// #[cfg(feature = "current_platform")]
/// collect!(platform(current)); // collect dependencies for current platform
/// ```
#[cfg(feature = "macros")]
pub use embed_licensing_macros::collect;