Commit eebf30f7 authored by Rene Saarsoo's avatar Rene Saarsoo
Browse files

Make builtin meta-tags overridable by user-define ones.

Previously it was either builtin ones or user-define ones.
Now one can have a combination of the two.
parent fd6a2b94
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
require "jsduck/meta_tag"

module JsDuck
  # Implementation of hidden @author tag
  class AuthorTag < MetaTag
    def initialize
      @name = "author"
    end
  end
end
+11 −0
Original line number Diff line number Diff line
require "jsduck/meta_tag"

module JsDuck
  # Implementation of hidden @docauthor tag
  class DocAuthorTag < MetaTag
    def initialize
      @name = "docauthor"
    end
  end
end
+24 −5
Original line number Diff line number Diff line
require 'optparse'
require 'jsduck/meta_tag'
require 'jsduck/author_tag'
require 'jsduck/doc_author_tag'

module JsDuck

@@ -70,7 +72,6 @@ module JsDuck
        "Mixed",
      ]
      @meta_tags = []
      @meta_tags_path = File.dirname(__FILE__) + "/sencha_tags"

      @warnings = true
      @verbose = false
@@ -116,11 +117,29 @@ module JsDuck
    def parse!(argv)
      create_option_parser.parse!(argv).each {|fname| read_filenames(fname) }
      validate
      load_meta_tags
    end

    # Instanciate all loaded MetaTag implementations
    def load_meta_tags
      # instanciate builtin meta tags
      builtins = MetaTag.descendants
      builtins.each do |cls|
        @meta_tags << cls.new
      end

      # Load user-defined meta-tags
      if @meta_tags_path
        require @meta_tags_path
      @meta_tags = []
      end
      # Instanciate these meta tags.  When builtin implementation for
      # @tag already exists, replace it with user-defined one.
      MetaTag.descendants.each do |cls|
        @meta_tags << cls.new
        if !builtins.include?(cls)
          newtag = cls.new
          @meta_tags = @meta_tags.find_all {|t| t.name != newtag.name }
          @meta_tags << newtag
        end
      end
    end

lib/jsduck/sencha_tags.rb

deleted100644 → 0
+0 −17
Original line number Diff line number Diff line
# This file implements hidden @author and @docauthor tags.
#
# It's included by default when no other file specified with --meta-tags option.
#
require "jsduck/meta_tag"

class JsDuck::AuthorTag < JsDuck::MetaTag
  def initialize
    @name = "author"
  end
end

class JsDuck::DocAuthorTag < JsDuck::MetaTag
  def initialize
    @name = "docauthor"
  end
end