Class: JsDuck::Web::Writer
- Inherits:
-
Object
- Object
- JsDuck::Web::Writer
- Defined in:
- lib/jsduck/web/writer.rb
Overview
Performs the generation of docs web app.
Instance Method Summary collapse
- #clean_output_dir ⇒ Object
- #format_classes ⇒ Object
-
#initialize(relations, assets, parsed_files, opts) ⇒ Writer
constructor
A new instance of Writer.
- #write ⇒ Object
- #write_classes ⇒ Object
-
#write_html_files ⇒ Object
Generate data.js and styles.css.
-
#write_icons ⇒ Object
Copy over class and member icons.
- #write_inline_examples ⇒ Object
- #write_source ⇒ Object
-
#write_template_files ⇒ Object
Copy over template files.
Constructor Details
#initialize(relations, assets, parsed_files, opts) ⇒ Writer
Returns a new instance of Writer.
20 21 22 23 24 25 |
# File 'lib/jsduck/web/writer.rb', line 20 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
49 50 51 |
# File 'lib/jsduck/web/writer.rb', line 49 def clean_output_dir OutputDir.clean(@opts) end |
#format_classes ⇒ Object
81 82 83 |
# File 'lib/jsduck/web/writer.rb', line 81 def format_classes Format::Batch.format_all!(@relations, @assets, @opts) end |
#write ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/jsduck/web/writer.rb', line 27 def write clean_output_dir write_template_files write_icons write_html_files # 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_classes ⇒ Object
92 93 94 95 |
# File 'lib/jsduck/web/writer.rb', line 92 def write_classes class_writer = ClassWriter.new(Exporter::App, @relations, @opts) class_writer.write(@opts.output+"/output", ".js") end |
#write_html_files ⇒ Object
Generate data.js and styles.css. Then generate HTML files, linking to the data.js and styles.css from them.
66 67 68 69 70 71 72 73 74 |
# File 'lib/jsduck/web/writer.rb', line 66 def write_html_files # Remember the MD5-fingerprinted filenames paths = { :data => Web::Data.new(@relations, @assets, @opts).write(@opts.output+"/data.js"), :css => Web::Css.new(@opts).write(@opts.output+"/styles.css"), } Web::IndexHtml.new(@assets, @opts, paths).write end |
#write_icons ⇒ Object
Copy over class and member icons
59 60 61 62 |
# File 'lib/jsduck/web/writer.rb', line 59 def write_icons Web::ClassIcons.write(@opts.output+"/class-icons") Web::MemberIcons.write(@opts.output+"/member-icons") end |
#write_inline_examples ⇒ Object
85 86 87 88 89 90 |
# File 'lib/jsduck/web/writer.rb', line 85 def write_inline_examples examples = InlineExamples.new examples.add_classes(@relations) examples.add_guides(@assets.guides) examples.write(@opts.output+"/inline-examples.js") end |