Loading bin/jsduck +9 −5 Original line number Diff line number Diff line Loading @@ -121,6 +121,10 @@ opts = OptionParser.new do | opts | app.export = :json end opts.on('--stdout', "Sends the output to STDOUT instead of writing to the filesystem", " ") do app.output_to_stdout = true end opts.separator "Debugging:" opts.separator "" Loading Loading @@ -175,22 +179,22 @@ app.input_files = js_files if app.input_files.length == 0 puts "You should specify some input files, otherwise there's nothing I can do :(" exit(1) elsif !app.output_dir elsif !app.output_to_stdout and !app.output_dir puts "You should also specify an output directory, where I could write all this amazing documentation." exit(1) elsif File.exists?(app.output_dir) && !File.directory?(app.output_dir) elsif !app.output_to_stdout and File.exists?(app.output_dir) && !File.directory?(app.output_dir) puts "Oh noes! The output directory is not really a directory at all :(" exit(1) elsif !File.exists?(File.dirname(app.output_dir)) elsif !app.output_to_stdout and !File.exists?(File.dirname(app.output_dir)) puts "Oh noes! The parent directory for #{app.output_dir} doesn't exist." exit(1) elsif !File.exists?(app.template_dir + "/extjs") elsif !app.output_to_stdout and !File.exists?(app.template_dir + "/extjs") puts "Oh noes! The template directory does not contain extjs/ directory :(" puts "Please copy ExtJS over to template/extjs or create symlink." puts "For example:" puts " $ cp -r /path/to/ext-4.0.0 " + app.template_dir + "/extjs" exit(1) elsif !File.exists?(app.template_dir + "/resources/css") elsif !app.output_to_stdout and !File.exists?(app.template_dir + "/resources/css") puts "Oh noes! CSS files for custom ExtJS theme missing :(" puts "Please compile SASS files in template/resources/sass with compass." puts "For example:" Loading lib/jsduck/app.rb +18 −2 Original line number Diff line number Diff line Loading @@ -24,6 +24,7 @@ module JsDuck # The main application logic of jsduck class App # These are basically input parameters for app attr_accessor :output_to_stdout attr_accessor :output_dir attr_accessor :template_dir attr_accessor :guides_dir Loading @@ -43,6 +44,7 @@ module JsDuck attr_accessor :append_html def initialize @output_to_stdout = false @output_dir = nil @template_dir = nil @guides_dir = nil Loading Loading @@ -109,8 +111,10 @@ module JsDuck end end clear_dir(@output_dir) if @export == :json clear_dir(@output_dir) unless @output_to_stdout if @output_to_stdout @timer.time(:generating) { output_classes(relations) } elsif @export == :json FileUtils.mkdir(@output_dir) init_output_dirs(@output_dir) @timer.time(:generating) { write_src(@output_dir+"/source", parsed_files) } Loading Loading @@ -218,6 +222,18 @@ module JsDuck File.open(filename, 'w') {|f| f.write(js) } end # Writes each class to STDOUT def output_classes(relations) if @export == :json puts JSON.generate(relations.classes) else exporter = Exporter.new(relations, get_doc_formatter(relations)) @parallel.each(relations.classes) do |cls| puts exporter.export(cls) end end end # Writes JsonP export file for each class def write_classes(path, relations) exporter = Exporter.new(relations, get_doc_formatter(relations)) Loading lib/jsduck/class.rb +4 −0 Original line number Diff line number Diff line Loading @@ -61,6 +61,10 @@ module JsDuck @doc.clone end def to_json(*a) to_hash.to_json(*a) end # Returns true when this class inherits from the specified class. # Also returns true when the class itself is the one we are asking about. def inherits_from?(class_name) Loading Loading
bin/jsduck +9 −5 Original line number Diff line number Diff line Loading @@ -121,6 +121,10 @@ opts = OptionParser.new do | opts | app.export = :json end opts.on('--stdout', "Sends the output to STDOUT instead of writing to the filesystem", " ") do app.output_to_stdout = true end opts.separator "Debugging:" opts.separator "" Loading Loading @@ -175,22 +179,22 @@ app.input_files = js_files if app.input_files.length == 0 puts "You should specify some input files, otherwise there's nothing I can do :(" exit(1) elsif !app.output_dir elsif !app.output_to_stdout and !app.output_dir puts "You should also specify an output directory, where I could write all this amazing documentation." exit(1) elsif File.exists?(app.output_dir) && !File.directory?(app.output_dir) elsif !app.output_to_stdout and File.exists?(app.output_dir) && !File.directory?(app.output_dir) puts "Oh noes! The output directory is not really a directory at all :(" exit(1) elsif !File.exists?(File.dirname(app.output_dir)) elsif !app.output_to_stdout and !File.exists?(File.dirname(app.output_dir)) puts "Oh noes! The parent directory for #{app.output_dir} doesn't exist." exit(1) elsif !File.exists?(app.template_dir + "/extjs") elsif !app.output_to_stdout and !File.exists?(app.template_dir + "/extjs") puts "Oh noes! The template directory does not contain extjs/ directory :(" puts "Please copy ExtJS over to template/extjs or create symlink." puts "For example:" puts " $ cp -r /path/to/ext-4.0.0 " + app.template_dir + "/extjs" exit(1) elsif !File.exists?(app.template_dir + "/resources/css") elsif !app.output_to_stdout and !File.exists?(app.template_dir + "/resources/css") puts "Oh noes! CSS files for custom ExtJS theme missing :(" puts "Please compile SASS files in template/resources/sass with compass." puts "For example:" Loading
lib/jsduck/app.rb +18 −2 Original line number Diff line number Diff line Loading @@ -24,6 +24,7 @@ module JsDuck # The main application logic of jsduck class App # These are basically input parameters for app attr_accessor :output_to_stdout attr_accessor :output_dir attr_accessor :template_dir attr_accessor :guides_dir Loading @@ -43,6 +44,7 @@ module JsDuck attr_accessor :append_html def initialize @output_to_stdout = false @output_dir = nil @template_dir = nil @guides_dir = nil Loading Loading @@ -109,8 +111,10 @@ module JsDuck end end clear_dir(@output_dir) if @export == :json clear_dir(@output_dir) unless @output_to_stdout if @output_to_stdout @timer.time(:generating) { output_classes(relations) } elsif @export == :json FileUtils.mkdir(@output_dir) init_output_dirs(@output_dir) @timer.time(:generating) { write_src(@output_dir+"/source", parsed_files) } Loading Loading @@ -218,6 +222,18 @@ module JsDuck File.open(filename, 'w') {|f| f.write(js) } end # Writes each class to STDOUT def output_classes(relations) if @export == :json puts JSON.generate(relations.classes) else exporter = Exporter.new(relations, get_doc_formatter(relations)) @parallel.each(relations.classes) do |cls| puts exporter.export(cls) end end end # Writes JsonP export file for each class def write_classes(path, relations) exporter = Exporter.new(relations, get_doc_formatter(relations)) Loading
lib/jsduck/class.rb +4 −0 Original line number Diff line number Diff line Loading @@ -61,6 +61,10 @@ module JsDuck @doc.clone end def to_json(*a) to_hash.to_json(*a) end # Returns true when this class inherits from the specified class. # Also returns true when the class itself is the one we are asking about. def inherits_from?(class_name) Loading