nitc :: CmdGraph :: defaultinit
# An abstract command that returns a dot graph
abstract class CmdGraph
super DocCommand
# Mainmodule for linearization
var mainmodule: MModule
# Rendering format
#
# Default is `dot`.
# See `allowed_formats`.
var format = "dot" is optional, writable
# Allowed rendering formats.
#
# Can be `dot` or `svg`.
var allowed_formats: Array[String] = ["dot", "svg"]
# Dot to render
var dot: nullable Writable = null is optional, writable
# Render `dot` depending on `format`
fun render: nullable Writable do
var dot = self.dot
if dot == null then return null
if format == "svg" then
var proc = new ProcessDuplex("dot", "-Tsvg")
var svg = proc.write_and_read(dot.write_to_string)
proc.close
proc.wait
return svg
end
return dot
end
redef fun init_command do
if not allowed_formats.has(format) then
return new ErrorBadGraphFormat(format, allowed_formats)
end
return super
end
end
src/doc/commands/commands_graph.nit:25,1--66,3