Loading lib/jsduck/class_formatter.rb +1 −0 Original line number Diff line number Diff line Loading @@ -48,6 +48,7 @@ module JsDuck m[:html_type] = (@include_types && !is_css_tag) ? format_type(m[:type]) : m[:type] if m[:type] m[:params] = m[:params].map {|p| format_item(p, is_css_tag) } if m[:params] m[:return] = format_item(m[:return], is_css_tag) if m[:return] m[:throws] = m[:throws].map {|t| format_item(t, is_css_tag) } if m[:throws] m[:properties] = m[:properties].map {|b| format_item(b, is_css_tag) } if m[:properties] m[:html_meta] = format_meta_data(m) m Loading lib/jsduck/doc_parser.rb +10 −0 Original line number Diff line number Diff line Loading @@ -132,6 +132,8 @@ module JsDuck at_alias elsif look(/@var\b/) at_var elsif look(/@throws\b/) at_throws elsif look(/@inheritable\b/) boolean_at_tag(/@inheritable/, :inheritable) elsif look(/@accessor\b/) Loading Loading @@ -276,6 +278,14 @@ module JsDuck skip_white end # matches @throws {type} ... def at_throws match(/@throws/) add_tag(:throws) maybe_type skip_white end # matches @type {type} or @type type # # The presence of @type implies that we are dealing with property. Loading lib/jsduck/merger.rb +12 −0 Original line number Diff line number Diff line Loading @@ -162,6 +162,7 @@ module JsDuck :doc => detect_doc(docs), :params => detect_params(:method, doc_map, code), :return => detect_return(doc_map, name == "constructor" ? "Object" : "undefined"), :throws => detect_throws(doc_map), }, doc_map) end Loading Loading @@ -477,6 +478,17 @@ module JsDuck } end def detect_throws(doc_map) return unless doc_map[:throws] doc_map[:throws].map do |throws| { :type => throws[:type] || "Object", :doc => throws[:doc] || "", } end end # Combines :doc-s of most tags # Ignores tags that have doc comment themselves and subproperty tags def detect_doc(docs) Loading lib/jsduck/renderer.rb +20 −0 Original line number Diff line number Diff line Loading @@ -318,6 +318,10 @@ module JsDuck doc << render_return(ret) end if item[:throws] doc << render_throws(item[:throws]) end doc end Loading Loading @@ -351,6 +355,22 @@ module JsDuck "</ul>", ] end 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 end end lib/jsduck/tag/throws.rbdeleted 100644 → 0 +0 −46 Original line number Diff line number Diff line require "jsduck/meta_tag" require "jsduck/logger" module JsDuck::Tag class Throws < JsDuck::MetaTag def initialize @name = "throws" @key = :throws @signature = {:long => "throws", :short => "THR"} @multiline = true end def to_value(tags) tags.map do | throws | if throws =~ /\A\{([\w\.]+)\}\s+([^ ].*)\Z/m {:type => $1, :doc => $2.strip} else {:type => "Object", :doc => throws} end end end def to_html(values) return if values.length == 0 html = values.map do | throws | <<-EOHTML <li> <span class="pre"><a href="#!/api/#{throws[:type]}">#{throws[:type]}</a></span> <div class="sub-desc"> <p>#{throws[:doc]}</p> </div> </li> EOHTML end.join return <<-EOHTML <h3>Throws</h3> <ul> #{html} </ul> EOHTML end end end Loading
lib/jsduck/class_formatter.rb +1 −0 Original line number Diff line number Diff line Loading @@ -48,6 +48,7 @@ module JsDuck m[:html_type] = (@include_types && !is_css_tag) ? format_type(m[:type]) : m[:type] if m[:type] m[:params] = m[:params].map {|p| format_item(p, is_css_tag) } if m[:params] m[:return] = format_item(m[:return], is_css_tag) if m[:return] m[:throws] = m[:throws].map {|t| format_item(t, is_css_tag) } if m[:throws] m[:properties] = m[:properties].map {|b| format_item(b, is_css_tag) } if m[:properties] m[:html_meta] = format_meta_data(m) m Loading
lib/jsduck/doc_parser.rb +10 −0 Original line number Diff line number Diff line Loading @@ -132,6 +132,8 @@ module JsDuck at_alias elsif look(/@var\b/) at_var elsif look(/@throws\b/) at_throws elsif look(/@inheritable\b/) boolean_at_tag(/@inheritable/, :inheritable) elsif look(/@accessor\b/) Loading Loading @@ -276,6 +278,14 @@ module JsDuck skip_white end # matches @throws {type} ... def at_throws match(/@throws/) add_tag(:throws) maybe_type skip_white end # matches @type {type} or @type type # # The presence of @type implies that we are dealing with property. Loading
lib/jsduck/merger.rb +12 −0 Original line number Diff line number Diff line Loading @@ -162,6 +162,7 @@ module JsDuck :doc => detect_doc(docs), :params => detect_params(:method, doc_map, code), :return => detect_return(doc_map, name == "constructor" ? "Object" : "undefined"), :throws => detect_throws(doc_map), }, doc_map) end Loading Loading @@ -477,6 +478,17 @@ module JsDuck } end def detect_throws(doc_map) return unless doc_map[:throws] doc_map[:throws].map do |throws| { :type => throws[:type] || "Object", :doc => throws[:doc] || "", } end end # Combines :doc-s of most tags # Ignores tags that have doc comment themselves and subproperty tags def detect_doc(docs) Loading
lib/jsduck/renderer.rb +20 −0 Original line number Diff line number Diff line Loading @@ -318,6 +318,10 @@ module JsDuck doc << render_return(ret) end if item[:throws] doc << render_throws(item[:throws]) end doc end Loading Loading @@ -351,6 +355,22 @@ module JsDuck "</ul>", ] end 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 end end
lib/jsduck/tag/throws.rbdeleted 100644 → 0 +0 −46 Original line number Diff line number Diff line require "jsduck/meta_tag" require "jsduck/logger" module JsDuck::Tag class Throws < JsDuck::MetaTag def initialize @name = "throws" @key = :throws @signature = {:long => "throws", :short => "THR"} @multiline = true end def to_value(tags) tags.map do | throws | if throws =~ /\A\{([\w\.]+)\}\s+([^ ].*)\Z/m {:type => $1, :doc => $2.strip} else {:type => "Object", :doc => throws} end end end def to_html(values) return if values.length == 0 html = values.map do | throws | <<-EOHTML <li> <span class="pre"><a href="#!/api/#{throws[:type]}">#{throws[:type]}</a></span> <div class="sub-desc"> <p>#{throws[:doc]}</p> </div> </li> EOHTML end.join return <<-EOHTML <h3>Throws</h3> <ul> #{html} </ul> EOHTML end end end