Skip to content

Commit

Permalink
Set up html-proofer as the link checker
Browse files Browse the repository at this point in the history
Following configuration from
alphagov/tech-docs-template#187
  • Loading branch information
Andrea Szöllössi committed Nov 11, 2019
1 parent 998750a commit 8d7ce74
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 2 deletions.
3 changes: 3 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,6 @@ gem 'govuk_tech_docs'
gem 'therubyracer'

gem 'middleman-gh-pages'

# Include linter to check for dead internal links
gem 'html-proofer'
20 changes: 18 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ GEM
eventmachine (>= 0.12.9)
http_parser.rb (~> 0.6.0)
erubis (2.7.0)
ethon (0.12.0)
ffi (>= 1.3.0)
eventmachine (1.2.7)
execjs (2.7.0)
fast_blank (1.0.0)
Expand Down Expand Up @@ -66,6 +68,14 @@ GEM
hamster (3.0.0)
concurrent-ruby (~> 1.0)
hashie (3.6.0)
html-proofer (3.13.0)
addressable (~> 2.3)
mercenary (~> 0.3)
nokogiri (~> 1.10)
parallel (~> 1.3)
rainbow (~> 3.0)
typhoeus (~> 1.3)
yell (~> 2.0)
http_parser.rb (0.6.0)
i18n (0.9.5)
concurrent-ruby (~> 1.0)
Expand All @@ -75,6 +85,7 @@ GEM
rb-fsevent (~> 0.9, >= 0.9.4)
rb-inotify (~> 0.9, >= 0.9.7)
memoist (0.16.0)
mercenary (0.3.6)
method_source (0.9.2)
middleman (4.3.5)
coffee-script (~> 2.2)
Expand Down Expand Up @@ -130,9 +141,9 @@ GEM
middleman-core (>= 3.2)
rouge (~> 2.0)
mini_portile2 (2.4.0)
minitest (5.12.2)
minitest (5.13.0)
multi_json (1.14.1)
nokogiri (1.10.4)
nokogiri (1.10.5)
mini_portile2 (~> 2.4.0)
openapi3_parser (0.5.2)
commonmarker (~> 0.17)
Expand All @@ -150,6 +161,7 @@ GEM
rack (2.0.7)
rack-livereload (0.3.17)
rack
rainbow (3.0.0)
rake (13.0.0)
rb-fsevent (0.10.3)
rb-inotify (0.10.0)
Expand All @@ -173,16 +185,20 @@ GEM
thor (0.20.3)
thread_safe (0.3.6)
tilt (2.0.10)
typhoeus (1.3.1)
ethon (>= 0.9.0)
tzinfo (1.2.5)
thread_safe (~> 0.1)
uglifier (3.2.0)
execjs (>= 0.3.0, < 3)
yell (2.2.0)

PLATFORMS
ruby

DEPENDENCIES
govuk_tech_docs
html-proofer
middleman-gh-pages
therubyracer
tzinfo-data
Expand Down
16 changes: 16 additions & 0 deletions config.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,23 @@
require 'govuk_tech_docs'

# Check for broken links
require 'html-proofer'

GovukTechDocs.configure(self, livereload: { js_host: "localhost" })

after_build do |builder|
begin
HTMLProofer.check_directory(config[:build_dir],
{ :assume_extension => true,
:disable_external => true,
:allow_hash_href => true,
:url_swap => { config[:tech_docs][:host] => "" } }).run
rescue RuntimeError => e
abort e.to_s
end
end


DOCS_LOCATION_IN_GEM = Bundler.rubygems.find_name('govuk_tech_docs').first.full_gem_path + "/docs"

files.watch :source, path: DOCS_LOCATION_IN_GEM
Expand Down

0 comments on commit 8d7ce74

Please sign in to comment.