From f0241dd728dd1245e938b137a541cb2db9a06026 Mon Sep 17 00:00:00 2001 From: pentamassiv Date: Sat, 5 Aug 2023 04:52:19 +0200 Subject: [PATCH 1/3] =?UTF-8?q?Removed=20=C2=B4docs=5Frs=5Ffeatures=C2=B4?= =?UTF-8?q?=20option?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/codegen/sys/cargo_toml.rs | 3 ++- src/config/config.rs | 13 ------------- 2 files changed, 2 insertions(+), 14 deletions(-) diff --git a/src/codegen/sys/cargo_toml.rs b/src/codegen/sys/cargo_toml.rs index ce98702e1..9df01f299 100644 --- a/src/codegen/sys/cargo_toml.rs +++ b/src/codegen/sys/cargo_toml.rs @@ -172,7 +172,8 @@ fn fill_in(root: &mut Table, env: &Env) { let docs_rs_metadata = upsert_table(docs_rs_metadata, "metadata"); let docs_rs_metadata = upsert_table(docs_rs_metadata, "docs"); let docs_rs_metadata = upsert_table(docs_rs_metadata, "rs"); - let docs_rs_features = env.config.docs_rs_features.clone(); + + let docs_rs_features: Vec = vec![]; docs_rs_metadata.insert( "features".to_string(), Value::Array( diff --git a/src/config/config.rs b/src/config/config.rs index 9efdfd701..0d24a4042 100644 --- a/src/config/config.rs +++ b/src/config/config.rs @@ -114,7 +114,6 @@ pub struct Config { pub single_version_file: Option, pub generate_display_trait: bool, pub trust_return_value_nullability: bool, - pub docs_rs_features: Vec, pub disable_format: bool, pub split_build_rs: bool, pub extra_versions: Vec, @@ -265,17 +264,6 @@ impl Config { None => false, }; - let mut docs_rs_features = Vec::new(); - for v in match toml.lookup("options.docs_rs_features") { - Some(v) => v.as_result_vec("options.docs_rs_features")?.as_slice(), - None => &[], - } { - docs_rs_features.push(v.as_str().map(|s| s.to_owned()).ok_or(format!( - "Invalid `docs_rs_features` value element, expected a string, found {}", - v.type_str() - ))?); - } - // options.concurrency is the default of all objects if nothing // else is configured let mut objects = toml @@ -373,7 +361,6 @@ impl Config { single_version_file, generate_display_trait, trust_return_value_nullability, - docs_rs_features, disable_format, split_build_rs, extra_versions, From cee53e5b68b93565801c6922c83a56ab34a1d688 Mon Sep 17 00:00:00 2001 From: pentamassiv Date: Sat, 5 Aug 2023 05:45:01 +0200 Subject: [PATCH 2/3] Set rustc-args and rustdoc-args on docs.rs --- src/codegen/sys/cargo_toml.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/codegen/sys/cargo_toml.rs b/src/codegen/sys/cargo_toml.rs index 9df01f299..71550ba61 100644 --- a/src/codegen/sys/cargo_toml.rs +++ b/src/codegen/sys/cargo_toml.rs @@ -173,6 +173,21 @@ fn fill_in(root: &mut Table, env: &Env) { let docs_rs_metadata = upsert_table(docs_rs_metadata, "docs"); let docs_rs_metadata = upsert_table(docs_rs_metadata, "rs"); + // Set the rustc and rustdoc args to be able to build the docs on docs.rs without the libraries + docs_rs_metadata.entry("rustc-args").or_insert_with(|| { + Value::Array(vec![ + Value::String("--cfg".to_string()), + Value::String("docsrs".to_string()), + ]) + }); + docs_rs_metadata.entry("rustdoc-args").or_insert_with(|| { + Value::Array(vec![ + Value::String("--cfg".to_string()), + Value::String("docsrs".to_string()), + Value::String("--generate-link-to-definition".to_string()), + ]) + }); + let docs_rs_features: Vec = vec![]; docs_rs_metadata.insert( "features".to_string(), From 58afa4356618c3341f4f282167726568d309603c Mon Sep 17 00:00:00 2001 From: pentamassiv Date: Sat, 5 Aug 2023 05:46:27 +0200 Subject: [PATCH 3/3] Build docs for all features unless a list was specified --- src/codegen/sys/cargo_toml.rs | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/src/codegen/sys/cargo_toml.rs b/src/codegen/sys/cargo_toml.rs index 71550ba61..44ce52239 100644 --- a/src/codegen/sys/cargo_toml.rs +++ b/src/codegen/sys/cargo_toml.rs @@ -188,16 +188,10 @@ fn fill_in(root: &mut Table, env: &Env) { ]) }); - let docs_rs_features: Vec = vec![]; - docs_rs_metadata.insert( - "features".to_string(), - Value::Array( - docs_rs_features - .into_iter() - .map(Value::String) - .collect::>(), - ), - ); + // Generate docs for all features unless a list of features to be activated on docs.rs was specified + if let toml::map::Entry::Vacant(_) = docs_rs_metadata.entry("features") { + set_string(docs_rs_metadata, "all-features", "true"); + } } }