Loading lib/jsduck/meta_tag.rb +4 −0 Original line number Diff line number Diff line Loading @@ -26,6 +26,10 @@ module JsDuck # existance of the tag. attr_reader :boolean # Whether to render the tag before other content (:top) or after # it (:bottom). Defaults to :bottom. attr_accessor :position # Here the appropriate class or member will be injected, # so the to_value and to_html methods can for produce # different output based on whether the tag is inside class, Loading lib/jsduck/meta_tag_loader.rb +2 −0 Original line number Diff line number Diff line Loading @@ -55,9 +55,11 @@ module JsDuck # Instanciates tag class. # When .key is missing, creates it from .name # When .position is missing, defaults to :bottom def create_tag(cls) tag = cls.new tag.key = tag.name.to_sym unless tag.key tag.position = :bottom unless tag.position tag end end Loading lib/jsduck/meta_tag_registry.rb +4 −3 Original line number Diff line number Diff line Loading @@ -31,9 +31,10 @@ module JsDuck register_keys end # Returns array of all available tag instances def tags @tags # Returns array of all available tag instances. # When position provided, returns only tags in that position def tags(position=nil) position ? @tags.find_all {|t| t.position == position} : @tags end # Accesses tag by key or name Loading lib/jsduck/renderer.rb +10 −5 Original line number Diff line number Diff line Loading @@ -13,9 +13,10 @@ module JsDuck "<div>", render_sidebar, "<div class='doc-contents'>", render_meta_data(@cls[:html_meta], :top), render_private_class_notice, @cls[:doc], render_meta_data(@cls[:html_meta]), render_meta_data(@cls[:html_meta], :bottom), "</div>", "<div class='members'>", render_all_sections, Loading @@ -33,10 +34,10 @@ module JsDuck ] end def render_meta_data(meta_data) def render_meta_data(meta_data, position) return if meta_data.size == 0 MetaTagRegistry.instance.tags.map {|tag| meta_data[tag.key] } MetaTagRegistry.instance.tags(position).map {|tag| meta_data[tag.key] } end def render_sidebar Loading Loading @@ -257,13 +258,17 @@ module JsDuck end def render_long_doc(m) doc = [m[:doc]] doc = [] doc << render_meta_data(m[:html_meta], :top) doc << m[:doc] if m[:default] && m[:default] != "undefined" doc << "<p>Defaults to: <code>" + CGI.escapeHTML(m[:default]) + "</code></p>" end doc << render_meta_data(m[:html_meta]) doc << render_meta_data(m[:html_meta], :bottom) doc << render_params_and_return(m) Loading Loading
lib/jsduck/meta_tag.rb +4 −0 Original line number Diff line number Diff line Loading @@ -26,6 +26,10 @@ module JsDuck # existance of the tag. attr_reader :boolean # Whether to render the tag before other content (:top) or after # it (:bottom). Defaults to :bottom. attr_accessor :position # Here the appropriate class or member will be injected, # so the to_value and to_html methods can for produce # different output based on whether the tag is inside class, Loading
lib/jsduck/meta_tag_loader.rb +2 −0 Original line number Diff line number Diff line Loading @@ -55,9 +55,11 @@ module JsDuck # Instanciates tag class. # When .key is missing, creates it from .name # When .position is missing, defaults to :bottom def create_tag(cls) tag = cls.new tag.key = tag.name.to_sym unless tag.key tag.position = :bottom unless tag.position tag end end Loading
lib/jsduck/meta_tag_registry.rb +4 −3 Original line number Diff line number Diff line Loading @@ -31,9 +31,10 @@ module JsDuck register_keys end # Returns array of all available tag instances def tags @tags # Returns array of all available tag instances. # When position provided, returns only tags in that position def tags(position=nil) position ? @tags.find_all {|t| t.position == position} : @tags end # Accesses tag by key or name Loading
lib/jsduck/renderer.rb +10 −5 Original line number Diff line number Diff line Loading @@ -13,9 +13,10 @@ module JsDuck "<div>", render_sidebar, "<div class='doc-contents'>", render_meta_data(@cls[:html_meta], :top), render_private_class_notice, @cls[:doc], render_meta_data(@cls[:html_meta]), render_meta_data(@cls[:html_meta], :bottom), "</div>", "<div class='members'>", render_all_sections, Loading @@ -33,10 +34,10 @@ module JsDuck ] end def render_meta_data(meta_data) def render_meta_data(meta_data, position) return if meta_data.size == 0 MetaTagRegistry.instance.tags.map {|tag| meta_data[tag.key] } MetaTagRegistry.instance.tags(position).map {|tag| meta_data[tag.key] } end def render_sidebar Loading Loading @@ -257,13 +258,17 @@ module JsDuck end def render_long_doc(m) doc = [m[:doc]] doc = [] doc << render_meta_data(m[:html_meta], :top) doc << m[:doc] if m[:default] && m[:default] != "undefined" doc << "<p>Defaults to: <code>" + CGI.escapeHTML(m[:default]) + "</code></p>" end doc << render_meta_data(m[:html_meta]) doc << render_meta_data(m[:html_meta], :bottom) doc << render_params_and_return(m) Loading