Class: JsDuck::BatchFormatter
- Inherits:
-
Object
- Object
- JsDuck::BatchFormatter
- Defined in:
- lib/jsduck/batch_formatter.rb
Overview
Performs the formatting of the doc-object of all classes.
Class Method Summary collapse
-
.create_class_formatter(relations, opts) ⇒ Object
Factory method to create new ClassFormatter instances.
-
.format_all!(relations, assets, opts) ⇒ Object
Formats all classes.
Class Method Details
.create_class_formatter(relations, opts) ⇒ Object
Factory method to create new ClassFormatter instances.
47 48 49 50 51 52 53 54 55 56 |
# File 'lib/jsduck/batch_formatter.rb', line 47 def self.create_class_formatter(relations, opts) doc_formatter = DocFormatter.new(relations, opts) doc_formatter.images = Img::DirSet.new(opts.images, "images") class_formatter = ClassFormatter.new(relations, doc_formatter) # Don't format types when exporting class_formatter.include_types = !opts.export class_formatter end |
.format_all!(relations, assets, opts) ⇒ Object
Formats all classes. Also registers found images in assets.
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/jsduck/batch_formatter.rb', line 14 def self.format_all!(relations, assets, opts) # Format all doc-objects in parallel formatted_classes = Util::Parallel.map(relations.classes) do |cls| files = cls[:files].map {|f| f[:filename] }.join(" ") Logger.log("Markdown formatting #{cls[:name]}", files) formatter = create_class_formatter(relations, opts) begin { :doc => formatter.format(cls.internal_doc), :images => formatter.images.all_used } rescue Logger.fatal_backtrace("Error while formatting #{cls[:name]} #{files}", $!) exit(1) end end # Then merge the data back to classes sequentially formatted_classes.each do |cls| relations[cls[:doc][:name]].internal_doc = cls[:doc] # Perform lookup of all the images again. We're really doing # this work twice now, but as we usually don't have excessive # amounts of images, the performance penalty should be minimal. cls[:images].each {|img| assets.images.get(img[:filename]) } end # Print warnings for unused images assets.images.report_unused end |