morazanm / fsm

A DSL for the Automata Theory Classroom
14 stars 6 forks source link

feat: quality of life updates to gviz-lib #88

Closed jschappel closed 1 year ago

jschappel commented 1 year ago

About

This PR exports two new functions:

  1. create-formatters
  2. graph->png

This PR also updates graph->svg and graph->bitmap functions to delete the .png and .dot files by default. All functions are updated in the developer docs.

Breaking features

This PR pushes a breaking change to the function graph->bitmap. Originally a filename was required when calling this function (i.e)

(graph->bitmap my-graph (current-directory) "test")
(delete-file "test.png")
(delete-file "test.dot")

However now the filename and directory are optional keyword args since the .dot and .png files are deleted by default. If a filename is not specified then the default name __tmp__ is used instead. If the directory is not specified then the systems tmp directory is used.

;; generate and cleanup files in the systems tmp directory using the default name
(graph->bitmap my-graph)

;; generate and cleanup files in using specified directory and filename
(graph->bitmap my-graph #:directory (current-directory) #:filename "test")

Additionally, if you want to save the generated files then you need to set the keyword arg #:clean #f

;; test.dot and test.png are not deleted 
(graph->bitmap my-graph #:filename "test" #:clean #f)