class Rock::Doc::HTML::TypeRenderingContext

Attributes

consumed_by[R]
displayed_by[R]
intermediate_type[R]
produced_by[R]
ruby_type[R]

Public Class Methods

new(object) click to toggle source
Calls superclass method Rock::Doc::HTML::RenderingContext.new
# File lib/rock/doc.rb, line 194
def initialize(object)
    super(object, 'orogen_type_fragment.page')
    @produced_by = []
    @consumed_by = []
    @displayed_by = []
end

Public Instance Methods

has_convertions?(type, recursive = true) click to toggle source
# File lib/rock/doc.rb, line 201
def has_convertions?(type, recursive = true)
    if type <= Typelib::NumericType
        return false
    elsif type.convertion_to_ruby
        return true
    end
    return if !recursive

    if type < Typelib::CompoundType
        type.enum_for(:each_field).any? do |field_name, field_type|
            has_convertions?(field_type, false)
        end
    elsif type < Typelib::EnumType
        false
    elsif type.respond_to?(:deference)
        return has_convertions?(type.deference, false)
    else
        raise NotImplementedError
    end
end
render(*template_path) click to toggle source
# File lib/rock/doc.rb, line 286
def render(*template_path)
    base = self.type
    typekit = Orocos.load_typekit_for(base, false)

    if base.contains_opaques?
        @intermediate_type = typekit.intermediate_type_for(type)
        if has_convertions?(intermediate_type)
            @ruby_type = intermediate_type
        end
    elsif has_convertions?(base)
        @ruby_type = base
    end

    super
end
render_convertion_spec(base_type, convertion) click to toggle source
# File lib/rock/doc.rb, line 222
def render_convertion_spec(base_type, convertion)
    if spec = convertion[0]
        if spec == Array
            # The base type is most likely an array or a container.
            # Display the element type as well ...
            if base_type.respond_to?(:deference)
                if subconv = base_type.deference.convertion_to_ruby
                    return "Array(#{render_convertion_spec(base_type.deference, subconv)})"
                else
                    return "Array(#{link_to(base_type.deference)})"
                end
            end
        end
        convertion[0].name

    else
        "converted to an unspecified type"
    end
end
render_type_convertion(type) click to toggle source
# File lib/rock/doc.rb, line 242
def render_type_convertion(type)
    result = []
    if convertion = type.convertion_to_ruby
        result << render_convertion_spec(type, convertion)
    elsif type < Typelib::CompoundType
        result << "<ul class=\"body-header-list\">"
        type.each_field do |field_name, field_type|
            if convertion = field_type.convertion_to_ruby
                result << render_item(field_name, render_convertion_spec(field_type, convertion))
            else
                result << render_item(field_name, link_to(field_type))
            end
        end
        result << "</ul>"
    elsif type < Typelib::ArrayType
        result << "<ul class=\"body-header-list\">"
        deference =
            if convertion = type.deference.convertion_to_ruby
                render_convertion_spec(type.deference, convertion)
            else
                render_convertion_spec(type.deference, [Array])
            end
        result << "<li>#{deference}[#{type.length}]</li>"
        result << "</ul>"
    elsif type < Typelib::ContainerType
        result << "<ul class=\"body-header-list\">"
        deference =
            if convertion = type.deference.convertion_to_ruby
                render_convertion_spec(type.deference, convertion)
            else
                link_to(type.deference)
            end
        result << "<li>Array(#{deference})</li>"
        result << "</ul>"
    else
        raise NotImplementedError
    end
    result.join("\n")
end
render_type_definition_fragment(type) click to toggle source
# File lib/rock/doc.rb, line 282
def render_type_definition_fragment(type)
    HTML.render_template("type_definition_fragment.page", binding)
end
type() click to toggle source
# File lib/rock/doc.rb, line 186
def type; @object end