Skip to content

Commit

Permalink
limit docs.rs to 5 API tags (#679)
Browse files Browse the repository at this point in the history
Co-authored-by: Cameron Taggart <[email protected]>
  • Loading branch information
cataggar and ctaggart authored Mar 7, 2022
1 parent 6945d23 commit 5be8146
Show file tree
Hide file tree
Showing 231 changed files with 270 additions and 237 deletions.
4 changes: 3 additions & 1 deletion services/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# 0.2 (2022-03)

- generated from azure-rest-api-specs [commit from 2022-03-02](https://github.com/Azure/azure-rest-api-specs/commit/c56b44b794ff17caad4d31c6ab64b07e28253504)
- [#672](https://github.com/Azure/azure-sdk-for-rust/pull/672) generated from azure-rest-api-specs [commit from 2022-03-02](https://github.com/Azure/azure-rest-api-specs/commit/c56b44b794ff17caad4d31c6ab64b07e28253504)
- [#675](https://github.com/Azure/azure-sdk-for-rust/pull/675) use Basic Information tag for default version
- [#634](https://github.com/Azure/azure-sdk-for-rust/issues/634) limit docs.rs to 5 API tags

# 0.1 (2022-01)

Expand Down
6 changes: 5 additions & 1 deletion services/autorust/codegen/examples/gen_svc.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
// cargo run --example gen_svc --release
// https://github.com/Azure/azure-rest-api-specs/blob/master/specification/batch/data-plane
use autorust_codegen::{self, cargo_toml, get_svc_readmes, lib_rs, path, Config, PropertyName, SpecReadme};
use autorust_codegen::{
self,
cargo_toml::{self},
get_svc_readmes, lib_rs, path, Config, PropertyName, SpecReadme,
};
use std::{collections::HashSet, fs, path::PathBuf};

const OUTPUT_FOLDER: &str = "../svc";
Expand Down
6 changes: 3 additions & 3 deletions services/autorust/codegen/examples/mgmt_tags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ fn main() -> Result<()> {
for (i, spec) in get_mgmt_readmes()?.iter().enumerate() {
println!("{} {}", i + 1, spec.spec());
for tag in spec.config()?.tags() {
println!(" {}", &tag.tag);
for input_file in &tag.input_files {
println!(" {}", input_file);
println!(" {}", &tag.name());
for input_file in &tag.input_files() {
println!(" {}", input_file.display());
}
tag_count += 1;
}
Expand Down
6 changes: 3 additions & 3 deletions services/autorust/codegen/examples/svc_tags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ fn main() -> Result<()> {
for (i, spec) in get_svc_readmes()?.iter().enumerate() {
println!("{} {}", i + 1, spec.spec());
for tag in spec.config()?.tags() {
println!(" {}", &tag.tag);
for input_file in &tag.input_files {
println!(" {}", input_file);
println!(" {}", &tag.name());
for input_file in &tag.input_files() {
println!(" {}", input_file.display());
}
tag_count += 1;
}
Expand Down
33 changes: 30 additions & 3 deletions services/autorust/codegen/src/cargo_toml.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,13 @@ pub enum Error {
pub fn create(crate_name: &str, tags: &[&Tag], default_tag: Option<&str>, path: &Path) -> Result<()> {
let file = File::create(path).map_err(|source| Error::IoError { source })?;
let mut file = LineWriter::new(file);
let default = get_default_feature(tags, default_tag);
let default_feature = get_default_feature(tags, default_tag);

// https://docs.rs/about/metadata
let docs_rs_features = docs_rs_features(tags, &default_feature);
let docs_rs_features: Vec<_> = docs_rs_features.iter().map(|s| format!("\"{}\"", s)).collect();
let docs_rs_features = docs_rs_features.join(", ");

file.write_all(
format!(
r#"# generated by AutoRust
Expand All @@ -41,15 +47,15 @@ azure_identity = {{ path = "../../../sdk/identity", version = "0.1" }}
tokio = {{ version = "1.0", features = ["macros"] }}
[package.metadata.docs.rs]
all-features = true
features = [{}]
[features]
default = ["{}", "enable_reqwest"]
enable_reqwest = ["azure_core/enable_reqwest"]
enable_reqwest_rustls = ["azure_core/enable_reqwest_rustls"]
no-default-version = []
"#,
crate_name, default
crate_name, docs_rs_features, default_feature
)
.as_bytes(),
)
Expand Down Expand Up @@ -77,3 +83,24 @@ fn get_default_feature(tags: &[&Tag], default_tag: Option<&str>) -> String {
None => tags[0].rust_feature_name(),
}
}

const MAX_DOCS_RS_FEATURES: usize = 4;
const NO_DEFAULT_VERSION: &str = "no-default-version";

/// Get a list of features to document at docs.rs in addition the default
fn docs_rs_features(tags: &[&Tag], default_feature: &str) -> Vec<String> {
let mut features: Vec<_> = tags
.iter()
.filter_map(|tag| {
let feature = tag.rust_feature_name();
if feature == default_feature {
None
} else {
Some(feature)
}
})
.collect();
features.truncate(MAX_DOCS_RS_FEATURES);
features.insert(0, NO_DEFAULT_VERSION.to_owned());
features
}
2 changes: 1 addition & 1 deletion services/mgmt/activedirectory/Cargo.toml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion services/mgmt/addons/Cargo.toml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion services/mgmt/adhybridhealthservice/Cargo.toml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion services/mgmt/adp/Cargo.toml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion services/mgmt/advisor/Cargo.toml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion services/mgmt/agrifood/Cargo.toml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion services/mgmt/alertsmanagement/Cargo.toml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion services/mgmt/analysisservices/Cargo.toml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion services/mgmt/apimanagement/Cargo.toml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion services/mgmt/app/Cargo.toml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion services/mgmt/appconfiguration/Cargo.toml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion services/mgmt/applicationinsights/Cargo.toml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion services/mgmt/appplatform/Cargo.toml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion services/mgmt/arcdata/Cargo.toml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion services/mgmt/attestation/Cargo.toml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion services/mgmt/authorization/Cargo.toml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion services/mgmt/automanage/Cargo.toml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion services/mgmt/automation/Cargo.toml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion services/mgmt/baremetalinfrastructure/Cargo.toml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion services/mgmt/batch/Cargo.toml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion services/mgmt/billing/Cargo.toml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion services/mgmt/blockchain/Cargo.toml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion services/mgmt/blueprint/Cargo.toml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion services/mgmt/botservice/Cargo.toml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion services/mgmt/cdn/Cargo.toml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion services/mgmt/changeanalysis/Cargo.toml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion services/mgmt/chaos/Cargo.toml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion services/mgmt/cloudshell/Cargo.toml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion services/mgmt/cognitiveservices/Cargo.toml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion services/mgmt/commerce/Cargo.toml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion services/mgmt/communication/Cargo.toml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion services/mgmt/compute/Cargo.toml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 5be8146

Please sign in to comment.