@@ -32,7 +32,7 @@ pub fn generate_type_markdown(
3232 } else if typ. is_enum ( ) {
3333 generate_enum_type_markdown ( db, tl, typ, & mut context, output, mkdocs_index) ;
3434 } else {
35- // generate_other_type_markdown (db, tl, typ, &mut context, input, output, mkdocs_index)? ;
35+ generate_alias_type_markdown ( db, tl, typ, & mut context, output, mkdocs_index) ;
3636 }
3737 Some ( ( ) )
3838}
@@ -284,3 +284,56 @@ pub struct EnumMember {
284284 pub value : String ,
285285 pub description : String ,
286286}
287+
288+ fn generate_alias_type_markdown (
289+ db : & DbIndex ,
290+ tl : & Tera ,
291+ typ : & LuaTypeDecl ,
292+ context : & mut Context ,
293+ output : & Path ,
294+ mkdocs_index : & mut MkdocsIndex ,
295+ ) -> Option < ( ) > {
296+ let typ_name = typ. get_name ( ) ;
297+ let typ_id = typ. get_id ( ) ;
298+ let namespace = typ. get_namespace ( ) ;
299+ context. insert ( "namespace" , & namespace) ;
300+
301+ let type_property_id = LuaPropertyOwnerId :: TypeDecl ( typ_id. clone ( ) ) ;
302+ let typ_property = db. get_property_index ( ) . get_property ( type_property_id) ;
303+ if let Some ( typ_property) = typ_property {
304+ if let Some ( property_text) = & typ_property. description {
305+ context. insert ( "description" , & property_text) ;
306+ }
307+ }
308+
309+ if let Some ( origin_typ) = typ. get_alias_origin ( db, None ) {
310+ let origin_typ_display = humanize_type ( db, & origin_typ, RenderLevel :: Detailed ) ;
311+ let display = format ! ( "```lua\n (alias) {} = {}\n ```\n " , typ_name, origin_typ_display) ;
312+ context. insert ( "origin_type" , & display) ;
313+ }
314+
315+ let render_text = match tl. render ( "lua_alias_template.tl" , & context) {
316+ Ok ( text) => text,
317+ Err ( e) => {
318+ eprintln ! ( "Failed to render template: {}" , e) ;
319+ return None ;
320+ }
321+ } ;
322+
323+ let file_type_name = format ! ( "{}.md" , escape_type_name( typ. get_full_name( ) ) ) ;
324+ mkdocs_index. types . push ( IndexStruct {
325+ name : format ! ( "alias {}" , typ_name) ,
326+ file : format ! ( "types/{}" , file_type_name. clone( ) ) ,
327+ } ) ;
328+
329+ let outpath = output. join ( file_type_name) ;
330+ println ! ( "output type file: {}" , outpath. display( ) ) ;
331+ match std:: fs:: write ( outpath, render_text) {
332+ Ok ( _) => { }
333+ Err ( e) => {
334+ eprintln ! ( "Failed to write file: {}" , e) ;
335+ return None ;
336+ }
337+ }
338+ Some ( ( ) )
339+ }
0 commit comments