diff --git a/lib/jsduck/tag_loader.rb b/lib/jsduck/tag_loader.rb new file mode 100644 index 0000000000000000000000000000000000000000..3c1d409883511d5737ea52382234aebee9432c90 --- /dev/null +++ b/lib/jsduck/tag_loader.rb @@ -0,0 +1,29 @@ +require "jsduck/tag/tag" + +module JsDuck + + class TagLoader + # Loads builtin tags from /tag dir. + # Returns array of Tag classes. + def load_builtins + load_tag_classes(File.dirname(__FILE__) + "/tag") + tag_classes + end + + private + + # Loads tags from given dir. + def load_tag_classes(dirname) + Dir[dirname+"/**/*.rb"].each {|file| require(file) } + end + + # Returns all available Tag classes sorted alphabetically. This + # ensures attributes in member signatures are always rendered in + # the same order. + def tag_classes + JsDuck::Tag::Tag.descendants.sort {|a, b| a.to_s <=> b.to_s } + end + + end + +end diff --git a/lib/jsduck/tag_registry.rb b/lib/jsduck/tag_registry.rb index 83791769957728ec32b5bb565793def63b5ada95..9d0512d19b4cfd167da1d993949f33353d582751 100644 --- a/lib/jsduck/tag_registry.rb +++ b/lib/jsduck/tag_registry.rb @@ -1,4 +1,4 @@ -require "jsduck/tag/tag" +require "jsduck/tag_loader" require "jsduck/util/singleton" module JsDuck @@ -15,17 +15,12 @@ module JsDuck @keys = {} @signatures = [] @html_renderers = {:top => [], :bottom => []} - load_tag_classes(File.dirname(__FILE__) + "/tag") - instantiate_tags - end - # Loads tags from given dir. - def load_tag_classes(dirname) - Dir[dirname+"/**/*.rb"].each {|file| require(file) } + instantiate_tags(TagLoader.new.load_builtins) end # Instantiates all descendants of JsDuck::Tag::Tag - def instantiate_tags + def instantiate_tags(tag_classes) tag_classes.each do |cls| tag = cls.new() Array(tag.pattern).each do |pattern| @@ -53,13 +48,6 @@ module JsDuck end end - # Returns all available Tag classes sorted alphabetically. This - # ensures attributes in member signatures are always rendered in - # the same order. - def tag_classes - JsDuck::Tag::Tag.descendants.sort {|a, b| a.to_s <=> b.to_s } - end - # # Accessors for lists of tags #