Class: Codnar::GraphViz

Inherits:
Object
  • Object
show all
Defined in:
lib/codnar/graphviz.rb

Overview

Generate diagrams using GraphViz.

Class Method Summary collapse

Class Method Details

.to_html(diagram) ⇒ Object

Convert a string containing a GraphViz diagram into SVG suitable for embedding into the HTML documentation. We pre-process the diagram using M4 to allow cutting down on the boilerplate (repeating the same styles in many nodes etc.). This should not be harmful for diagrams that do not use M4 commands.



11
12
13
14
15
16
# File 'lib/codnar/graphviz.rb', line 11

def self.to_html(diagram)
  stdin, stdout, stderr = Open3.popen3("m4 | dot -Tsvg")
  write_diagram(stdin, diagram)
  check_for_errors(stderr)
  return clean_output(stdout)
end