From 3a408857d4554e9e5cef951eb816ab7d07888af8 Mon Sep 17 00:00:00 2001 From: Alex Wilson Date: Thu, 31 Mar 2022 15:52:33 +0100 Subject: [PATCH 1/9] BAU: Check for broken internal links Sometimes we break links (full or partial) when we move pages about or rename headers, so now html-proofer will run as part of the build to make sure we've not broken any links. --- Gemfile | 2 ++ config.rb | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/Gemfile b/Gemfile index 95a22d14..d36511e4 100644 --- a/Gemfile +++ b/Gemfile @@ -11,3 +11,5 @@ gem 'tzinfo-data', platforms: [:mswin, :mingw, :jruby] # Include the tech docs gem gem 'govuk_tech_docs' +# Include linter to check for dead internal links +gem 'html-proofer' diff --git a/config.rb b/config.rb index 4c658a71..ed181c78 100644 --- a/config.rb +++ b/config.rb @@ -1,5 +1,24 @@ require 'govuk_tech_docs' +# Check for broken links +require 'html-proofer' + GovukTechDocs.configure(self) set :layout, 'custom' + +after_build do |builder| + begin + HTMLProofer.check_directory(config[:build_dir], + { :assume_extension => true, + :disable_external => true, + :allow_hash_href => true, + :empty_alt_ignore => true, + :file_ignore => [ + /search/ # Provided by tech-docs gem but has a "broken" link from html-proofer's point of view + ] + }).run + rescue RuntimeError => e + abort e.to_s + end +end \ No newline at end of file From c8f729c72f875ff3de97656443777b8792dcca4e Mon Sep 17 00:00:00 2001 From: Alex Wilson Date: Thu, 31 Mar 2022 15:54:43 +0100 Subject: [PATCH 2/9] BAU: Fix currently broken internal links - The Reliability Engineering section for CDIO no longer exists - Remove call-to-action to update the manual as there is no corresponding section - Re-add "Testing with RSpec" header for ruby to unbreak a link - Update links after changes to source-code guidance structure --- config/tech-docs.yml | 6 +++--- .../manuals/programming-languages/nodejs/index.html.md.erb | 3 --- source/manuals/programming-languages/ruby.html.md.erb | 2 ++ source/partials/_nav-version-control-deployments.html.erb | 1 + 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/config/tech-docs.yml b/config/tech-docs.yml index 0809e7a5..405e48ad 100644 --- a/config/tech-docs.yml +++ b/config/tech-docs.yml @@ -36,8 +36,8 @@ default_owner_slack: '#gds-way' owner_slack_workspace: gds redirects: - /standards/publish-opensource-code.html: /standards/source-code/#publish-open-source-code - /standards/git.html: /standards/source-code/#working-with-git - /standards/source-code.html: /standards/source-code/ + /standards/publish-opensource-code.html: /standards/source-code/index.html#publish-open-source-code + /standards/git.html: /standards/source-code/working-with-git.html + /standards/cyber-security-overview.html: /standards/cdio-pillars.html#cdio-security /standards/testing-with-rspec.html: /manuals/programming-languages/ruby.html#testing-with-rspec /standards/secrets-ACL.html: /standards/secrets-acl.html diff --git a/source/manuals/programming-languages/nodejs/index.html.md.erb b/source/manuals/programming-languages/nodejs/index.html.md.erb index e3f3985e..9344ae5b 100644 --- a/source/manuals/programming-languages/nodejs/index.html.md.erb +++ b/source/manuals/programming-languages/nodejs/index.html.md.erb @@ -20,9 +20,6 @@ the main [programming languages manual page](../../programming-languages.html). The advice here is specifically about Node.js. Generic guidelines on writing code are out of scope. -If you want to contribute to this document please see the [Updating this -manual](#updating-this-manual) section below. - Most guidelines listed here are recommendations, and the authors acknowledge that there will sometimes be valid exceptions. diff --git a/source/manuals/programming-languages/ruby.html.md.erb b/source/manuals/programming-languages/ruby.html.md.erb index 3b8c264b..8d701376 100644 --- a/source/manuals/programming-languages/ruby.html.md.erb +++ b/source/manuals/programming-languages/ruby.html.md.erb @@ -33,6 +33,8 @@ applications we have chosen [Sinatra] before - however this should be approached with caution as these can easily become large applications over time that are less conventionally organised than Rails applications. +## Testing with RSpec + For testing, the [RSpec] framework is the conventional and preferred choice. RSpec provides an expressive syntax that lends itself to producing readable tests. For testing functionality from a user's perspective it is preferred diff --git a/source/partials/_nav-version-control-deployments.html.erb b/source/partials/_nav-version-control-deployments.html.erb index a0faff31..5c635a90 100644 --- a/source/partials/_nav-version-control-deployments.html.erb +++ b/source/partials/_nav-version-control-deployments.html.erb @@ -1,5 +1,6 @@