Skip to content

Commit 740ea92

Browse files
committed
refactor: architecture cleanup — OCP-compliant CSS, data-driven nav, test suite
Architectural changes: - CSS: Replace ~90 per-type/per-stage selectors with 6 generic variable-driven rules (--stage-color, --doctype-color, --badge-color, --cat-color) for Open/Closed Principle compliance - Navigation: Extract _data/navigation.yml as single source of truth for categories and draft stages; header, footer, and home page all consume it - Config: Remove dead 'documents' collection, add proper excludes for _archive/, spec/, _data/schemas/ - Layouts: doc-type layout supports stage_filter_name for data-driven filtering Quality assurance: - Add JSON Schema (documents.schema.json) for aggregated document data contract - Add RSpec suite: 26 examples covering config, rake tasks, schema validation, data integrity, and template references - Add json_schemer gem for schema validation, rspec for test framework Cleanup: - Archive unused layouts (toc.html, toc-type.html, document.html) and includes (toc-*, disqus_comments, feedback, script, find-doc) - Remove generated relaton.css from public/ - Update .gitignore to exclude entire public/ directory
1 parent c41edfa commit 740ea92

32 files changed

Lines changed: 556 additions & 211 deletions

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ assets/relaton.css
3232

3333
# Vite / Node
3434
node_modules/
35-
public/vite*
35+
public/
3636
config/
3737
vendor/
3838

Gemfile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,8 @@ end
1414

1515
gem "tzinfo-data", platforms: [:mingw, :mswin, :x64_mingw, :jruby]
1616
gem "wdm", "~> 0.1.0" if Gem.win_platform?
17+
18+
group :test do
19+
gem "rspec", "~> 3.13"
20+
gem "json_schemer", "~> 2.0"
21+
end

Gemfile.lock

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ GEM
3131
connection_pool (3.0.2)
3232
csv (3.3.5)
3333
date (3.5.1)
34+
diff-lcs (1.6.2)
3435
diffy (3.4.4)
3536
domain_name (0.6.20240107)
3637
dry-cli (1.4.1)
@@ -74,6 +75,7 @@ GEM
7475
google-protobuf (4.34.1-x86_64-linux-musl)
7576
bigdecimal
7677
rake (~> 13.3)
78+
hana (1.3.7)
7779
http-cookie (1.1.6)
7880
domain_name (~> 0.5)
7981
http_parser.rb (0.8.1)
@@ -116,6 +118,11 @@ GEM
116118
jekyll-watch (2.2.1)
117119
listen (~> 3.0)
118120
json (2.19.5)
121+
json_schemer (2.5.0)
122+
bigdecimal
123+
hana (~> 1.3)
124+
regexp_parser (~> 2.0)
125+
simpleidn (~> 0.2)
119126
kramdown (2.5.2)
120127
rexml (>= 3.4.4)
121128
kramdown-parser-gfm (1.1.0)
@@ -204,6 +211,7 @@ GEM
204211
rb-fsevent (0.11.2)
205212
rb-inotify (0.11.1)
206213
ffi (~> 1.0)
214+
regexp_parser (2.12.0)
207215
relaton-bib (2.1.3)
208216
bibtex-ruby
209217
iso639
@@ -237,6 +245,19 @@ GEM
237245
lutaml-model (~> 0.8.0)
238246
nokogiri
239247
rouge (4.7.0)
248+
rspec (3.13.2)
249+
rspec-core (~> 3.13.0)
250+
rspec-expectations (~> 3.13.0)
251+
rspec-mocks (~> 3.13.0)
252+
rspec-core (3.13.6)
253+
rspec-support (~> 3.13.0)
254+
rspec-expectations (3.13.5)
255+
diff-lcs (>= 1.2.0, < 2.0)
256+
rspec-support (~> 3.13.0)
257+
rspec-mocks (3.13.8)
258+
diff-lcs (>= 1.2.0, < 2.0)
259+
rspec-support (~> 3.13.0)
260+
rspec-support (3.13.7)
240261
rubyntlm (0.6.5)
241262
base64
242263
rubyzip (2.3.2)
@@ -260,6 +281,7 @@ GEM
260281
sawyer (0.9.3)
261282
addressable (>= 2.3.5)
262283
faraday (>= 0.17.3, < 3)
284+
simpleidn (0.2.3)
263285
stringio (3.2.0)
264286
terminal-table (3.0.2)
265287
unicode-display_width (>= 1.1.1, < 3)
@@ -294,9 +316,11 @@ DEPENDENCIES
294316
jekyll-calconnect-theme
295317
jekyll-feed (~> 0.17.0)
296318
jekyll-vite
319+
json_schemer (~> 2.0)
297320
metanorma-release!
298321
octokit (~> 9.0)
299322
relaton-calconnect (~> 2.1)
323+
rspec (~> 3.13)
300324
tzinfo-data
301325

302326
CHECKSUMS
@@ -313,6 +337,7 @@ CHECKSUMS
313337
connection_pool (3.0.2) sha256=33fff5ba71a12d2aa26cb72b1db8bba2a1a01823559fb01d29eb74c286e62e0a
314338
csv (3.3.5) sha256=6e5134ac3383ef728b7f02725d9872934f523cb40b961479f69cf3afa6c8e73f
315339
date (3.5.1) sha256=750d06384d7b9c15d562c76291407d89e368dda4d4fff957eb94962d325a0dc0
340+
diff-lcs (1.6.2) sha256=9ae0d2cba7d4df3075fe8cd8602a8604993efc0dfa934cff568969efb1909962
316341
diffy (3.4.4) sha256=79384ab5ca82d0e115b2771f0961e27c164c456074bd2ec46b637ebf7b6e47e3
317342
domain_name (0.6.20240107) sha256=5f693b2215708476517479bf2b3802e49068ad82167bcd2286f899536a17d933
318343
dry-cli (1.4.1) sha256=b8015bb76c708aa8705a36faf694973e75eeeffca39b89c8e172dc6f66a7d874
@@ -336,6 +361,7 @@ CHECKSUMS
336361
google-protobuf (4.34.1-x86_64-darwin) sha256=4dc498376e218871613589c4d872400d42ad9ae0c700bdb2606fe1c77a593075
337362
google-protobuf (4.34.1-x86_64-linux-gnu) sha256=87088c9fd8e47b5b40ca498fc1195add6149e941ff7e81c532a5b0b8876d4cc9
338363
google-protobuf (4.34.1-x86_64-linux-musl) sha256=8c0e91436fbe504ffc64f0bd621f2e69adbcce8ed2c58439d7a21117069cfdd7
364+
hana (1.3.7) sha256=5425db42d651fea08859811c29d20446f16af196308162894db208cac5ce9b0d
339365
http-cookie (1.1.6) sha256=ba4b82be64de61dc281243dac70e3c382c45142f20268ed9276a3670c93feaa9
340366
http_parser.rb (0.8.1) sha256=9ae8df145b39aa5398b2f90090d651c67bd8e2ebfe4507c966579f641e11097a
341367
i18n (1.14.8) sha256=285778639134865c5e0f6269e0b818256017e8cde89993fdfcbfb64d088824a5
@@ -349,6 +375,7 @@ CHECKSUMS
349375
jekyll-vite (3.0.4) sha256=bb08c6f95e814afeebd73b9299805b85c5daa1964ce85c9e7a0fa77790018785
350376
jekyll-watch (2.2.1) sha256=bc44ed43f5e0a552836245a54dbff3ea7421ecc2856707e8a1ee203a8387a7e1
351377
json (2.19.5) sha256=218a18553e4801d579ca7e0f5bc72bafd776d7397238a1fb4e74db5b0a812c59
378+
json_schemer (2.5.0) sha256=2f01fb4cce721a4e08dd068fc2030cffd0702a7f333f1ea2be6e8991f00ae396
352379
kramdown (2.5.2) sha256=1ba542204c66b6f9111ff00dcc26075b95b220b07f2905d8261740c82f7f02fa
353380
kramdown-parser-gfm (1.1.0) sha256=fb39745516427d2988543bf01fc4cf0ab1149476382393e0e9c48592f6581729
354381
latex-decode (0.4.2) sha256=e85633406e315e348e0ca6de231dee1bf45a22496b0866059c635f7502c2a592
@@ -390,6 +417,7 @@ CHECKSUMS
390417
rake (13.4.2) sha256=cb825b2bd5f1f8e91ca37bddb4b9aaf345551b4731da62949be002fa89283701
391418
rb-fsevent (0.11.2) sha256=43900b972e7301d6570f64b850a5aa67833ee7d87b458ee92805d56b7318aefe
392419
rb-inotify (0.11.1) sha256=a0a700441239b0ff18eb65e3866236cd78613d6b9f78fea1f9ac47a85e47be6e
420+
regexp_parser (2.12.0) sha256=35a916a1d63190ab5c9009457136ae5f3c0c7512d60291d0d1378ba18ce08ebb
393421
relaton-bib (2.1.3) sha256=bfc645c4cf97736f03d83c5217066842bba0b892a7921556fa87b75433d1389b
394422
relaton-calconnect (2.1.2) sha256=f9f2b960cbb5471df19dfde38f2ed7c2d8357fe641c9041524e3ab7d860e7e0b
395423
relaton-core (0.0.13) sha256=10eef0d4bdff18a9058114ca46323508972b8caed872212992c4f9ced7375881
@@ -398,6 +426,11 @@ CHECKSUMS
398426
rexml (3.4.4) sha256=19e0a2c3425dfbf2d4fc1189747bdb2f849b6c5e74180401b15734bc97b5d142
399427
rfcxml (0.4.4) sha256=c338de6822d167d3ed8c71663e33feecc36844875436257eb7174bf2e9d32cb8
400428
rouge (4.7.0) sha256=dba5896715c0325c362e895460a6d350803dbf6427454f49a47500f3193ea739
429+
rspec (3.13.2) sha256=206284a08ad798e61f86d7ca3e376718d52c0bc944626b2349266f239f820587
430+
rspec-core (3.13.6) sha256=a8823c6411667b60a8bca135364351dda34cd55e44ff94c4be4633b37d828b2d
431+
rspec-expectations (3.13.5) sha256=33a4d3a1d95060aea4c94e9f237030a8f9eae5615e9bd85718fe3a09e4b58836
432+
rspec-mocks (3.13.8) sha256=086ad3d3d17533f4237643de0b5c42f04b66348c28bf6b9c2d3f4a3b01af1d47
433+
rspec-support (3.13.7) sha256=0640e5570872aafefd79867901deeeeb40b0c9875a36b983d85f54fb7381c47c
401434
rubyntlm (0.6.5) sha256=47013402b99ae29ee93f930af51edaec8c6008556f4be25705a422b4430314f5
402435
rubyzip (2.3.2) sha256=3f57e3935dc2255c414484fbf8d673b4909d8a6a57007ed754dde39342d2373f
403436
safe_yaml (1.0.5) sha256=a6ac2d64b7eb027bdeeca1851fe7e7af0d668e133e8a88066a0c6f7087d9f848
@@ -410,6 +443,7 @@ CHECKSUMS
410443
sass-embedded (1.99.0-x86_64-linux-gnu) sha256=a4e2ae5e9951815cb8b3ab408cee8b800852491988a57de735f18d259c70d7c4
411444
sass-embedded (1.99.0-x86_64-linux-musl) sha256=94be72a6f856c610e67b12303dc76a58412e64b24ce97bdf4912199b8145c8dd
412445
sawyer (0.9.3) sha256=0d0f19298408047037638639fe62f4794483fb04320269169bd41af2bdcf5e41
446+
simpleidn (0.2.3) sha256=08ce96f03fa1605286be22651ba0fc9c0b2d6272c9b27a260bc88be05b0d2c29
413447
stringio (3.2.0) sha256=c37cb2e58b4ffbd33fe5cd948c05934af997b36e0b6ca6fdf43afa234cf222e1
414448
terminal-table (3.0.2) sha256=f951b6af5f3e00203fb290a669e0a85c5dd5b051b3b023392ccfd67ba5abae91
415449
thor (1.5.0) sha256=e3a9e55fe857e44859ce104a84675ab6e8cd59c650a49106a05f55f136425e73

Rakefile

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# frozen_string_literal: true
22

33
require "fileutils"
4+
require "rspec/core/rake_task"
45

56
desc "Aggregate releases and build document index"
67
task :fetch do
@@ -28,3 +29,38 @@ desc "Remove all build artifacts"
2829
task :clean do
2930
FileUtils.rm_rf("_site")
3031
end
32+
33+
desc "Validate aggregated document index against schema"
34+
task :validate_schema do
35+
require "json"
36+
require "json_schemer"
37+
38+
schema_path = "_data/schemas/documents.schema.json"
39+
data_path = "_data/documents.json"
40+
41+
unless File.exist?(data_path)
42+
abort "SKIP: #{data_path} not found — run `rake fetch` first"
43+
end
44+
45+
schema = JSON.parse(File.read(schema_path))
46+
data = JSON.parse(File.read(data_path))
47+
schemer = JsonSchemer.schema(schema)
48+
49+
errors = []
50+
data["items"].each_with_index do |doc, i|
51+
unless schemer.valid?(doc)
52+
schemer.validate(doc).each do |error|
53+
errors << "Document ##{i} (#{doc['id'] || 'unknown'}): #{error['error']}"
54+
end
55+
end
56+
end
57+
58+
if errors.empty?
59+
puts "OK: #{data['items'].length} documents pass schema validation"
60+
else
61+
errors.first(20).each { |e| puts " #{e}" }
62+
abort "FAIL: #{errors.length} schema violations found"
63+
end
64+
end
65+
66+
RSpec::Core::RakeTask.new(:spec)
File renamed without changes.

0 commit comments

Comments
 (0)