lib/rdoc/generator/json_index.rb in rdoc-3.12.2 vs lib/rdoc/generator/json_index.rb in rdoc-4.0.0.preview2

- old
+ new

@@ -13,13 +13,13 @@ # @base_dir = Pathname.pwd.expand_path # # @json_index = RDoc::Generator::JsonIndex.new self, options # end # -# def generate top_levels +# def generate # # ... -# @json_index.generate top_levels +# @json_index.generate # end # end # # == Index Format # @@ -86,41 +86,49 @@ # # +options+ are the same options passed to the parent generator. def initialize parent_generator, options @parent_generator = parent_generator - @options = options + @store = parent_generator.store + @options = options @template_dir = File.expand_path '../template/json_index', __FILE__ @base_dir = @parent_generator.base_dir @classes = nil @files = nil @index = nil end ## + # Builds the JSON index as a Hash. + + def build_index + reset @store.all_files.sort, @store.all_classes_and_modules.sort + + index_classes + index_methods + index_pages + + { :index => @index } + end + + ## # Output progress information if debugging is enabled def debug_msg *msg return unless $DEBUG_RDOC $stderr.puts(*msg) end ## - # Creates the JSON index. + # Writes the JSON index to disk - def generate top_levels + def generate debug_msg "Generating JSON index" - reset top_levels.sort, RDoc::TopLevel.all_classes_and_modules.sort - - index_classes - index_methods - index_pages - debug_msg " writing search index to %s" % SEARCH_INDEX_FILE - data = { :index => @index } + data = build_index return if @options.dry_run out_dir = @base_dir + @options.op_dir index_file = out_dir + SEARCH_INDEX_FILE