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

Write videos.json and guides.json to output dir.

Those won't be used by the docs app, but this way they will be
available in release version of the docs app, and people can use
those files as input to JSDuck.
parent f14199c0
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -83,6 +83,7 @@ module JsDuck
        @timer.time(:generating) { write_search_data }
        @timer.time(:generating) { write_classes }
        @timer.time(:generating) { @guides.write(@opts.output_dir+"/guides") }
        @timer.time(:generating) { @videos.write(@opts.output_dir+"/videos") }
      end

      @timer.report
+4 −2
Original line number Diff line number Diff line
@@ -20,11 +20,13 @@ module JsDuck

    # Writes all guides to given dir in JsonP format
    def write(dir)
      # Skip it all when we have no guides
      return if @guides.length == 0

      FileUtils.mkdir(dir)
      FileUtils.mkdir(dir) unless File.exists?(dir)
      @guides.each {|group| group["items"].each {|g| write_guide(g, dir) } }
      # Write the JSON to output dir, so it's available in released
      # version of docs and people can use it with JSDuck by themselves.
      File.open(dir+"/guides.json", 'w') {|f| f.write(JSON.generate(@guides)) }
    end

    def write_guide(guide, dir)
+10 −0
Original line number Diff line number Diff line
@@ -13,6 +13,16 @@ module JsDuck
      @videos = JSON.parse(IO.read(filename))
    end

    # Writes videos JSON file to a dir
    def write(dir)
      return if @videos.length == 0

      FileUtils.mkdir(dir) unless File.exists?(dir)
      # Write the JSON to output dir, so it's available in released
      # version of docs and people can use it with JSDuck by themselves.
      File.open(dir+"/videos.json", 'w') {|f| f.write(JSON.generate(@videos)) }
    end

    # Returns all videos as array
    def to_array
      @videos