You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Nov 19, 2024. It is now read-only.
desc"Check the existing _site for broken links on Jenkins"
8
-
task:cicddo
9
-
10
-
puts'Checking links with htmlproofer...'.magenta
11
-
12
-
HTMLProofer.check_directory("_site",options).run
13
-
2
+
# Run htmlproofer to check for broken links
3
+
desc'Build devdocs and check for broken links'
4
+
tasklinks: %w[buildlinks_no_build]
5
+
6
+
desc'Check the existing _site for broken links on Jenkins'
7
+
task:cicddo
8
+
puts'Checking links with htmlproofer...'.magenta
9
+
10
+
HTMLProofer.check_directory('_site',options).run
11
+
end
12
+
13
+
desc'Check the existing _site for broken links'
14
+
task:links_no_builddo
15
+
begin
16
+
# We're expecting link validation errors, but unless we rescue from StandardError, rake will abort and won't run the convert task (https://stackoverflow.com/a/10048406).
17
+
# Wrapping task in a begin-rescue block prevents rake from aborting.
18
+
# Seems to prevent printing an error count though.
19
+
20
+
puts'Checking links with htmlproofer...'.magenta
21
+
22
+
# If you're running this for the first time, create the tmp/.htmlproofer directory first or the script fails.
23
+
mkdir_pdir_nameunlessDir.exist?(dir_name)
24
+
25
+
# Write console output (stderr only) to a file.
26
+
# Use this if you need to also capture stdout: https://stackoverflow.com/a/2480439
27
+
report=md_report_path
28
+
$stderr.reopen(report,'w+')
29
+
30
+
HTMLProofer.check_directory('_site',options).run
31
+
32
+
# We're expecting link validation errors, but unless we rescue from StandardError, rake will abort and won't run the convert task (https://stackoverflow.com/a/10048406).
33
+
# Wrapping task in a begin-rescue block prevent rake from aborting.
34
+
# Seems to prevent printing an error count though.
35
+
rescueStandardError
36
+
# Show how many lines contains the Markdown report
37
+
size_in_lines(report)
14
38
end
15
-
16
-
desc"Check the existing _site for broken links"
17
-
task:links_no_builddo
18
-
19
-
begin
20
-
# We're expecting link validation errors, but unless we rescue from StandardError, rake will abort and won't run the convert task (https://stackoverflow.com/a/10048406).
21
-
# Wrapping task in a begin-rescue block prevents rake from aborting.
22
-
# Seems to prevent printing an error count though.
23
-
24
-
puts'Checking links with htmlproofer...'.magenta
25
-
26
-
# If you're running this for the first time, create the tmp/.htmlproofer directory first or the script fails.
27
-
mkdir_pdir_nameunlessDir.exists?(dir_name)
28
-
29
-
# Write console output (stderr only) to a file.
30
-
# Use this if you need to also capture stdout: https://stackoverflow.com/a/2480439
31
-
$stderr.reopen(md_report_path,"w")
32
-
33
-
HTMLProofer.check_directory("_site",options).run
34
-
35
-
# We're expecting link validation errors, but unless we rescue from StandardError, rake will abort and won't run the convert task (https://stackoverflow.com/a/10048406).
36
-
# Wrapping task in a begin-rescue block prevent rake from aborting.
37
-
# Seems to prevent printing an error count though.
38
-
rescue
39
-
# Show how many lines contains the Markdown report
40
-
size_in_lines(md_report_path)
41
-
end
42
-
end
43
-
44
-
desc"Checkout to the master branch and check the links"
45
-
taskon_master: %w[to_masterlinks]
46
-
47
-
desc"Report about broken links in HTML"
48
-
taskreport: %w[links]do
49
-
50
-
puts'Converting the link check reports to HTML...'.magenta
51
-
52
-
# Locate the output directory, iterate over markdown files inside it, and convert those files to HTML.
53
-
Find.find(dir_name)do |path|
54
-
# Filter .md files only
55
-
ifFile.extname(path) == '.md'
56
-
print"Reading the #{path} ... ".magenta
57
-
# Change a file extension to .html
58
-
html_file=path.ext('html')
59
-
File.open(html_file,'w')do |file|
60
-
print"converting to HTML ... ".magenta
61
-
file.writekramdown(content(path))
62
-
file.writecss
63
-
end
64
-
# Open the HTML reports in browser
65
-
print"opening the converted report in browser ... ".magenta
66
-
open_in_browser(html_file)
67
-
puts"Done!".green
68
-
end
69
-
end
39
+
end
40
+
41
+
desc'Checkout to the master branch and check the links'
42
+
taskon_master: %w[to_masterlinks]
43
+
44
+
desc'Report about broken links in HTML'
45
+
taskreport: %w[links]do
46
+
puts'Converting the link check reports to HTML...'.magenta
47
+
48
+
# Locate the output directory, iterate over markdown files inside it, and convert those files to HTML.
49
+
Find.find(dir_name)do |path|
50
+
# Filter .md files only
51
+
nextunlessFile.extname(path) == '.md'
52
+
print"Reading the #{path} ... ".magenta
53
+
# Change a file extension to .html
54
+
html_file=path.ext('html')
55
+
File.open(html_file,'w')do |file|
56
+
print'converting to HTML ... '.magenta
57
+
file.writekramdown(content(path))
58
+
file.writecss
59
+
end
60
+
# Open the HTML reports in browser
61
+
print'opening the converted report in browser ... '.magenta
0 commit comments