-
Notifications
You must be signed in to change notification settings - Fork 237
/
Rakefile
76 lines (64 loc) · 2.42 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
#encoding: utf-8
namespace :links do
require 'html-proofer'
require 'optparse'
files_ignore = []
note = '(This can take a few mins to run) '
desc 'Build site'
task :build do
if ARGV.length > 0
if ARGV.include? "quiet"
quiet = '-q'
# BLACK MAGIC TO HIJACK ARG AS A TASK
task ARGV.last.to_sym do ; end
else
quiet = ''
# BLACK MAGIC TO HIJACK ARG AS A TASK
task ARGV.last.to_sym do ; end
end
end
puts
puts "Building site..."
sh 'mkdocs build -f mkdocs.yml -d site' + ' ' + String(quiet)
end
desc 'Checks html files for broken external links'
task :test_external, [:ARGV] do
# Verify regex at https://regex101.com
options = {
:assume_extension => true,
:log_level => :info,
:external_only => true,
:internal_domains => ["https://instructor.labs.sysdeseng.com", "https://www.youtube.com"],
:url_ignore => [ /http(s)?:\/\/(www.)?katacoda.com.*/ ],
:url_swap => {'https://kubevirt.io/' => '',},
:http_status_ignore => [0, 400, 429, 999]
}
parser = OptionParser.new
parser.banner = "Usage: rake -- [arguments]"
# Added option -u which will remove the url_swap option to from the map
parser.on("-u", "--us", "Remove url_swap from htmlProofer") do |url_swap|
options.delete(:url_swap)
end
args = parser.order!(ARGV) {}
parser.parse!(args)
puts
puts "Checks html files for broken external links " + note + "..."
HTMLProofer.check_directory("./site", options).run
end
desc 'Checks html files for broken internal links'
task :test_internal do
options = {
:assume_extension => true,
:allow_hash_href => true,
:log_level => :info,
:disable_external => true,
:url_swap => {'/user-guide' => '',},
:http_status_ignore => [0, 200, 400, 429, 999]
}
puts
puts "Checks html files for broken internal links " + note + "..."
HTMLProofer.check_directory("./site", options).run
end
end
desc 'The default task will execute all tests in a row'
task :default => ['links:build', 'links:test_external', 'links:test_internal']