nitc :: CmdGraph :: _allowed_formats
Allowed rendering formats.nitc :: CmdGraph :: allowed_formats=
Allowed rendering formats.nitc :: CmdGraph :: defaultinit
nitc :: CmdGraph :: mainmodule=
Mainmodule for linearizationnitc :: commands_http $ CmdGraph :: http_init
Init the command from an HTTPRequestnitc :: commands_parser $ CmdGraph :: parser_init
Initialize the command from the CommandParser datanitc :: json_commands $ CmdGraph :: to_json
Return a JSON Serializable representation ofself
results
nitc :: CmdGraph :: _allowed_formats
Allowed rendering formats.nitc :: CmdGraph :: allowed_formats=
Allowed rendering formats.core :: Object :: class_factory
Implementation used byget_class
to create the specific class.
nitc :: DocCommand :: cmd_filter
Return a new filter for that command execution.nitc :: DocCommand :: defaultinit
nitc :: CmdGraph :: defaultinit
core :: Object :: defaultinit
nitc :: DocCommand :: execute
nitc :: DocCommand :: filter=
ModelFilter to apply if anynitc :: DocCommand :: http_init
Init the command from an HTTPRequestcore :: Object :: is_same_instance
Return true ifself
and other
are the same instance (i.e. same identity).
core :: Object :: is_same_serialized
Isself
the same as other
in a serialization context?
core :: Object :: is_same_type
Return true ifself
and other
have the same dynamic type.
nitc :: CmdGraph :: mainmodule=
Mainmodule for linearizationcore :: Object :: native_class_name
The class name of the object in CString format.core :: Object :: output_class_name
Display class name on stdout (debug only).nitc :: DocCommand :: parser_init
Initialize the command from the CommandParser datanitc :: DocCommand :: to_json
Return a JSON Serializable representation ofself
results
# 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
redef class CmdGraph
redef fun parser_init(mentity_name, options) do
var opt_format = options.opt_string("format")
if opt_format != null then format = opt_format
return super
end
end
src/doc/commands/commands_parser.nit:363,1--369,3
redef class CmdGraph
redef fun to_json do
var obj = new JsonObject
var output = render
if output != null then
obj["graph"] = output.write_to_string
end
return obj
end
end
src/doc/templates/json_commands.nit:101,1--110,3