Class: Instadoc::HtmlBuilder
- Inherits:
-
Object
- Object
- Instadoc::HtmlBuilder
- Defined in:
- lib/instadoc/html_builder.rb
Instance Method Summary collapse
- #build(files) ⇒ Object
- #build_hyperlink(file_name) ⇒ Object
- #create(files, pathname = @config.output_path) ⇒ Object
-
#initialize(config) ⇒ HtmlBuilder
constructor
A new instance of HtmlBuilder.
- #write_to_file(html, pathname) ⇒ Object
Constructor Details
#initialize(config) ⇒ HtmlBuilder
Returns a new instance of HtmlBuilder.
7 8 9 |
# File 'lib/instadoc/html_builder.rb', line 7 def initialize(config) @config = config end |
Instance Method Details
#build(files) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/instadoc/html_builder.rb', line 11 def build(files) builder = Nokogiri::HTML::Builder.new do |doc| doc.html { doc.body() { doc.table(:border => 1) { doc.th "Documentation" doc.th "Hyperlink to class" doc.th "Line number" files.each { |file| file.documented_lines.keys.each { |line_number| doc.tr { doc.td_ file.documented_lines[line_number] doc.td { doc.a(:href => build_hyperlink(file.name_with_package)) { doc.text file.pathname.basename } } doc.td_ line_number } } } } } } end builder.to_html end |
#build_hyperlink(file_name) ⇒ Object
53 54 55 |
# File 'lib/instadoc/html_builder.rb', line 53 def build_hyperlink(file_name) @config.hyperlink_for(file_name) end |
#create(files, pathname = @config.output_path) ⇒ Object
39 40 41 42 43 44 45 |
# File 'lib/instadoc/html_builder.rb', line 39 def create(files, pathname = @config.output_path) html = build(files) write_to_file(html, pathname) unless @config.verbose puts "Documentation summery written to #{pathname.realpath}" end end |
#write_to_file(html, pathname) ⇒ Object
47 48 49 50 51 |
# File 'lib/instadoc/html_builder.rb', line 47 def write_to_file(html, pathname) file = @config.open_new_file(pathname) file.puts html file end |