Class: RosettAi::Documentation::ReferenceCompiler
- Inherits:
-
Object
- Object
- RosettAi::Documentation::ReferenceCompiler
- Defined in:
- lib/rosett_ai/documentation/reference_compiler.rb
Overview
Compiles the LaTeX technical reference document.
Runs the full pdflatex → biber → makeindex → pdflatex toolchain to produce doc/reference/rosett-ai-technical-reference.pdf from the LaTeX sources in doc/reference/src/.
Design reference: conf/design/documentation.yml
Constant Summary collapse
- REQUIRED_TOOLS =
['pdflatex', 'biber', 'makeindex'].freeze
- OUTPUT_NAME =
'rosett-ai-technical-reference.pdf'- BUILD_ARTIFACTS =
['aux', 'bbl', 'bcf', 'blg', 'idx', 'ilg', 'ind', 'lof', 'log', 'lot', 'out', 'ptc', 'run.xml', 'toc'].freeze
Instance Method Summary collapse
- #available? ⇒ Boolean
- #compile! ⇒ Object
-
#initialize(root: nil) ⇒ ReferenceCompiler
constructor
A new instance of ReferenceCompiler.
- #missing_tools ⇒ Object
- #output_path ⇒ Object
- #source_dir ⇒ Object
- #stale? ⇒ Boolean
Constructor Details
#initialize(root: nil) ⇒ ReferenceCompiler
Returns a new instance of ReferenceCompiler.
24 25 26 |
# File 'lib/rosett_ai/documentation/reference_compiler.rb', line 24 def initialize(root: nil) @root = root || RosettAi.root end |
Instance Method Details
#available? ⇒ Boolean
28 29 30 |
# File 'lib/rosett_ai/documentation/reference_compiler.rb', line 28 def available? REQUIRED_TOOLS.all? { |tool| tool_on_path?(tool) } end |
#compile! ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/rosett_ai/documentation/reference_compiler.rb', line 44 def compile! raise RosettAi::DocumentationError, "Missing LaTeX tools: #{missing_tools.join(', ')}" unless available? raise RosettAi::DocumentationError, "Source directory not found: #{source_dir}" unless source_dir.exist? Dir.chdir(source_dir) do run_pdflatex! run_biber! run_makeindex 3.times { run_pdflatex! } end install_pdf! clean_artifacts! end |
#missing_tools ⇒ Object
32 33 34 |
# File 'lib/rosett_ai/documentation/reference_compiler.rb', line 32 def missing_tools REQUIRED_TOOLS.reject { |tool| tool_on_path?(tool) } end |
#output_path ⇒ Object
59 60 61 |
# File 'lib/rosett_ai/documentation/reference_compiler.rb', line 59 def output_path @root.join('doc', 'reference', OUTPUT_NAME) end |
#source_dir ⇒ Object
63 64 65 |
# File 'lib/rosett_ai/documentation/reference_compiler.rb', line 63 def source_dir @root.join('doc', 'reference', 'src') end |
#stale? ⇒ Boolean
36 37 38 39 40 41 42 |
# File 'lib/rosett_ai/documentation/reference_compiler.rb', line 36 def stale? pdf = output_path return true unless pdf.exist? pdf_mtime = pdf.mtime source_files.any? { |f| f.mtime > pdf_mtime } end |