graphviz_main.anubis 1.49 KB
/*
 * Created by PyramIDE.
 * User: フランスのトトロ aka (David RENÉ) 
 * Date: 05/04/2017
 * Time: 20:33
 * © Calexium 
 */

read tools/basis.anubis
read tools/streams.anubis
read system/string.anubis
read densaku_lib/types/densaku.anubis
read generation/graphviz/graphviz_header.anubis
read generation/graphviz/graphviz_type.anubis

public define Maybe(One)
  make_graphviz_types
  (
    DS_Type_File_Output_Dir   out_dir,
    DS_Type_File_Output_Name  output_file_name,    
    List(DS_Type)             types,
    String                    destination_dir
  )=
  with final_destination_dir = 
    if out_dir is
    {
      auto                  then  destination_dir + "types/generated/",
      relative_path(path)   then  destination_dir + path + "/",
      absolute_path(path)   then  path
    },

  with file_name = if output_file_name is 
  {
    auto              then final_destination_dir+"graphviz.gv",
    name(_file_name)  then final_destination_dir+to_lower(_file_name)+".gv",
  },
  
  if file(file_name, new) is
  {
    failure     then  println("can't create file "+file_name);failure,
    success(fd) then 
      with strm = make_stream(fd),
      
      if generate_graphviz_header(strm)                     is { failure then failure, success(_) then
      if generate_graphviz_types(strm, types)               is { failure then failure, success(_) then
      if generate_graphviz_footer(strm)                     is { failure then failure, success(_) then
        success(unique)
      }}}
  }
.