Class: Howdoc::Writers::Html
- Inherits:
-
Object
- Object
- Howdoc::Writers::Html
- Defined in:
- lib/howdoc/writers.rb
Overview
Writes the illustrated guide a reader actually opens -- one page per language the guide is published in.
Class Method Summary collapse
- .call(document) ⇒ Object
- .copy_screenshot(source, edition, number) ⇒ Object
-
.copy_screenshots(document, edition) ⇒ Object
A picture of the application is the same picture whatever language the page around it is written in, so it is taken once, while the browser is still on the page, and copied to where each edition looks for it.
- .write(document, edition) ⇒ Object
Class Method Details
.call(document) ⇒ Object
34 35 36 |
# File 'lib/howdoc/writers.rb', line 34 def self.call(document) document.editions.map { |edition| write(document, edition) } end |
.copy_screenshot(source, edition, number) ⇒ Object
63 64 65 66 67 68 |
# File 'lib/howdoc/writers.rb', line 63 def self.copy_screenshot(source, edition, number) return unless File.file?(source) FileUtils.mkdir_p(edition.image_dir) FileUtils.cp(source, File.join(edition.image_dir, edition.image_filename(number))) end |
.copy_screenshots(document, edition) ⇒ Object
A picture of the application is the same picture whatever language the page around it is written in, so it is taken once, while the browser is still on the page, and copied to where each edition looks for it.
53 54 55 56 57 58 59 60 61 |
# File 'lib/howdoc/writers.rb', line 53 def self.copy_screenshots(document, edition) return if edition.equal?(document.primary) document.steps.each do |step| next if step.screenshot.nil? copy_screenshot(File.join(document.image_dir, step.screenshot), edition, step.number) end end |
.write(document, edition) ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/howdoc/writers.rb', line 38 def self.write(document, edition) FileUtils.mkdir_p(edition.dir) copy_screenshots(document, edition) markup = Templates.render( 'document/html/layout.haml', document: edition, config: Howdoc.config ) File.write(edition.path('html'), markup) edition.path('html') end |