Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix docsrs #1487

Merged
merged 3 commits into from
Aug 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading