Skip to content

Commit e86823b

Browse files
authored
Merge pull request #907 from Lorak-mmk/workaround_macros_docs
Move derive macros docs to scylla crate
2 parents c9aecf4 + 7933112 commit e86823b

File tree

4 files changed

+76
-34
lines changed

4 files changed

+76
-34
lines changed

scylla-cql/src/lib.rs

+13-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,19 @@
11
pub mod errors;
22
pub mod frame;
33
#[macro_use]
4-
pub mod macros;
4+
pub mod macros {
5+
pub use scylla_macros::FromRow;
6+
pub use scylla_macros::FromUserType;
7+
pub use scylla_macros::IntoUserType;
8+
pub use scylla_macros::SerializeCql;
9+
pub use scylla_macros::SerializeRow;
10+
pub use scylla_macros::ValueList;
11+
12+
// Reexports for derive(IntoUserType)
13+
pub use bytes::{BufMut, Bytes, BytesMut};
14+
15+
pub use crate::impl_from_cql_value_from_method;
16+
}
517

618
pub mod types;
719

scylla-macros/src/lib.rs

+18-10
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ mod value_list;
99

1010
mod serialize;
1111

12-
/// See the documentation for this item in the `scylla` crate.
12+
/// Documentation for this macro can only be found
13+
/// in `scylla` crate - not in scylla-macros nor in scylla-cql.
14+
/// This is because of rustdocs limitations that are hard to explain here.
1315
#[proc_macro_derive(SerializeCql, attributes(scylla))]
1416
pub fn serialize_cql_derive(tokens_input: TokenStream) -> TokenStream {
1517
match serialize::cql::derive_serialize_cql(tokens_input) {
@@ -18,7 +20,9 @@ pub fn serialize_cql_derive(tokens_input: TokenStream) -> TokenStream {
1820
}
1921
}
2022

21-
/// See the documentation for this item in the `scylla` crate.
23+
/// Documentation for this macro can only be found
24+
/// in `scylla` crate - not in scylla-macros nor in scylla-cql.
25+
/// This is because of rustdocs limitations that are hard to explain here.
2226
#[proc_macro_derive(SerializeRow, attributes(scylla))]
2327
pub fn serialize_row_derive(tokens_input: TokenStream) -> TokenStream {
2428
match serialize::row::derive_serialize_row(tokens_input) {
@@ -27,32 +31,36 @@ pub fn serialize_row_derive(tokens_input: TokenStream) -> TokenStream {
2731
}
2832
}
2933

30-
/// #[derive(FromRow)] derives FromRow for struct
31-
/// Works only on simple structs without generics etc
34+
/// Documentation for this macro can only be found
35+
/// in `scylla` crate - not in scylla-macros nor in scylla-cql.
36+
/// This is because of rustdocs limitations that are hard to explain here.
3237
#[proc_macro_derive(FromRow, attributes(scylla_crate))]
3338
pub fn from_row_derive(tokens_input: TokenStream) -> TokenStream {
3439
let res = from_row::from_row_derive(tokens_input);
3540
res.unwrap_or_else(|e| e.into_compile_error().into())
3641
}
3742

38-
/// #[derive(FromUserType)] allows to parse a struct as User Defined Type
39-
/// Works only on simple structs without generics etc
43+
/// Documentation for this macro can only be found
44+
/// in `scylla` crate - not in scylla-macros nor in scylla-cql.
45+
/// This is because of rustdocs limitations that are hard to explain here.
4046
#[proc_macro_derive(FromUserType, attributes(scylla_crate))]
4147
pub fn from_user_type_derive(tokens_input: TokenStream) -> TokenStream {
4248
let res = from_user_type::from_user_type_derive(tokens_input);
4349
res.unwrap_or_else(|e| e.into_compile_error().into())
4450
}
4551

46-
/// #[derive(IntoUserType)] allows to parse a struct as User Defined Type
47-
/// Works only on simple structs without generics etc
52+
/// Documentation for this macro can only be found
53+
/// in `scylla` crate - not in scylla-macros nor in scylla-cql.
54+
/// This is because of rustdocs limitations that are hard to explain here.
4855
#[proc_macro_derive(IntoUserType, attributes(scylla_crate))]
4956
pub fn into_user_type_derive(tokens_input: TokenStream) -> TokenStream {
5057
let res = into_user_type::into_user_type_derive(tokens_input);
5158
res.unwrap_or_else(|e| e.into_compile_error().into())
5259
}
5360

54-
/// #[derive(ValueList)] derives ValueList for struct
55-
/// Works only on simple structs without generics etc
61+
/// Documentation for this macro can only be found
62+
/// in `scylla` crate - not in scylla-macros nor in scylla-cql.
63+
/// This is because of rustdocs limitations that are hard to explain here.
5664
#[proc_macro_derive(ValueList, attributes(scylla_crate))]
5765
pub fn value_list_derive(tokens_input: TokenStream) -> TokenStream {
5866
let res = value_list::value_list_derive(tokens_input);

scylla/src/lib.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,11 @@ pub mod _macro_internal {
9898
pub use scylla_cql::_macro_internal::*;
9999
}
100100

101+
pub mod macros;
102+
#[doc(inline)]
103+
pub use macros::*;
104+
101105
pub use scylla_cql::frame;
102-
pub use scylla_cql::macros::{self, *};
103106
pub use scylla_cql::types::serialize;
104107

105108
pub mod authentication;

scylla-cql/src/macros.rs scylla/src/macros.rs

+41-22
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,28 @@
11
/// #[derive(FromRow)] derives FromRow for struct
2+
///
23
/// Works only on simple structs without generics etc
3-
pub use scylla_macros::FromRow;
4+
///
5+
/// ---
6+
///
7+
pub use scylla_cql::macros::FromRow;
48

59
/// #[derive(FromUserType)] allows to parse struct as a User Defined Type
10+
///
611
/// Works only on simple structs without generics etc
7-
pub use scylla_macros::FromUserType;
12+
///
13+
/// ---
14+
///
15+
pub use scylla_cql::macros::FromUserType;
816

917
/// #[derive(IntoUserType)] allows to pass struct a User Defined Type Value in queries
18+
///
1019
/// Works only on simple structs without generics etc
11-
pub use scylla_macros::IntoUserType;
12-
13-
/// #[derive(ValueList)] allows to pass struct as a list of values for a query
14-
pub use scylla_macros::ValueList;
20+
///
21+
/// ---
22+
///
23+
pub use scylla_cql::macros::IntoUserType;
1524

16-
/// Derive macro for the [`SerializeCql`](crate::types::serialize::value::SerializeCql) trait
25+
/// Derive macro for the [`SerializeCql`](crate::serialize::value::SerializeCql) trait
1726
/// which serializes given Rust structure as a User Defined Type (UDT).
1827
///
1928
/// At the moment, only structs with named fields are supported.
@@ -31,8 +40,8 @@ pub use scylla_macros::ValueList;
3140
/// This behavior is the default to support ALTERing UDTs by adding new fields.
3241
/// You can require exact match of fields using `force_exact_match` attribute.
3342
///
34-
/// In case of failure, either [`BuiltinTypeCheckError`](crate::types::serialize::value::BuiltinTypeCheckError)
35-
/// or [`BuiltinSerializationError`](crate::types::serialize::value::BuiltinSerializationError)
43+
/// In case of failure, either [`BuiltinTypeCheckError`](crate::serialize::value::BuiltinTypeCheckError)
44+
/// or [`BuiltinSerializationError`](crate::serialize::value::BuiltinSerializationError)
3645
/// will be returned.
3746
///
3847
/// # Example
@@ -46,9 +55,8 @@ pub use scylla_macros::ValueList;
4655
/// ...can be serialized using the following struct:
4756
///
4857
/// ```rust
49-
/// # use scylla_cql::macros::SerializeCql;
58+
/// # use scylla::SerializeCql;
5059
/// #[derive(SerializeCql)]
51-
/// # #[scylla(crate = scylla_cql)]
5260
/// struct MyUdt {
5361
/// a: i32,
5462
/// b: Option<String>,
@@ -77,7 +85,7 @@ pub use scylla_macros::ValueList;
7785
///
7886
/// By default, the code generated by the derive macro will refer to the items
7987
/// defined by the driver (types, traits, etc.) via the `::scylla` path.
80-
/// For example, it will refer to the [`SerializeCql`](crate::types::serialize::value::SerializeCql) trait
88+
/// For example, it will refer to the [`SerializeCql`](crate::serialize::value::SerializeCql) trait
8189
/// using the following path:
8290
///
8391
/// ```rust,ignore
@@ -121,18 +129,21 @@ pub use scylla_macros::ValueList;
121129
/// `#[scylla(skip)]`
122130
///
123131
/// Don't use the field during serialization.
124-
pub use scylla_macros::SerializeCql;
132+
///
133+
/// ---
134+
///
135+
pub use scylla_cql::macros::SerializeCql;
125136

126-
/// Derive macro for the [`SerializeRow`](crate::types::serialize::row::SerializeRow) trait
137+
/// Derive macro for the [`SerializeRow`](crate::serialize::row::SerializeRow) trait
127138
/// which serializes given Rust structure into bind markers for a CQL statement.
128139
///
129140
/// At the moment, only structs with named fields are supported.
130141
///
131142
/// Serialization will fail if there are some bind markers/columns in the statement
132143
/// that don't match to any of the Rust struct fields, _or vice versa_.
133144
///
134-
/// In case of failure, either [`BuiltinTypeCheckError`](crate::types::serialize::row::BuiltinTypeCheckError)
135-
/// or [`BuiltinSerializationError`](crate::types::serialize::row::BuiltinSerializationError)
145+
/// In case of failure, either [`BuiltinTypeCheckError`](crate::serialize::row::BuiltinTypeCheckError)
146+
/// or [`BuiltinSerializationError`](crate::serialize::row::BuiltinSerializationError)
136147
/// will be returned.
137148
///
138149
/// # Example
@@ -148,9 +159,8 @@ pub use scylla_macros::SerializeCql;
148159
/// ...the values for the query can be serialized using the following struct:
149160
///
150161
/// ```rust
151-
/// # use scylla_cql::macros::SerializeRow;
162+
/// # use scylla::SerializeRow;
152163
/// #[derive(SerializeRow)]
153-
/// # #[scylla(crate = scylla_cql)]
154164
/// struct MyValues {
155165
/// a: i32,
156166
/// b: Option<String>,
@@ -179,7 +189,7 @@ pub use scylla_macros::SerializeCql;
179189
///
180190
/// By default, the code generated by the derive macro will refer to the items
181191
/// defined by the driver (types, traits, etc.) via the `::scylla` path.
182-
/// For example, it will refer to the [`SerializeRow`](crate::types::serialize::row::SerializeRow) trait
192+
/// For example, it will refer to the [`SerializeRow`](crate::serialize::row::SerializeRow) trait
183193
/// using the following path:
184194
///
185195
/// ```rust,ignore
@@ -219,9 +229,18 @@ pub use scylla_macros::SerializeCql;
219229
/// `#[scylla(skip)]`
220230
///
221231
/// Don't use the field during serialization.
222-
pub use scylla_macros::SerializeRow;
232+
///
233+
/// ---
234+
///
235+
pub use scylla_cql::macros::SerializeRow;
236+
237+
/// #[derive(ValueList)] allows to pass struct as a list of values for a query
238+
///
239+
/// ---
240+
///
241+
pub use scylla_cql::macros::ValueList;
242+
243+
pub use scylla_cql::macros::impl_from_cql_value_from_method;
223244

224245
// Reexports for derive(IntoUserType)
225246
pub use bytes::{BufMut, Bytes, BytesMut};
226-
227-
pub use crate::impl_from_cql_value_from_method;

0 commit comments

Comments
 (0)