Loading lib/jsduck/tag_loader.rb 0 → 100644 +29 −0 Original line number Diff line number Diff line 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 lib/jsduck/tag_registry.rb +3 −15 Original line number Diff line number Diff line require "jsduck/tag/tag" require "jsduck/tag_loader" require "jsduck/util/singleton" module JsDuck Loading @@ -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| Loading Loading @@ -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 # Loading Loading
lib/jsduck/tag_loader.rb 0 → 100644 +29 −0 Original line number Diff line number Diff line 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
lib/jsduck/tag_registry.rb +3 −15 Original line number Diff line number Diff line require "jsduck/tag/tag" require "jsduck/tag_loader" require "jsduck/util/singleton" module JsDuck Loading @@ -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| Loading Loading @@ -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 # Loading