@@ -6,6 +6,7 @@ pub struct CustomEnumType {
66 pub raw_type : String ,
77 pub value : Option < String > ,
88 pub snake_case_name : String ,
9+ pub doc_str : Option < Vec < String > > ,
910}
1011
1112fn camel_to_snake_case ( variable_name : & str ) -> String {
@@ -79,14 +80,17 @@ impl EnumBindGenerator {
7980 } )
8081 }
8182
82- pub fn raw_types_to_custom ( raw_types : Vec < ( & str , & str ) > ) -> Vec < CustomEnumType > {
83+ pub fn raw_types_to_custom (
84+ raw_types : Vec < ( & str , & str , Option < Vec < String > > ) > ,
85+ ) -> Vec < CustomEnumType > {
8386 raw_types
8487 . into_iter ( )
85- . map ( |( name, raw_type) | CustomEnumType {
88+ . map ( |( name, raw_type, doc_str ) | CustomEnumType {
8689 name : name. to_string ( ) ,
8790 raw_type : raw_type. to_string ( ) ,
8891 value : None ,
8992 snake_case_name : String :: new ( ) ,
93+ doc_str,
9094 } )
9195 . collect ( )
9296 }
@@ -103,6 +107,7 @@ impl EnumBindGenerator {
103107 let mut file_line_start = struct_pos + impl_pos + impl_definition. len ( ) ;
104108 let mut lines = contents[ file_line_start..] . split ( '\n' ) ;
105109 let mut types = Vec :: new ( ) ;
110+ let mut docs = Vec :: new ( ) ;
106111
107112 loop {
108113 let line = lines. next ( ) ?;
@@ -112,8 +117,15 @@ impl EnumBindGenerator {
112117 break ;
113118 }
114119
120+ if line_trim. starts_with ( "///" ) {
121+ docs. push ( line_trim. trim_start_matches ( "///" ) . trim ( ) . to_string ( ) ) ;
122+ file_line_start += line. len ( ) ;
123+ continue ;
124+ }
125+
115126 if line_trim. starts_with ( "//" ) {
116127 file_line_start += line. len ( ) ;
128+ docs. clear ( ) ;
117129 continue ;
118130 }
119131
@@ -129,7 +141,16 @@ impl EnumBindGenerator {
129141 . trim_start_matches ( "Self(" )
130142 . trim_end_matches ( ')' ) ;
131143
132- types. push ( ( variable_name, variable_value) ) ;
144+ let docs = if docs. is_empty ( ) {
145+ None
146+ } else {
147+ let docs_copy = docs. clone ( ) ;
148+ docs. clear ( ) ;
149+
150+ Some ( docs_copy)
151+ } ;
152+
153+ types. push ( ( variable_name, variable_value, docs) ) ;
133154
134155 file_line_start += line. len ( ) ;
135156 }
0 commit comments