diff --git a/Gemfile b/Gemfile index 07e93f1..dc5c858 100644 --- a/Gemfile +++ b/Gemfile @@ -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' diff --git a/Gemfile.lock b/Gemfile.lock index 97e1939..010102b 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -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) @@ -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) @@ -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) @@ -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) @@ -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) @@ -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 diff --git a/config.rb b/config.rb index ebdbabd..09fccf1 100644 --- a/config.rb +++ b/config.rb @@ -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