From fe39e74efbdcca56e0edefa5bb3cabe2dae4135a Mon Sep 17 00:00:00 2001 From: 魏曹先生 <1992414357@qq.com> Date: Wed, 22 Jul 2026 20:22:28 +0800 Subject: feat(docs): add docsrs flag and unify doc scripts Migrate existing doc scripts to call the deploy-api-docs tool, and add nightly variants that build with --cfg docsrs --- .run/src/bin/deploy-api-docs.rs | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) (limited to '.run/src/bin/deploy-api-docs.rs') diff --git a/.run/src/bin/deploy-api-docs.rs b/.run/src/bin/deploy-api-docs.rs index 7aa093c..ac4486e 100644 --- a/.run/src/bin/deploy-api-docs.rs +++ b/.run/src/bin/deploy-api-docs.rs @@ -1,10 +1,16 @@ use std::path::Path; +use arg_picker::{Picker, macros::arg}; use tools::{println_cargo_style, run_cmd}; const OUTPUT_DIR: &str = "docs/api-docs"; fn main() { + let (using_docsrs, open) = Picker::from_args() + .pick_or_default(&arg![docsrs: bool]) + .pick_or_default(&arg![open: bool, 'O']) + .unwrap(); + let repo_root = find_git_repo().expect("Failed to find git repository root"); // Read features from [package.metadata.docs.rs] @@ -20,11 +26,21 @@ fn main() { std::fs::create_dir_all(&output_path).expect("Failed to create output directory"); // Build cargo doc command - let cmd = format!( - "cargo doc --no-deps --features \"{}\" -p mingling --target-dir \"{}\" --color always", - features_arg, - output_path.join("target").to_string_lossy() - ); + let cmd = if using_docsrs { + format!( + "cargo +nightly rustdoc {} --features \"{}\" -p mingling --target-dir \"{}\" --color always -- --cfg docsrs", + if open { "--open" } else { "" }, + features_arg, + output_path.join("target").to_string_lossy() + ) + } else { + format!( + "cargo doc --no-deps {} --features \"{}\" -p mingling --target-dir \"{}\" --color always", + if open { "--open" } else { "" }, + features_arg, + output_path.join("target").to_string_lossy() + ) + }; println_cargo_style!("Features: {}", features_arg); println_cargo_style!("Output: {}", output_path.display()); -- cgit