@@ -92,12 +92,12 @@ impl DocFragment for LuaDocFragment {
9292 . fold ( TypeWalker :: new ( ) , |a, v| ( v. builder ) ( a) ) ;
9393
9494 // generate json file
95- let mut json = serde_json:: to_string_pretty ( & tw)
95+ let json = serde_json:: to_string_pretty ( & tw)
9696 . map_err ( |e| ScriptError :: DocGenError ( e. to_string ( ) ) ) ?;
9797
9898 // temporary fix for incompatibility in json formats
99- json. remove ( json. len ( ) - 1 ) ;
100- json. push_str ( ",\n \" tealr_version_used\" : \" 0.9.0-alpha3\" ,\n \" extra_page\" : []\n }" ) ;
99+ // json.remove(json.len() - 1);
100+ // json.push_str(",\n\"tealr_version_used\": \"0.9.0-alpha3\",\n\"extra_page\": []\n}");
101101
102102 let json_path = script_doc_dir. join ( format ! ( "{}.json" , docs_name) ) ;
103103
@@ -125,23 +125,27 @@ impl DocFragment for LuaDocFragment {
125125
126126 #[ cfg( feature = "teal" ) ]
127127 {
128- // now generate teal declaration (d.tl) file
129-
130- let script_types_dir = & script_asset_path. join ( "types" ) ;
131- fs:: create_dir_all ( script_types_dir)
132- . expect ( "Could not create `.../assets/scripts/types` directories" ) ;
133-
134- let decl_path = & script_types_dir. join ( "types.d.tl" ) ;
135- // generate declaration file
136- let decl_file_contents = tw. generate ( "types" , true ) . unwrap ( ) ;
137-
138- let mut decl_file =
139- File :: create ( decl_path) . map_err ( |e| ScriptError :: DocGenError ( e. to_string ( ) ) ) ?;
140-
141- decl_file
142- . write_all ( decl_file_contents. as_bytes ( ) )
143- . expect ( "Failed to write to declaration file" ) ;
144- decl_file. flush ( ) . unwrap ( ) ;
128+ // now manage the definition (d.tl) file
129+ let definition_directory = script_asset_path. join ( "types" ) ;
130+ fs:: create_dir_all ( & definition_directory) . map_err ( |e| {
131+ ScriptError :: DocGenError ( format ! (
132+ "Could not create `{}` directories: {e}" ,
133+ & definition_directory. display( )
134+ ) )
135+ } ) ?;
136+
137+ let definition_file_path = script_doc_dir
138+ . join ( & docs_name)
139+ . join ( "definitions" )
140+ . join ( docs_name + ".d.tl" ) ;
141+ let output_definition_file_path = script_asset_path. join ( "types" ) . join ( "types.d.tl" ) ;
142+ fs:: copy ( & definition_file_path, & output_definition_file_path) . map_err ( |e| {
143+ ScriptError :: DocGenError ( format ! (
144+ "Could not copy definition file from `{}` to `{}`: {e}" ,
145+ definition_file_path. display( ) ,
146+ output_definition_file_path. display( )
147+ ) )
148+ } ) ?;
145149
146150 // finally create a tlconfig.lua file if doesn't exist
147151 // we do this to avoid problems with varying teal configurations
0 commit comments