class Roby::GUI::ModelViews::ActionInterface
Handler class to display information about an action interface
Public Class Methods
find_definition_place(model)
click to toggle source
# File lib/roby/gui/model_views/action_interface.rb, line 25 def self.find_definition_place(model) location = model.definition_location.find do |location| return if location.label == 'require' || location.label == 'using_task_library' Roby.app.app_file?(location.absolute_path) end if location return location.absolute_path, location.lineno end end
html_defined_in(page, model, with_require: true, definition_location: nil, format: "<b>Defined in</b> %s")
click to toggle source
# File lib/roby/gui/model_views/action_interface.rb, line 35 def self.html_defined_in(page, model, with_require: true, definition_location: nil, format: "<b>Defined in</b> %s") path, lineno = *definition_location || find_definition_place(model) if path path = Pathname.new(path) path_link = page.link_to(path, "#{path}:#{lineno}", lineno: lineno) page.push(nil, "<p>#{format % [path_link]}</p>") if with_require if req_base = $LOAD_PATH.find { |p| path.fnmatch?(File.join(p, "*")) } req = path.relative_path_from(Pathname.new(req_base)) page.push(nil, "<code>require '#{req.sub_ext("")}'</code>") end end end end
new(page)
click to toggle source
Calls superclass method
# File lib/roby/gui/model_views/action_interface.rb, line 6 def initialize(page) super end
Public Instance Methods
compute_toplevel_links(model, options)
click to toggle source
# File lib/roby/gui/model_views/action_interface.rb, line 10 def compute_toplevel_links(model, options) actions = model.each_action.map do |action| arguments = action.arguments.map { |arg| ":#{arg.name}" }.join(", ") format = "#{action.name}(#{arguments}) => #{page.link_to(action.returned_type)}: #{action.doc}" Element.new(action.name, format, element_link_target(action, options[:interactive]), action.name, Hash.new) end end
render(model, options = Hash.new)
click to toggle source
# File lib/roby/gui/model_views/action_interface.rb, line 18 def render(model, options = Hash.new) ActionInterface.html_defined_in(page, model, with_require: true) actions = compute_toplevel_links(model, options) render_links('Actions', actions) end