Class: Roby::GUI::ModelViews::ActionInterface
- Inherits:
-
MetaRuby::GUI::HTML::Collection
- Object
- MetaRuby::GUI::HTML::Collection
- Roby::GUI::ModelViews::ActionInterface
- Defined in:
- lib/roby/gui/model_views/action_interface.rb
Overview
Handler class to display information about an action interface
Class Method Summary collapse
- .find_definition_place(model) ⇒ Object
- .html_defined_in(page, model, with_require: true, definition_location: nil, format: "<b>Defined in</b> %s") ⇒ Object
Instance Method Summary collapse
Class Method Details
.find_definition_place(model) ⇒ Object
23 24 25 26 27 28 29 30 31 32 |
# File 'lib/roby/gui/model_views/action_interface.rb', line 23 def self.find_definition_place(model) location = model.definition_location.find do |location| break if location.label == "require" || location.label == "using_task_library" Roby.app.app_file?(location.absolute_path) end [location.absolute_path, location.lineno] if location end |
.html_defined_in(page, model, with_require: true, definition_location: nil, format: "<b>Defined in</b> %s") ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/roby/gui/model_views/action_interface.rb', line 34 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) return unless path path = Pathname.new(path) path_link = page.link_to(path, "#{path}:#{lineno}", lineno: lineno) page.push(nil, "<p>#{format(format, path_link)}</p>") return unless with_require req_base = $LOAD_PATH.find { |p| path.fnmatch?(File.join(p, "*")) } return unless req_base req = path.relative_path_from(Pathname.new(req_base)) page.push(nil, "<code>require '#{req.sub_ext('')}'</code>") end |
Instance Method Details
#compute_toplevel_links(model, options) ⇒ Object
8 9 10 11 12 13 14 |
# File 'lib/roby/gui/model_views/action_interface.rb', line 8 def compute_toplevel_links(model, ) 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, [:interactive]), action.name, {}) end end |
#render(model, options = {}) ⇒ Object
16 17 18 19 20 21 |
# File 'lib/roby/gui/model_views/action_interface.rb', line 16 def render(model, = {}) ActionInterface.html_defined_in(page, model, with_require: true) actions = compute_toplevel_links(model, ) render_links("Actions", actions) end |