@@ -220,12 +220,13 @@ impl Module {
220
220
} )
221
221
. map ( TryInto :: try_into)
222
222
. map_ok ( |it| Rc :: new ( RefCell :: new ( it) ) )
223
- // .collect::<Vec<RType>>();
224
223
. collect :: < Result < _ > > ( ) ?;
225
224
self . loaded = true ;
226
225
Ok ( self )
227
226
}
228
227
228
+ /// Expand `inherit_variants` macros to their inner enum.
229
+ /// This would also populate `inherits` field of `EnumMeta` types.
229
230
pub fn expand ( self ) -> Result < Self > {
230
231
if !self . loaded {
231
232
return Err ( String :: from ( LOAD_ERROR ) ) ;
@@ -235,6 +236,7 @@ impl Module {
235
236
Ok ( self )
236
237
}
237
238
239
+ /// Fills the Meta types.
238
240
pub fn analyze ( self ) -> Result < Self > {
239
241
if !self . loaded {
240
242
return Err ( String :: from ( LOAD_ERROR ) ) ;
@@ -250,6 +252,7 @@ impl Module {
250
252
}
251
253
252
254
let definitions = Definitions {
255
+ // We filter map to get rid of stuff we don't need in our schema.
253
256
types : self . items . into_iter ( ) . filter_map ( |it| ( & * it. borrow ( ) ) . into ( ) ) . collect ( ) ,
254
257
} ;
255
258
Ok ( Schema { source : self . path , definitions } )
@@ -262,6 +265,11 @@ pub fn expand(type_def: &TypeRef) -> Result<()> {
262
265
let ( enum_, inherits) = mac
263
266
. mac
264
267
. parse_body_with ( |input : & ParseBuffer | {
268
+ // Because of `@inherit`s we can't use the actual `ItemEnum` parse,
269
+ // This closure is similar to how `ItemEnum` parser works, With the exception
270
+ // of how we approach our variants, First we try to parse a variant out of our
271
+ // tokens if we fail we try parsing the inheritance, And we would raise an
272
+ // error only if both of these fail.
265
273
let attrs = input. call ( Attribute :: parse_outer) ?;
266
274
let vis = input. parse :: < Visibility > ( ) ?;
267
275
let enum_token = input. parse :: < Token ! [ enum ] > ( ) ?;
0 commit comments