class JsDuck::Render::Subproperties
Renders params, return values and everything else that can have nested subproperties.
Public Instance Methods
render(item)
click to toggle source
Renders object properties, which could also be functions in which case they will be rendered with parameters and return value.
# File lib/jsduck/render/subproperties.rb, line 16 def render(item) doc = [] if item[:type] == "Function" params = item[:properties] # If the name of last property is "return" remove it from # properties list and format as a return value afterwards. if item[:properties].last[:name] == "return" ret = params.last params = params.slice(0, params.length-1) end doc << render_params(params) doc << render_return(ret) if ret else doc << render_list(item[:properties]) end doc end
render_list(params)
click to toggle source
# File lib/jsduck/render/subproperties.rb, line 44 def render_list(params) return [ "<ul>", params.map {|p| render_single_param(p) }, "</ul>", ] end
render_new()
click to toggle source
# File lib/jsduck/render/subproperties.rb, line 69 def render_new signature = TagRegistry.get_by_name(:new).signature return [ "<span class='signature'>", "<span class='new' title='#{signature[:tooltip]}'>", signature[:long], "</span>", "</span>", ] end
render_params(params)
click to toggle source
# File lib/jsduck/render/subproperties.rb, line 37 def render_params(params) return [ '<h3 class="pa">Parameters</h3>', render_list(params), ] end
render_return(ret)
click to toggle source
# File lib/jsduck/render/subproperties.rb, line 84 def render_return(ret) return [ "<h3 class='pa'>Returns</h3>", "<ul>", "<li>", "<span class='pre'>#{ret[:html_type]}</span>", "<div class='sub-desc'>", ret[:doc], ret[:properties] && ret[:properties].length > 0 ? render(ret) : "", "</div>", "</li>", "</ul>", ] end
render_since(param)
click to toggle source
# File lib/jsduck/render/subproperties.rb, line 80 def render_since(param) TagRegistry.get_by_name(:since).to_html(param) end
render_single_param(p)
click to toggle source
# File lib/jsduck/render/subproperties.rb, line 52 def render_single_param(p) return [ "<li>", "<span class='pre'>#{p[:name]}</span> : ", p[:html_type], p[:optional] ? " (optional)" : "", p[:new] ? render_new : "", "<div class='sub-desc'>", p[:doc], p[:default] ? "<p>Defaults to: <code>#{Util::HTML.escape(p[:default])}</code></p>" : "", p[:since] ? render_since(p) : "", p[:properties] && p[:properties].length > 0 ? render(p) : "", "</div>", "</li>", ] end
render_throws(throws)
click to toggle source
# File lib/jsduck/render/subproperties.rb, line 99 def render_throws(throws) return [ "<h3 class='pa'>Throws</h3>", "<ul>", throws.map do |thr| [ "<li>", "<span class='pre'>#{thr[:html_type]}</span>", "<div class='sub-desc'>#{thr[:doc]}</div>", "</li>", ] end, "</ul>", ] end