Skip to content

Commit

Permalink
Add html-proofer link checking
Browse files Browse the repository at this point in the history
Follow example from 
alphagov/tech-docs-template#187

Also contains gem update.

This will be useful to keep track of fixing the 24 broken links 
currently in the tdt docs.
  • Loading branch information
Andrea Szöllössi committed Nov 4, 2019
1 parent 68ba384 commit 0a41062
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 0 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'
16 changes: 16 additions & 0 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 @@ -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
15 changes: 15 additions & 0 deletions config.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,22 @@
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 0a41062

Please sign in to comment.