From ee3c2e39ac8456712bf21bd5f3d300d9c8b5605a Mon Sep 17 00:00:00 2001 From: 魏曹先生 <1992414357@qq.com> Date: Tue, 18 Aug 2026 09:18:38 +0800 Subject: feat(ci-new): add show-features command to list documented features --- mingling_ci/src/res/features.rs | 47 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 mingling_ci/src/res/features.rs (limited to 'mingling_ci/src/res') diff --git a/mingling_ci/src/res/features.rs b/mingling_ci/src/res/features.rs new file mode 100644 index 0000000..8009514 --- /dev/null +++ b/mingling_ci/src/res/features.rs @@ -0,0 +1,47 @@ +use mingling::{Program, macros::program_setup}; + +use crate::ThisProgram; + +/// Manifest that declares the documented feature list. +/// +/// Path is relative to the repo root (the CI's working directory). +const FEATURES_MANIFEST: &str = "./mingling/Cargo.toml"; + +/// The docs.rs feature list of `mingling`, the single source of truth for the +/// feature combinations used by CI checks. +#[derive(Default, Clone)] +pub struct ResFeatureList { + pub list: Vec, +} + +#[program_setup] +pub fn features_setup(p: &mut Program) { + p.with_resource(ResFeatureList { + list: docs_rs_features(), + }); +} + +/// Reads `[package.metadata.docs.rs].features` from `mingling/Cargo.toml`. +#[must_use] +fn docs_rs_features() -> Vec { + let Ok(content) = std::fs::read_to_string(FEATURES_MANIFEST) else { + return Vec::new(); + }; + let Ok(toml_value) = content.parse::() else { + return Vec::new(); + }; + toml_value + .get("package") + .and_then(|p| p.get("metadata")) + .and_then(|m| m.get("docs")) + .and_then(|d| d.get("rs")) + .and_then(|rs| rs.get("features")) + .and_then(|f| f.as_array()) + .map(|features| { + features + .iter() + .filter_map(|v| v.as_str().map(str::to_string)) + .collect() + }) + .unwrap_or_default() +} -- cgit