Loading lib/jsduck/doc_parser.rb +1 −1 Original line number Diff line number Diff line Loading @@ -163,7 +163,7 @@ module JsDuck prev_tag = @current_tag add_tag(:meta) @current_tag[:name] = tag.key || tag.name @current_tag[:name] = tag.key match(/\w+/) skip_horiz_white Loading lib/jsduck/meta_tag.rb +3 −3 Original line number Diff line number Diff line Loading @@ -8,9 +8,9 @@ module JsDuck # Name of the tag (required) attr_reader :name # The key under which to store this tag. Should be a symbol. # By default the string :name is used as key. attr_reader :key # The key under which to store this tag. Must be a symbol. When # not provided then :name is converted to symbol and used as key. attr_accessor :key # The text to display in member signature. Must be a hash # defining the short and long versions of the signature text: Loading lib/jsduck/meta_tag_loader.rb +10 −2 Original line number Diff line number Diff line Loading @@ -18,7 +18,7 @@ module JsDuck # instatiates builtin meta tags def initialize @classes = MetaTag.descendants @meta_tags = @classes.map {|cls| cls.new } @meta_tags = @classes.map {|cls| create_tag(cls) } end # Loads user-defined meta-tags from given paths. Loading Loading @@ -46,12 +46,20 @@ module JsDuck MetaTag.descendants.each do |cls| if !@classes.include?(cls) @classes << cls newtag = cls.new newtag = create_tag(cls) @meta_tags = @meta_tags.find_all {|t| t.name != newtag.name } @meta_tags << newtag end end end # Instanciates tag class. # When .key is missing, creates it from .name def create_tag(cls) tag = cls.new tag.key = tag.name.to_sym unless tag.key tag end end end lib/jsduck/renderer.rb +1 −1 Original line number Diff line number Diff line Loading @@ -37,7 +37,7 @@ module JsDuck return if meta_data.size == 0 MetaTagRegistry.instance.tags.map do |tag| contents = meta_data[tag.key || tag.name] contents = meta_data[tag.key] if contents tag.to_html(contents) else Loading spec/aggregator_meta_tags_spec.rb +10 −7 Original line number Diff line number Diff line Loading @@ -8,18 +8,21 @@ describe JsDuck::Aggregator do class AuthorTag < JsDuck::MetaTag def initialize @name = "author" @key = :author end end class EmailTag < JsDuck::MetaTag def initialize @name = "email" @key = :email end end class LongTag < JsDuck::MetaTag def initialize @name = "long" @key = :long @multiline = true end end Loading @@ -46,8 +49,8 @@ describe JsDuck::Aggregator do it "detects content of the defined tags" do @doc[:meta].should == { "author" => ["John Doe", "Steve Jobs"], "email" => ["Kill Bill"], :author => ["John Doe", "Steve Jobs"], :email => ["Kill Bill"], } end end Loading @@ -68,8 +71,8 @@ describe JsDuck::Aggregator do it "detects tag content until next @tag" do @doc[:meta].should == { "long" => ["Some text\non multiple\nlines."], "author" => ["Steve Jobs"], :long => ["Some text\non multiple\nlines."], :author => ["Steve Jobs"], } end end Loading @@ -87,8 +90,8 @@ describe JsDuck::Aggregator do it "includes {@link} as part of tag content" do @doc[:meta].should == { "long" => ["Me {@link foo bar}"], "author" => ["Me {@link foo bar}"], :long => ["Me {@link foo bar}"], :author => ["Me {@link foo bar}"], } end end Loading @@ -106,7 +109,7 @@ describe JsDuck::Aggregator do it "detects the meta tag" do @doc[:meta].should == { "author" => ["John Doe"], :author => ["John Doe"], } end Loading Loading
lib/jsduck/doc_parser.rb +1 −1 Original line number Diff line number Diff line Loading @@ -163,7 +163,7 @@ module JsDuck prev_tag = @current_tag add_tag(:meta) @current_tag[:name] = tag.key || tag.name @current_tag[:name] = tag.key match(/\w+/) skip_horiz_white Loading
lib/jsduck/meta_tag.rb +3 −3 Original line number Diff line number Diff line Loading @@ -8,9 +8,9 @@ module JsDuck # Name of the tag (required) attr_reader :name # The key under which to store this tag. Should be a symbol. # By default the string :name is used as key. attr_reader :key # The key under which to store this tag. Must be a symbol. When # not provided then :name is converted to symbol and used as key. attr_accessor :key # The text to display in member signature. Must be a hash # defining the short and long versions of the signature text: Loading
lib/jsduck/meta_tag_loader.rb +10 −2 Original line number Diff line number Diff line Loading @@ -18,7 +18,7 @@ module JsDuck # instatiates builtin meta tags def initialize @classes = MetaTag.descendants @meta_tags = @classes.map {|cls| cls.new } @meta_tags = @classes.map {|cls| create_tag(cls) } end # Loads user-defined meta-tags from given paths. Loading Loading @@ -46,12 +46,20 @@ module JsDuck MetaTag.descendants.each do |cls| if !@classes.include?(cls) @classes << cls newtag = cls.new newtag = create_tag(cls) @meta_tags = @meta_tags.find_all {|t| t.name != newtag.name } @meta_tags << newtag end end end # Instanciates tag class. # When .key is missing, creates it from .name def create_tag(cls) tag = cls.new tag.key = tag.name.to_sym unless tag.key tag end end end
lib/jsduck/renderer.rb +1 −1 Original line number Diff line number Diff line Loading @@ -37,7 +37,7 @@ module JsDuck return if meta_data.size == 0 MetaTagRegistry.instance.tags.map do |tag| contents = meta_data[tag.key || tag.name] contents = meta_data[tag.key] if contents tag.to_html(contents) else Loading
spec/aggregator_meta_tags_spec.rb +10 −7 Original line number Diff line number Diff line Loading @@ -8,18 +8,21 @@ describe JsDuck::Aggregator do class AuthorTag < JsDuck::MetaTag def initialize @name = "author" @key = :author end end class EmailTag < JsDuck::MetaTag def initialize @name = "email" @key = :email end end class LongTag < JsDuck::MetaTag def initialize @name = "long" @key = :long @multiline = true end end Loading @@ -46,8 +49,8 @@ describe JsDuck::Aggregator do it "detects content of the defined tags" do @doc[:meta].should == { "author" => ["John Doe", "Steve Jobs"], "email" => ["Kill Bill"], :author => ["John Doe", "Steve Jobs"], :email => ["Kill Bill"], } end end Loading @@ -68,8 +71,8 @@ describe JsDuck::Aggregator do it "detects tag content until next @tag" do @doc[:meta].should == { "long" => ["Some text\non multiple\nlines."], "author" => ["Steve Jobs"], :long => ["Some text\non multiple\nlines."], :author => ["Steve Jobs"], } end end Loading @@ -87,8 +90,8 @@ describe JsDuck::Aggregator do it "includes {@link} as part of tag content" do @doc[:meta].should == { "long" => ["Me {@link foo bar}"], "author" => ["Me {@link foo bar}"], :long => ["Me {@link foo bar}"], :author => ["Me {@link foo bar}"], } end end Loading @@ -106,7 +109,7 @@ describe JsDuck::Aggregator do it "detects the meta tag" do @doc[:meta].should == { "author" => ["John Doe"], :author => ["John Doe"], } end Loading