Skip to content
This repository was archived by the owner on Nov 19, 2024. It is now read-only.

Commit ae0a190

Browse files
committed
Read options from the external YAML file
1 parent 869d0b1 commit ae0a190

File tree

2 files changed

+60
-94
lines changed

2 files changed

+60
-94
lines changed

_config.checks.yml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# Configuration settings for html-proofer.
2+
# For configuration documentation, refer to: https://github.com/gjtorikian/html-proofer#configuration
3+
# For configuration defaults, refer to: https://github.com/gjtorikian/html-proofer/blob/master/lib/html-proofer/configuration.rb
4+
#
5+
html-proofer:
6+
:disable_external: true
7+
:only_4xx: true
8+
:checks_to_ignore:
9+
- ImageCheck
10+
- ScriptCheck
11+
:allow_hash_ref: true
12+
:error_sort: :desc
13+
:parallel:
14+
:in_processes: 3
15+
:file_ignore:
16+
- !ruby/regexp /404.html/
17+
- !ruby/regexp /action-groups.html/
18+
- !ruby/regexp /cloud-fastly.html/
19+
- !ruby/regexp /codelinks/
20+
- !ruby/regexp /contributing.html/
21+
- !ruby/regexp /css-preprocess.html/
22+
- !ruby/regexp /es-overview.html/
23+
- !ruby/regexp /guides\/m1x/
24+
- !ruby/regexp /index.html/
25+
- !ruby/regexp /magento-third-party.html/
26+
- !ruby/regexp /magento-techbull.html/
27+
- !ruby/regexp /pattern-library/
28+
- !ruby/regexp /release-notes/
29+
- !ruby/regexp /search.html/
30+
- !ruby/regexp /swagger/
31+
- !ruby/regexp /template.html/
32+
- !ruby/regexp /theme_dictionary.html/
33+
- !ruby/regexp /videos/
34+
- !ruby/regexp /whats-new.html/
35+
:url_ignore:
36+
- !ruby/regexp /account.magento.com/
37+
- !ruby/regexp /config-guide/
38+
- !ruby/regexp /docs.magento.com/
39+
- !ruby/regexp /extension-dev-guide/
40+
- !ruby/regexp /frontend-dev-guide/
41+
- !ruby/regexp /github.com/
42+
- !ruby/regexp /guides\/v2.0/
43+
- !ruby/regexp /howdoi/
44+
- !ruby/regexp /mariadb.com/
45+
- !ruby/regexp /mrg/
46+
- !ruby/regexp /navigation/
47+
- !ruby/regexp /pattern-library/
48+
- !ruby/regexp /release-notes/
49+
- !ruby/regexp /rest/
50+
- !ruby/regexp /ui_comp_guide/
51+
- !ruby/regexp /www.thegeekstuff.com/
52+
- !ruby/regexp /yatil.net/

rakelib/proofer.rb

Lines changed: 8 additions & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -1,104 +1,18 @@
1+
# Configure html-proofer parameters
12
module Proofer
2-
# Constants to be used in options
3-
FILE_IGNORE = %w[
4-
videos
5-
swagger
6-
mftf
7-
pattern-library
8-
guides/m1x
9-
search.html
10-
404.html
11-
codelinks
12-
magento-third-party.html
13-
magento-techbull.html
14-
release-notes
15-
index.html
16-
template.html
17-
whats-new.html
18-
action-groups.html
19-
css-preprocess.html
20-
es-overview.html
21-
cloud-fastly.html
22-
theme_dictionary.html
23-
contributing.html
24-
].freeze
25-
26-
URL_IGNORE = %w[
27-
guides/v2.0
28-
architecture
29-
advanced-reporting
30-
coding-standards
31-
comp-mgr
32-
config-guide
33-
contributor-guide
34-
design-styleguide
35-
ext-best-practices
36-
extension-dev-guide
37-
frontend-dev-guide
38-
get-started
39-
graphql
40-
howdoi
41-
inventory
42-
javascript-dev-guide
43-
marketplace
44-
magento-functional-testing-framework
45-
migration
46-
modules
47-
mrg
48-
mtf
49-
pattern-library
50-
payments-integrations
51-
release-notes
52-
rest
53-
soap
54-
test
55-
ui-components
56-
ui_comp_guide
57-
pwa
58-
msi
59-
mftf
60-
github.com
61-
www.thegeekstuff.com
62-
account.magento.com
63-
yatil.net
64-
ui-library
65-
security
66-
navigation
67-
community
68-
docs.magento.com
69-
mariadb.com
70-
].freeze
71-
72-
# Configure htmlproofer parameters:
3+
# Read options from the '_config.checks.yml'
734
def options
74-
{
75-
log_level: :info,
76-
only_4xx: true,
77-
# external_only: true, # Check external links only
78-
checks_to_ignore: %w[ScriptCheck ImageCheck],
79-
allow_hash_ref: true,
80-
alt_ignore: [/.*/],
81-
file_ignore: array_to_re(FILE_IGNORE),
82-
url_ignore: array_to_re(URL_IGNORE),
83-
error_sort: :desc, # Sort by invalid link instead of affected file path (default). This makes it easier to see how many files the broken link affects.
84-
parallel: { in_processes: 3 },
85-
typhoeus: { followlocation: true, connecttimeout: 10, timeout: 30 },
86-
hydra: { max_concurrency: 50 },
87-
# cache: { :timeframe => '30d' }
88-
}
89-
end
90-
91-
# Convert array of strings to array of regular expressions
92-
def array_to_re(array)
93-
array.map { |item| /#{item}/ }
5+
config = YAML.load_file('_config.checks.yml')
6+
config['html-proofer']
947
end
958

969
# Count the number of lines in the given file
9710
def size_in_lines(filepath)
9811
f = File.new(filepath)
9912
f.readlines[-1]
10013
count = f.lineno.to_s
101-
puts "#{count} lines in the #{File.basename(filepath)} file.".blue
14+
puts "The link check report contains #{count} lines.".blue
15+
puts "To see the report, open the #{filepath} file.".blue
10216
end
10317

10418
# Read the current Git branch
@@ -113,8 +27,8 @@ def dir_name
11327

11428
# Name the file for the link checker report
11529
def file_name
116-
prefix = "broken-links-in-"
117-
timestamp = Time.now.strftime("_%m-%d_%H-%M-%S")
30+
prefix = 'broken-links-in-'
31+
timestamp = Time.now.strftime('_%m-%d_%H-%M-%S')
11832
prefix + current_branch + timestamp
11933
end
12034

0 commit comments

Comments
 (0)