summaryrefslogtreecommitdiff
path: root/rakelib/doc.rake
blob: 7838871b1ac0530d81c468fee65f6749f43b7bfb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# This Source Code Form is subject to the terms of the Mozilla Public License,
# v. 2.0. If a copy of the MPL was not distributed with this file, You can
# obtain one at https://mozilla.org/MPL/2.0/.
# frozen_string_literal: true

require 'pathname'
require 'rake/clean'

CLEAN.include 'build/doc'
directory 'build/doc'

rule '.bbl' => '.bcf' do |t|
  task_target = Pathname.new t.name
  chdir = 'doc'
  output_directory = task_target.dirname.relative_path_from(chdir).to_path
  source = task_target.basename('.bbl').to_path

  sh 'biber', '-output-directory', output_directory, source, chdir:
end

namespace :doc do
  task tex: 'build/doc' do |t|
    sh 'pdflatex', '-output-directory', "../#{t.prerequisites.first}", 'report',
      chdir: 'doc'
  end
end

desc 'Generate documentation'
task doc: 'doc:tex' do
  Rake::Task['build/doc/report.bbl'].invoke
  Rake::Task['doc:tex'].reenable
  Rake::Task['doc:tex'].invoke
end