-
Notifications
You must be signed in to change notification settings - Fork 347
/
Rakefile
85 lines (70 loc) · 1.8 KB
/
Rakefile
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# frozen_string_literal: true
require 'rake/clean'
require 'rubocop/rake_task'
# If no task given, build
task default: :build
# Support clean and clobber tasks
CLEAN << '_site'
CLOBBER << '_cache' << '.sass-cache' << '_data/indico'
desc 'Preview on a local machine'
task :serve do
trap('SIGINT') { exit }
jekyll 'serve', :incremental, :livereload
end
desc 'Build on a local machine'
task :build do
jekyll 'build', :verbose, :trace
end
desc 'Cache the indico access'
task :cache do
sh 'jekyll-indico-cache'
end
RuboCop::RakeTask.new(:rubocop)
# See https://github.com/gjtorikian/html-proofer#configuration
COMMON_OPTIONS = {
assume_extension: true,
allow_hash_href: true,
url_swap: { %r{https://localhost:4000/} => '' }
}.freeze
LIGHT_OPTIONS = {
url_ignore: [
'Unknown',
'http://vassil.vassilev.info',
'https://indico.lal.in2p3.fr/event/4754/#sc-19-8-machine-learning-to-pr', # Fix
%r{https://www.ci.uchicago.edu/profile/.*}
]
}.freeze
desc 'Check already built site'
task :checkonly do
html_proofer COMMON_OPTIONS, LIGHT_OPTIONS
end
desc 'Check links and things'
task check: %i[build checkonly]
desc 'Stronger check for missing options - will show up as warnings on GHA'
task checkall: :build do
html_proofer COMMON_OPTIONS
end
### Support functions ###
# Run the jekyll command, with arguments
# (symbols are long options, hashes are long options with arguments)
def jekyll(*directives)
directives.map! do |x|
case x
when Symbol
"--#{x}"
when Hash
x.map { |k, v| "--#{k}=#{v}" }.join(' ')
else x
end
end
sh "jekyll #{directives.join(' ')}"
end
# Run HTMLProofer
def html_proofer(*options)
require 'html-proofer'
begin
HTMLProofer.check_directory('./_site', options.inject(:merge)).run
rescue RuntimeError => e
abort e.message
end
end