Skip to content

Commit

Permalink
Merge pull request #1487 from pentamassiv/fix_docsrs
Browse files Browse the repository at this point in the history
Fix docsrs
  • Loading branch information
GuillaumeGomez authored Aug 5, 2023
2 parents ef087c0 + 58afa43 commit 47c2f07
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 23 deletions.
30 changes: 20 additions & 10 deletions src/codegen/sys/cargo_toml.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,16 +172,26 @@ 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();
docs_rs_metadata.insert(
"features".to_string(),
Value::Array(
docs_rs_features
.into_iter()
.map(Value::String)
.collect::<Vec<_>>(),
),
);

// 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()),
])
});

// 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");
}
}
}

Expand Down
13 changes: 0 additions & 13 deletions src/config/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@ pub struct Config {
pub single_version_file: Option<PathBuf>,
pub generate_display_trait: bool,
pub trust_return_value_nullability: bool,
pub docs_rs_features: Vec<String>,
pub disable_format: bool,
pub split_build_rs: bool,
pub extra_versions: Vec<Version>,
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 47c2f07

Please sign in to comment.