Loading bin/jsduck +19 −1 Original line number Diff line number Diff line Loading @@ -34,10 +34,28 @@ opts = OptionParser.new do | opts | app.template_dir = path end opts.on('--json', "Produces JSON export instead of HTML documentation.") do |path| opts.on('--json', "Produces JSON export instead of HTML documentation.") do app.export = :json end opts.on('--link=TPL', "HTML template for replacing {@link} in export.", "Possible placeholders:", "%c - full class name (e.g. 'Ext.Panel')", "%m - class member name (e.g. 'urlEncode')", "%M - class member name, prefixed with hash (e.g. '#urlEncode')", "%a - anchor text for link", "Default value: '<a href=\"%c%M\">%a</a>'") do |tpl| app.link_tpl = tpl end opts.on('--img=TPL', "HTML template for replacing {@img} in export.", "Possible placeholders:", "%u - URL from @img tag (e.g. 'some/path.png')", "%a - alt text for image", "Default value: '<img src=\"%u\" alt=\"%a\"/>'") do |tpl| app.img_tpl = tpl end # For debugging it's often useful to set --processes=0 to get deterministic results. opts.on('-p', '--processes=COUNT', "The number of parallel processes to use.", "Defaults to the number of processors/cores.", Loading lib/jsduck/app.rb +9 −1 Original line number Diff line number Diff line Loading @@ -25,6 +25,8 @@ module JsDuck attr_accessor :input_files attr_accessor :verbose attr_accessor :export attr_accessor :link_tpl attr_accessor :img_tpl def initialize @output_dir = nil Loading @@ -32,6 +34,8 @@ module JsDuck @input_files = [] @verbose = false @export = nil @link_tpl = nil @img_tpl = nil @timer = Timer.new @parallel = ParallelWrap.new end Loading Loading @@ -174,7 +178,11 @@ module JsDuck # Writes JSON export file for each class def write_json(path, relations) exporter = Exporter.new(relations) formatter = DocFormatter.new formatter.link_tpl = @link_tpl if @link_tpl formatter.img_tpl = @img_tpl if @img_tpl formatter.relations = relations exporter = Exporter.new(relations, formatter) @parallel.each(relations.classes) do |cls| filename = path + "/" + cls[:name] + ".json" puts "Writing to #{filename} ..." if @verbose Loading lib/jsduck/exporter.rb +2 −6 Original line number Diff line number Diff line Loading @@ -9,13 +9,9 @@ module JsDuck # Also all the :doc elements will be formatted - converted from # markdown to HTML and @links resolved. class Exporter attr_accessor :relations def initialize(relations) def initialize(relations, formatter) @relations = relations @formatter = DocFormatter.new @formatter.css_class = 'docClass' @formatter.relations = relations @formatter = formatter end # Returns all data in Class object as hash. Loading Loading
bin/jsduck +19 −1 Original line number Diff line number Diff line Loading @@ -34,10 +34,28 @@ opts = OptionParser.new do | opts | app.template_dir = path end opts.on('--json', "Produces JSON export instead of HTML documentation.") do |path| opts.on('--json', "Produces JSON export instead of HTML documentation.") do app.export = :json end opts.on('--link=TPL', "HTML template for replacing {@link} in export.", "Possible placeholders:", "%c - full class name (e.g. 'Ext.Panel')", "%m - class member name (e.g. 'urlEncode')", "%M - class member name, prefixed with hash (e.g. '#urlEncode')", "%a - anchor text for link", "Default value: '<a href=\"%c%M\">%a</a>'") do |tpl| app.link_tpl = tpl end opts.on('--img=TPL', "HTML template for replacing {@img} in export.", "Possible placeholders:", "%u - URL from @img tag (e.g. 'some/path.png')", "%a - alt text for image", "Default value: '<img src=\"%u\" alt=\"%a\"/>'") do |tpl| app.img_tpl = tpl end # For debugging it's often useful to set --processes=0 to get deterministic results. opts.on('-p', '--processes=COUNT', "The number of parallel processes to use.", "Defaults to the number of processors/cores.", Loading
lib/jsduck/app.rb +9 −1 Original line number Diff line number Diff line Loading @@ -25,6 +25,8 @@ module JsDuck attr_accessor :input_files attr_accessor :verbose attr_accessor :export attr_accessor :link_tpl attr_accessor :img_tpl def initialize @output_dir = nil Loading @@ -32,6 +34,8 @@ module JsDuck @input_files = [] @verbose = false @export = nil @link_tpl = nil @img_tpl = nil @timer = Timer.new @parallel = ParallelWrap.new end Loading Loading @@ -174,7 +178,11 @@ module JsDuck # Writes JSON export file for each class def write_json(path, relations) exporter = Exporter.new(relations) formatter = DocFormatter.new formatter.link_tpl = @link_tpl if @link_tpl formatter.img_tpl = @img_tpl if @img_tpl formatter.relations = relations exporter = Exporter.new(relations, formatter) @parallel.each(relations.classes) do |cls| filename = path + "/" + cls[:name] + ".json" puts "Writing to #{filename} ..." if @verbose Loading
lib/jsduck/exporter.rb +2 −6 Original line number Diff line number Diff line Loading @@ -9,13 +9,9 @@ module JsDuck # Also all the :doc elements will be formatted - converted from # markdown to HTML and @links resolved. class Exporter attr_accessor :relations def initialize(relations) def initialize(relations, formatter) @relations = relations @formatter = DocFormatter.new @formatter.css_class = 'docClass' @formatter.relations = relations @formatter = formatter end # Returns all data in Class object as hash. Loading