Skip to content

Commit

Permalink
Migrate validation to Jekyll hooks (#2709)
Browse files Browse the repository at this point in the history
Compared to the use of the validate.py scripts, this has the advantage of ensuring the validation is always performed.

It also gives access to enriched data, which is useful for validated generated content, such as release links. It also check links in the product description.
Note that some links had to be excluded from this check because, despite being valid, they are systematically returning an error.
A dependency to open-uri (https://github.com/ruby/open-uri) has been added to simplify the validation of HTTP links.

For this to work the priority of the ProductDataEnricher plugin has been set to normal, to allow hooks to be run before and after enrichment.

Some alternate URLs has been changed or removed due to an enforcement of the rules regarding permalinks and alternate_urls (no more dots).
  • Loading branch information
marcwrobel committed May 12, 2023
1 parent 1162d3b commit 24259c4
Show file tree
Hide file tree
Showing 10 changed files with 290 additions and 143 deletions.
19 changes: 0 additions & 19 deletions .github/workflows/validate.yaml

This file was deleted.

3 changes: 3 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,6 @@ gem "wdm", "~> 0.1.0" if Gem.win_platform?
gem "webrick", "~> 1.8"

gem 'icalendar', '~> 2.7'

# Used in product-data-validator to check URLs
gem "open-uri", "~> 0.3"
10 changes: 10 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ GEM
public_suffix (>= 2.0.2, < 6.0)
colorator (1.1.0)
concurrent-ruby (1.2.2)
date (3.3.3)
em-websocket (0.5.3)
eventmachine (>= 0.12.9)
http_parser.rb (~> 0)
Expand Down Expand Up @@ -76,6 +77,10 @@ GEM
minitest (5.18.0)
nokogiri (1.14.3-x86_64-linux)
racc (~> 1.4)
open-uri (0.3.0)
stringio
time
uri
pathutil (0.16.2)
forwardable-extended (~> 2.6)
posix-spawn (0.3.15)
Expand All @@ -90,11 +95,15 @@ GEM
safe_yaml (1.0.5)
sassc (2.4.0)
ffi (~> 1.9)
stringio (3.0.6)
terminal-table (3.0.2)
unicode-display_width (>= 1.1.1, < 3)
time (0.2.2)
date
tzinfo (2.0.6)
concurrent-ruby (~> 1.0)
unicode-display_width (2.3.0)
uri (0.12.1)
webrick (1.8.1)

PLATFORMS
Expand All @@ -109,6 +118,7 @@ DEPENDENCIES
jekyll-timeago
jemoji
just-the-docs
open-uri (~> 0.3)
tzinfo-data
webrick (~> 1.8)

Expand Down
119 changes: 0 additions & 119 deletions _auto/validate.py

This file was deleted.

3 changes: 3 additions & 0 deletions _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ defaults:
path: "products"
values:
layout: product
alternate_urls: []
identifiers: []
auto: []
releaseColumn: true
releaseColumnLabel: 'Latest'
releaseDateColumn: false
Expand Down
2 changes: 1 addition & 1 deletion _plugins/product-data-enricher.rb
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,6 @@ def render_eol_template(template, cycle)
end
end

Jekyll::Hooks.register [:pages], :post_init do |page|
Jekyll::Hooks.register [:pages], :post_init, priority: Jekyll::Hooks::PRIORITY_MAP[:normal] do |page|
Jekyll::ProductDataEnricher.enrich(page) if Jekyll::ProductDataEnricher.is_product?(page)
end

0 comments on commit 24259c4

Please sign in to comment.