-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathconfig.rb
More file actions
103 lines (77 loc) · 2.89 KB
/
config.rb
File metadata and controls
103 lines (77 loc) · 2.89 KB
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
require_relative "lib/teacher_services_tech_docs"
GovukTechDocs.configure(self)
service_list = YAML.load_file("config/services.yml")
services = service_list.reduce([]) do |list, service|
repo = SchoolsDigitalTechDocs::GitHub::RubyRepo.new(
repo_name: service["repo_name"],
service_name: service["name"],
)
list + service.fetch("docsets", []).map do |docset|
repo.load_docs(
path_in_repo: docset["path"],
ignore_files: docset.fetch("ignore_files", []),
)
end
end
ignore "templates/*"
RUBY_SERVICE_REPOS = service_list.select { |s| s["language"] == "ruby" }.map do |service|
repo = SchoolsDigitalTechDocs::GitHub::RubyRepo.new(
repo_name: service["repo_name"],
service_name: service["name"],
)
raise "No profile created for #{service}" unless repo.profile
repo
end
CS_SERVICE_REPOS = service_list.select { |s| s["language"] == "cs" }.map do |service|
repo = SchoolsDigitalTechDocs::GitHub::CsRepo.new(
repo_name: service["repo_name"],
csproj_path: service["csproj_path"],
service_name: service["name"],
)
raise "No profile created for #{service} " unless repo.profile
repo
end
OTHER_SERVICE_REPOS = service_list.select { |s| s["language"] == "other" }.map do |service|
repo = SchoolsDigitalTechDocs::GitHub::OtherRepo.new(
repo_name: service["repo_name"],
service_name: service["name"],
)
raise "No profile created for #{service} " unless repo.profile
repo
end
CS_SERVICE_PROFILES = CS_SERVICE_REPOS.sort_by(&:service_name).map(&:profile)
RUBY_SERVICE_PROFILES = RUBY_SERVICE_REPOS.sort_by(&:service_name).map(&:profile)
OTHER_SERVICE_PROFILES = OTHER_SERVICE_REPOS.sort_by(&:service_name).map(&:profile)
ALL_SERVICE_NAMES = service_list.map do |service|
service["name"]
end
MAPPED_SERVICE_NAMES = (CS_SERVICE_REPOS + RUBY_SERVICE_REPOS).map(&:service_name)
OTHER_SERVICE_NAMES = service_list.select { |r| r["language"] == "other" }.map do |service|
service["name"]
end
missing_service_names = Set.new(ALL_SERVICE_NAMES) - Set.new(MAPPED_SERVICE_NAMES + OTHER_SERVICE_NAMES)
unless missing_service_names.empty?
raise("Missing service profiles: total #{services.length}; Ruby #{RUBY_SERVICE_PROFILES.length}; C# #{CS_SERVICE_PROFILES.length}; Other #{OTHER_SERVICE_NAMES.length}")
end
helpers do
def pages_by_category
SchoolsDigitalTechDocs::PagesByCategory.new(sitemap)
end
def ruby_service_profiles
RUBY_SERVICE_PROFILES.reject(&:archived).compact
end
def cs_service_profiles
CS_SERVICE_PROFILES.reject(&:archived).compact
end
def other_service_profiles
OTHER_SERVICE_PROFILES.reject(&:archived).compact
end
def archived_service_profiles
(OTHER_SERVICE_PROFILES + RUBY_SERVICE_PROFILES + CS_SERVICE_PROFILES).select(&:archived).compact
end
end
services.each do |docset|
docset.each do |page|
proxy page.fetch(:path), "templates/external_doc_template.html", page.fetch(:proxy_args)
end
end