Class: PackerFiles::DocGenerator
- Inherits:
-
Object
- Object
- PackerFiles::DocGenerator
- Defined in:
- lib/PackerFiles/OS/DocGenerator.rb
Instance Method Summary collapse
-
#Generate ⇒ Object
Generate the documentation.This is done by looking at the type accessors that are defined by the OS class and then calling the doc_file function to figure out the ERB template.
-
#initialize(class_name, filename) ⇒ DocGenerator
constructor
Constructor accepts a class name and the file name to write the documentation to.
Constructor Details
#initialize(class_name, filename) ⇒ DocGenerator
Constructor accepts a class name and the file name to write the documentation to.
10 11 12 13 |
# File 'lib/PackerFiles/OS/DocGenerator.rb', line 10 def initialize(class_name, filename) @class_name = class_name @file_name = filename end |
Instance Method Details
#Generate ⇒ Object
Generate the documentation.This is done by looking at the type accessors that are defined by the OS class and then calling the doc_file function to figure out the ERB template.
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/PackerFiles/OS/DocGenerator.rb', line 18 def Generate # Generate content for all the type accessor classes. content = [] ancestry_class_list.each do |class_name| hash = class_name.type_accessors next if hash.nil? hash.each_pair { |func, type_data| file = type_data.first.doc_file hash = {'name' => func, 'mod' => PackerFiles} doc = PackerFiles.evaluate_erb(file, hash) content += doc.split("\n").map {|line| ' ' + line } } end # Generate content for the top level structure. top_doc_file = PackerFiles.DirPath('OS/example/Doc.txt').first os_name = @class_name.name.gsub('PackerFiles::', '') hash = Hash['os_name', os_name, 'content', content] value = PackerFiles.evaluate_erb(top_doc_file, hash) File.write(@file_name, value) end |