Class: JsDuck::WebWriter
- Inherits:
-
Object
- Object
- JsDuck::WebWriter
- Defined in:
- lib/jsduck/web_writer.rb
Overview
Performs the generation of docs web app.
Instance Method Summary collapse
-
#clean_output_dir ⇒ Object
– util routines –.
- #format_classes ⇒ Object
-
#initialize(relations, assets, parsed_files, opts) ⇒ WebWriter
constructor
A new instance of WebWriter.
- #write ⇒ Object
- #write_app_data ⇒ Object
- #write_classes ⇒ Object
- #write_index_html ⇒ Object
- #write_inline_examples ⇒ Object
- #write_source ⇒ Object
- #write_template_files ⇒ Object
Constructor Details
#initialize(relations, assets, parsed_files, opts) ⇒ WebWriter
Returns a new instance of WebWriter.
16 17 18 19 20 21 |
# File 'lib/jsduck/web_writer.rb', line 16 def initialize(relations, assets, parsed_files, opts) @relations = relations @assets = assets @parsed_files = parsed_files @opts = opts end |
Instance Method Details
#clean_output_dir ⇒ Object
– util routines –
77 78 79 |
# File 'lib/jsduck/web_writer.rb', line 77 def clean_output_dir FileUtils.rm_rf(@opts.output_dir) end |
#format_classes ⇒ Object
81 82 83 |
# File 'lib/jsduck/web_writer.rb', line 81 def format_classes BatchFormatter.format_all!(@relations, @assets, @opts) end |
#write ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/jsduck/web_writer.rb', line 23 def write clean_output_dir write_template_files write_app_data write_index_html # class-formatting is done in parallel which breaks the links # between source files and classes. Therefore it MUST to be done # after writing sources which needs the links to work. write_source if @opts.source format_classes write_inline_examples if @opts.tests write_classes @assets.write end |
#write_app_data ⇒ Object
47 48 49 50 51 52 |
# File 'lib/jsduck/web_writer.rb', line 47 def write_app_data filename = @opts.output_dir+"/data.js" AppData.new(@relations, @assets, @opts).write(filename) # Rename the file and remember the name for use in IndexHtml.write @opts.data_path = Util::MD5.rename(filename) end |
#write_classes ⇒ Object
70 71 72 73 |
# File 'lib/jsduck/web_writer.rb', line 70 def write_classes class_writer = ClassWriter.new(Exporter::App, @relations, @opts) class_writer.write(@opts.output_dir+"/output", ".js") end |
#write_index_html ⇒ Object
54 55 56 |
# File 'lib/jsduck/web_writer.rb', line 54 def write_index_html IndexHtml.new(@assets, @opts).write end |
#write_inline_examples ⇒ Object
63 64 65 66 67 68 |
# File 'lib/jsduck/web_writer.rb', line 63 def write_inline_examples examples = InlineExamples.new examples.add_classes(@relations) examples.add_guides(@assets.guides) examples.write(@opts.output_dir+"/inline-examples.js") end |
#write_source ⇒ Object
58 59 60 61 |
# File 'lib/jsduck/web_writer.rb', line 58 def write_source source_writer = Source::Writer.new(@parsed_files) source_writer.write(@opts.output_dir + "/source") end |
#write_template_files ⇒ Object
43 44 45 |
# File 'lib/jsduck/web_writer.rb', line 43 def write_template_files TemplateDir.new(@opts).write end |