Class: RosettAi::Documentation::ReferenceCompiler

Inherits:
Object
  • Object
show all
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 =

Returns External tools required for documentation compilation.

Returns:

  • (Array)

    External tools required for documentation compilation.

['pdflatex', 'biber', 'makeindex'].freeze
OUTPUT_NAME =

Returns Filename for compiled reference documentation.

Returns:

  • (String)

    Filename for compiled reference documentation.

'rosett-ai-technical-reference.pdf'
BUILD_ARTIFACTS =

Returns Files produced during reference documentation build.

Returns:

  • (Array)

    Files produced during reference documentation build.

['aux', 'bbl', 'bcf', 'blg', 'idx', 'ilg', 'ind',
'lof', 'log', 'lot', 'out', 'ptc', 'run.xml', 'toc'].freeze

Instance Method Summary collapse

Constructor Details

#initialize(root: nil) ⇒ ReferenceCompiler

Returns a new instance of ReferenceCompiler.



27
28
29
# File 'lib/rosett_ai/documentation/reference_compiler.rb', line 27

def initialize(root: nil)
  @root = root || RosettAi.root
end

Instance Method Details

#available?Boolean

Returns:

  • (Boolean)


31
32
33
# File 'lib/rosett_ai/documentation/reference_compiler.rb', line 31

def available?
  REQUIRED_TOOLS.all? { |tool| tool_on_path?(tool) }
end

#compile!Object



49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/rosett_ai/documentation/reference_compiler.rb', line 49

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_toolsArray<String>

Return external tools required but not installed.

Returns:

  • (Array<String>)


37
38
39
# File 'lib/rosett_ai/documentation/reference_compiler.rb', line 37

def missing_tools
  REQUIRED_TOOLS.reject { |tool| tool_on_path?(tool) }
end

#output_pathPathname

Return the compiled documentation output path.

Returns:

  • (Pathname)


66
67
68
# File 'lib/rosett_ai/documentation/reference_compiler.rb', line 66

def output_path
  @root.join('doc', 'reference', OUTPUT_NAME)
end

#source_dirPathname

Return the man page source directory.

Returns:

  • (Pathname)


72
73
74
# File 'lib/rosett_ai/documentation/reference_compiler.rb', line 72

def source_dir
  @root.join('doc', 'reference', 'src')
end

#stale?Boolean

Returns:

  • (Boolean)


41
42
43
44
45
46
47
# File 'lib/rosett_ai/documentation/reference_compiler.rb', line 41

def stale?
  pdf = output_path
  return true unless pdf.exist?

  pdf_mtime = pdf.mtime
  source_files.any? { |f| f.mtime > pdf_mtime }
end