-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRakefile
112 lines (97 loc) · 3.32 KB
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
require 'json'
require 'net/http'
require 'date'
require 'csv'
namespace :generate do
task :markdown do
json = JSON.parse(Net::HTTP.get(URI.parse("https://w3c.github.io/sustyweb/guidelines.json")))
File.open("out.md", "w") do |file|
file.puts <<~EOD
---
title: Sustainability Self-Assessment #{Date.today}
layout: page
---
Assessed against the #{json["title"]} version #{json["version"]} (#{json["edition"]}) on #{Date.today}.
## Contents
{: .no_toc }
<details markdown="block">
<summary>
Expand
</summary>
- TOC
{:toc}
</details>
## Methodology
## Conclusions
EOD
json["category"].each do |category|
next unless ["2", "3", "4"].include?(category["id"])
if category["guidelines"]
file.puts <<~EOD
## Section #{category["id"]}. #{category["name"]}
EOD
category["guidelines"].each do |guideline|
file.puts <<~EOD
### Guideline #{category["id"]}.#{guideline["id"]}. [#{guideline["guideline"]}](#{guideline["url"]})
#{guideline["description"]}
<details markdown="block">
<summary>
Criteria: #{guideline["criteria"].map{ |g| "⚪<!--🔴🟡🟢🟣-->" }.join(" ") }
</summary>
EOD
guideline["criteria"].each do |criterion|
file.puts <<~EOD
#### #{criterion["title"]}
#{criterion["description"]}
{:.todo}
Write assessment detail here.
Change paragraph class to "bad", "ok", "good", or "na" to set the
evaluation overall result, and set the relevant icon colour after
the guideline summary.
EOD
end
file.puts <<~EOD
</details>
EOD
end
end
end
end
end
task :csv do
json = JSON.parse(Net::HTTP.get(URI.parse("https://w3c.github.io/sustyweb/guidelines.json")))
CSV.open("out.csv", "wb") do |csv|
# Headers
csv << [ "# Sustainability Self-Assessment #{Date.today}" ]
csv << [ "# Assessed against the #{json["title"]} version #{json["version"]} (#{json["edition"]}) on #{Date.today}." ]
csv << ["Section", "Title", "Description", "RAG Status", "Comment"]
json["category"].each do |category|
next unless ["2", "3", "4", "5"].include?(category["id"])
if category["guidelines"]
csv << [
category["id"],
category["name"],
nil, "-", "-"
]
category["guidelines"].each do |guideline|
csv << [
"#{category["id"]}.#{guideline["id"]}",
guideline["guideline"],
guideline["description"],
"-", "-"
]
guideline["criteria"].each_with_index do |criterion, index|
csv << [
"#{category["id"]}.#{guideline["id"]}#{("a".."z").to_a[index]}",
criterion["title"],
criterion["description"],
"TODO: choose Red/Amber/Green/NA",
"TODO: Write assessment detail here"
]
end
end
end
end
end
end
end