class Autodoc::Documents
Public Class Methods
Source
# File lib/autodoc/documents.rb, line 5 def initialize @table = Hash.new {|table, key| table[key] = [] } end
Public Instance Methods
Source
# File lib/autodoc/documents.rb, line 9 def append(context, example) document = Autodoc::Document.new(context.clone, example.clone) @table[document.pathname] << document end
Source
# File lib/autodoc/documents.rb, line 14 def write write_toc if Autodoc.configuration.toc write_toc_html if Autodoc.configuration.toc_html write_documents end
Private Instance Methods
Source
# File lib/autodoc/documents.rb, line 35 def render_toc ERB.new(Autodoc.configuration.toc_template, trim_mode: "-").result(binding) end
Source
# File lib/autodoc/documents.rb, line 44 def render_toc_html ERB.new(Autodoc.configuration.toc_html_template, trim_mode: "-").result(binding) end
Source
# File lib/autodoc/documents.rb, line 52 def toc_html_path Autodoc.configuration.pathname + "toc.html" end
Source
# File lib/autodoc/documents.rb, line 48 def toc_path Autodoc.configuration.pathname + "toc.md" end
Source
# File lib/autodoc/documents.rb, line 23 def write_documents @table.each do |pathname, documents| pathname.parent.mkpath pathname.open("w") {|file| file << documents.sort_by(&:line_number).map(&:render).join("\n").rstrip + "\n" } end end
Source
# File lib/autodoc/documents.rb, line 30 def write_toc toc_path.parent.mkpath toc_path.open("w") {|file| file << render_toc } end
Source
# File lib/autodoc/documents.rb, line 39 def write_toc_html toc_html_path.parent.mkpath toc_html_path.open("w") {|file| file << render_toc_html } end