aboutsummaryrefslogtreecommitdiff
path: root/.run/src/bin/deploy-api-docs.rs
diff options
context:
space:
mode:
Diffstat (limited to '.run/src/bin/deploy-api-docs.rs')
-rw-r--r--.run/src/bin/deploy-api-docs.rs58
1 files changed, 22 insertions, 36 deletions
diff --git a/.run/src/bin/deploy-api-docs.rs b/.run/src/bin/deploy-api-docs.rs
index ea52886..961eb04 100644
--- a/.run/src/bin/deploy-api-docs.rs
+++ b/.run/src/bin/deploy-api-docs.rs
@@ -1,44 +1,22 @@
use std::path::Path;
+use arg_picker::{Picker, macros::arg};
use tools::{println_cargo_style, run_cmd};
-const DOCS_RS_MANIFEST: &str = "mingling/Cargo.toml";
const OUTPUT_DIR: &str = "docs/api-docs";
fn main() {
- let repo_root = find_git_repo().expect("Failed to find git repository root");
+ let using_docsrs = Picker::from_args()
+ .pick_or_default(&arg![docsrs: bool])
+ .unwrap();
- let manifest_path = repo_root.join(DOCS_RS_MANIFEST);
- if !manifest_path.exists() {
- eprintln!("Error: Manifest not found at {}", manifest_path.display());
- std::process::exit(1);
- }
+ let repo_root = find_git_repo().expect("Failed to find git repository root");
- // Read and parse [package.metadata.docs.rs]
- let manifest_content =
- std::fs::read_to_string(&manifest_path).expect("Failed to read Cargo.toml");
- let cargo_toml: toml::Value = manifest_content
- .parse()
- .expect("Failed to parse Cargo.toml");
-
- let doc_features = cargo_toml
- .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())
- .unwrap_or_else(|| {
- eprintln!("Error: [package.metadata.docs.rs] or its 'features' key not found in mingling/Cargo.toml");
- std::process::exit(1);
- });
-
- let features: Vec<&str> = doc_features.iter().filter_map(|v| v.as_str()).collect();
-
- if features.is_empty() {
- eprintln!("Error: No features defined in [package.metadata.docs.rs]");
+ // Read features from [package.metadata.docs.rs]
+ let features = tools::read_features().unwrap_or_else(|e| {
+ eprintln!("Error: {}", e);
std::process::exit(1);
- }
+ });
let features_arg = features.join(",");
@@ -47,11 +25,19 @@ 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",
+ features_arg,
+ output_path.join("target").to_string_lossy()
+ )
+ } else {
+ format!(
+ "cargo doc --no-deps --features \"{}\" -p mingling --target-dir \"{}\" --color always",
+ features_arg,
+ output_path.join("target").to_string_lossy()
+ )
+ };
println_cargo_style!("Features: {}", features_arg);
println_cargo_style!("Output: {}", output_path.display());