aboutsummaryrefslogtreecommitdiff
path: root/.run/src/bin/deploy-api-docs.rs
diff options
context:
space:
mode:
author魏曹先生 <1992414357@qq.com>2026-07-22 20:22:28 +0800
committer魏曹先生 <1992414357@qq.com>2026-07-22 20:23:15 +0800
commitfe39e74efbdcca56e0edefa5bb3cabe2dae4135a (patch)
treeafa8ebda68138314b78d130fdd7c80356ba339eb /.run/src/bin/deploy-api-docs.rs
parenta64ff145c4454d4e8c088f4564679415895472b6 (diff)
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
Diffstat (limited to '.run/src/bin/deploy-api-docs.rs')
-rw-r--r--.run/src/bin/deploy-api-docs.rs26
1 files changed, 21 insertions, 5 deletions
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());