Class: PrmGenerator::Generator
- Inherits:
-
Object
- Object
- PrmGenerator::Generator
- Extended by:
- T::Sig
- Defined in:
- lib/udb/prm_generator.rb
Overview
Main PRM generation coordinator
The Generator class orchestrates the PRM (Processor Reference Manual) generation process. It validates input parameters, loads PRM configuration, and coordinates the creation of AsciiDoc and PDF documentation files. Usage involves initializing with required paths and resolver, then calling ‘generate_adoc` and/or `generate_pdf` to produce documentation. Key responsibilities:
- Validating inputs and configuration
- Loading PRM data and processor configuration
- Generating component documentation (CSRs, instructions, extensions, non-ISA specs)
- Assembling and exporting the main PRM document in AsciiDoc and PDF formats
Instance Attribute Summary collapse
-
#output_dir ⇒ Object
readonly
Returns the value of attribute output_dir.
-
#prm_name ⇒ Object
readonly
Returns the value of attribute prm_name.
-
#resolver ⇒ Object
readonly
Returns the value of attribute resolver.
-
#root_dir ⇒ Object
readonly
Returns the value of attribute root_dir.
-
#template_dir ⇒ Object
readonly
Returns the value of attribute template_dir.
Instance Method Summary collapse
- #generate_adoc ⇒ Object
- #generate_pdf ⇒ Object
-
#initialize(prm_name, resolver:, output_dir:, template_dir:, root_dir:) ⇒ Generator
constructor
A new instance of Generator.
Constructor Details
#initialize(prm_name, resolver:, output_dir:, template_dir:, root_dir:) ⇒ Generator
Returns a new instance of Generator.
60 61 62 63 64 65 66 67 68 |
# File 'lib/udb/prm_generator.rb', line 60 def initialize(prm_name, resolver:, output_dir:, template_dir:, root_dir:) @prm_name = prm_name @resolver = resolver @output_dir = Pathname.new(output_dir) @template_dir = Pathname.new(template_dir) @root_dir = Pathname.new(root_dir) validate_inputs end |
Instance Attribute Details
#output_dir ⇒ Object (readonly)
Returns the value of attribute output_dir.
58 59 60 |
# File 'lib/udb/prm_generator.rb', line 58 def output_dir @output_dir end |
#prm_name ⇒ Object (readonly)
Returns the value of attribute prm_name.
58 59 60 |
# File 'lib/udb/prm_generator.rb', line 58 def prm_name @prm_name end |
#resolver ⇒ Object (readonly)
Returns the value of attribute resolver.
58 59 60 |
# File 'lib/udb/prm_generator.rb', line 58 def resolver @resolver end |
#root_dir ⇒ Object (readonly)
Returns the value of attribute root_dir.
58 59 60 |
# File 'lib/udb/prm_generator.rb', line 58 def root_dir @root_dir end |
#template_dir ⇒ Object (readonly)
Returns the value of attribute template_dir.
58 59 60 |
# File 'lib/udb/prm_generator.rb', line 58 def template_dir @template_dir end |
Instance Method Details
#generate_adoc ⇒ Object
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/udb/prm_generator.rb', line 70 def generate_adoc puts "[INFO] Generating AsciiDoc files for #{prm_name}..." prm = load_prm processor_config = prm.processor_config adoc_output_dir = @output_dir / prm_name / "adoc" # Clean and create output directory FileUtils.rm_rf(adoc_output_dir) FileUtils.mkdir_p(adoc_output_dir) # Generate individual component files ComponentGenerator.new(processor_config, prm_name, adoc_output_dir, @template_dir).generate_all puts "[INFO] AsciiDoc generation complete for #{prm_name}" end |
#generate_pdf ⇒ Object
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 |
# File 'lib/udb/prm_generator.rb', line 87 def generate_pdf puts "[INFO] Generating PDF for #{prm_name}..." prm = load_prm pdf_output_dir = @output_dir / prm_name / "pdf" FileUtils.mkdir_p(pdf_output_dir) # Generate main document main_generator = MainDocumentGenerator.new( prm, @resolver, @output_dir / prm_name, @template_dir, @root_dir ) main_adoc_path = pdf_output_dir / "_prm_main.adoc" main_content = main_generator.generate File.write(main_adoc_path, main_content) puts "[INFO] Generated main AsciiDoc: #{main_adoc_path}" # Generate PDF pdf_path = pdf_output_dir / "#{prm_name}-specification.pdf" PdfGenerator.new(@template_dir, @root_dir).generate(main_adoc_path, pdf_path) puts "[INFO] PDF generation complete: #{pdf_path}" end |