@@ -92,12 +92,12 @@ impl DocFragment for LuaDocFragment {
92
92
. fold ( TypeWalker :: new ( ) , |a, v| ( v. builder ) ( a) ) ;
93
93
94
94
// generate json file
95
- let mut json = serde_json:: to_string_pretty ( & tw)
95
+ let json = serde_json:: to_string_pretty ( & tw)
96
96
. map_err ( |e| ScriptError :: DocGenError ( e. to_string ( ) ) ) ?;
97
97
98
98
// 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}");
101
101
102
102
let json_path = script_doc_dir. join ( format ! ( "{}.json" , docs_name) ) ;
103
103
@@ -125,23 +125,27 @@ impl DocFragment for LuaDocFragment {
125
125
126
126
#[ cfg( feature = "teal" ) ]
127
127
{
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
+ } ) ?;
145
149
146
150
// finally create a tlconfig.lua file if doesn't exist
147
151
// we do this to avoid problems with varying teal configurations
0 commit comments