Skip to content

Commit

Permalink
rename sync_routes_default feature to sync_routes_in_root and improve…
Browse files Browse the repository at this point in the history
… docs around that (#157)

In particular, don't show that feature on docs.rs, it clutters it too much.
  • Loading branch information
wfraser authored Oct 31, 2024
1 parent 878d1a9 commit 08e803c
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 19 deletions.
6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ dbx_users = ["dbx_common", "dbx_team_common", "dbx_team_policies", "dbx_users_co
dbx_users_common = ["dbx_common"]

default_async_client = ["async_routes", "dep:reqwest"]
default_client = ["sync_routes", "sync_routes_default", "dep:ureq"]
default_client = ["sync_routes", "sync_routes_in_root", "dep:ureq"]

# Enable unstable ("preview") API routes.
unstable = []
Expand All @@ -109,7 +109,7 @@ async_routes = []

# Re-export the sync routes as `dropbox_sdk::{namsepace}` directly (matches pre-v0.19 structure).
# If disabled, export the async routes there instead.
sync_routes_default = ["sync_routes"]
sync_routes_in_root = ["sync_routes"]

# Include all namespaces by default.
# Enable sync default client, sync routes, and make the sync routes default, to match pre-v0.19.
Expand All @@ -136,7 +136,7 @@ default = [
"dbx_users_common",
"default_client",
"sync_routes",
"sync_routes_default",
"sync_routes_in_root",
]

[package.metadata.docs.rs]
Expand Down
6 changes: 0 additions & 6 deletions generator/rust.stoneg.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,9 @@ def generate(self, api: ir.Api) -> None:
self.emit()
with self.block('if_feature! { "async_routes",', delim=(None, '}')):
self.emit('pub mod async_routes;')
with self.block('if_feature! { not "sync_routes_default",', delim=(None, '}')):
self.emit('#[allow(unused_imports)]')
self.emit(f'pub use crate::generated::async_routes::*;')
self.emit()
with self.block('if_feature! { "sync_routes",', delim=(None, '}')):
self.emit('pub mod sync_routes;')
with self.block('if_feature! { "sync_routes_default",', delim=(None, '}')):
self.emit('#[allow(unused_imports)]')
self.emit(f'pub use crate::generated::sync_routes::*;')
self.emit()
with self.block('pub(crate) fn eat_json_fields<\'de, V>(map: &mut V)'
' -> Result<(), V::Error>'
Expand Down
8 changes: 0 additions & 8 deletions src/generated/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,10 @@ pub mod types;

if_feature! { "async_routes",
pub mod async_routes;
if_feature! { not "sync_routes_default",
#[allow(unused_imports)]
pub use crate::generated::async_routes::*;
}
}

if_feature! { "sync_routes",
pub mod sync_routes;
if_feature! { "sync_routes_default",
#[allow(unused_imports)]
pub use crate::generated::sync_routes::*;
}
}

pub(crate) fn eat_json_fields<'de, V>(map: &mut V) -> Result<(), V::Error> where V: ::serde::de::MapAccess<'de> {
Expand Down
10 changes: 9 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ if_feature! { "default_client",
pub mod default_client;

// for backwards-compat only; don't match this for async
if_feature! { "sync_routes_default",
if_feature! { "sync_routes_in_root",
pub use client_trait::*;
}
}
Expand All @@ -61,5 +61,13 @@ mod generated;
// You need to run the Stone generator to create this module.
pub use generated::*;

#[cfg(feature = "async_routes")]
#[cfg(not(feature = "sync_routes_in_root"))]
pub use generated::async_routes::*;

#[cfg(feature = "sync_routes")]
#[cfg(feature = "sync_routes_in_root")]
pub use generated::sync_routes::*;

mod error;
pub use error::{BoxedError, Error, NoError};
2 changes: 1 addition & 1 deletion src/oauth2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ impl Authorization {
}
}

if_feature! { "sync_routes_default",
if_feature! { "sync_routes",
/// Compatibility shim for working with sync HTTP clients.
pub fn obtain_access_token(
&mut self,
Expand Down

0 comments on commit 08e803c

Please sign in to comment.