diff --git a/lib/jsduck/app.rb b/lib/jsduck/app.rb index 88663182b75efa9350e8ae8cf713afd73b6c5d2b..49d7dda65d0f349e6e584091fe8697cd2351055a 100644 --- a/lib/jsduck/app.rb +++ b/lib/jsduck/app.rb @@ -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 diff --git a/lib/jsduck/guides.rb b/lib/jsduck/guides.rb index be36a4ce85737d21780b1da5fb1a78c0c44434bd..f3138fa995a9d3aee713f8e0f6878eccde9b915f 100644 --- a/lib/jsduck/guides.rb +++ b/lib/jsduck/guides.rb @@ -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) diff --git a/lib/jsduck/videos.rb b/lib/jsduck/videos.rb index bf8fd1991daed40b04d1fe50408490ff92f5939f..3b362eb3e043608f192830c81e28cf95a18f6ee6 100644 --- a/lib/jsduck/videos.rb +++ b/lib/jsduck/videos.rb @@ -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