Skip to content

Commit b98d106

Browse files
authored
Bugfix: adapt populateCerts.js to new yaml format (#236)
Signed-off-by: Matthias Büchse <[email protected]>
1 parent 80283e2 commit b98d106

File tree

1 file changed

+29
-46
lines changed

1 file changed

+29
-46
lines changed

populateCerts.js

Lines changed: 29 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -22,57 +22,40 @@ const sidebarItems = scopes.map((scope) => {
2222
const matrix = {}
2323
const versionsShown = {}
2424
var numOld = 0
25+
var modules = {}
26+
scope.modules.forEach((module) => {
27+
modules[module.id] = module
28+
module.prettyName = module.id.startsWith('scs-') ? `${module.id}: ${module.name}` : module.name
29+
})
30+
scope.timeline.sort((a, b) => b.date.localeCompare(a.date))
31+
const current = scope.timeline.filter((entry) => entry.date <= today)
32+
const lookup = current.length ? current[0].versions : {}
2533
// sort in descending order, so we get the MAX_OLD most recent obsolete versions
2634
scope.versions.sort((a, b) => b.version.localeCompare(a.version));
2735
scope.versions.forEach((version) => {
36+
version.state = lookup[version.version] || 'deprecated'
2837
version.isStable = version.stabilized_at !== undefined && version.stabilized_at <= today
29-
version.isObsolete = version.deprecated_at !== undefined && version.deprecated_at < today
30-
version.isEffective = version.isStable && !version.isObsolete
31-
version.isPreview = version.stabilized_at === undefined || today < version.stabilized_at
32-
if (!version.isEffective && !version.isPreview) {
38+
version.isEffective = version.state == 'effective'
39+
if (['warn', 'effective', 'draft'].indexOf(version.state) == -1) {
3340
numOld += 1
3441
if (numOld > MAX_OLD) return
3542
}
36-
version.state = (
37-
version.stabilized_at === undefined ? 'Draft' :
38-
version.isEffective ? 'Effective' :
39-
version.isObsolete ? 'Deprecated' :
40-
'Stable'
41-
)
42-
if (version.standards === undefined) return
43+
if (version.include === undefined) return
4344
versionsShown[version.version] = version
44-
version.standards.forEach((standard) => {
45-
const components = standard.url.split('/')
46-
const filename = components[components.length - 1]
47-
// first, sensible (but not pretty) defaults
48-
var key = standard.url
49-
var name = standard.name
50-
var ver = '✓'
51-
var url = standard.url
52-
if (filename.startsWith('scs-') && filename.endsWith('.md')) {
53-
// special case for internal standards
54-
const components2 = filename.split('-')
55-
key = `scs-${components2[1]}`
56-
name = `${key}: ${name}`
57-
ver = components2[2]
58-
url = `/standards/${filename.substring(0, filename.length - 3)}`
59-
} else {
60-
// special case mainly for OpenStack Powered Compute, but anything ending in 'vXYZ'
61-
const components2 = name.split(' ')
62-
const v = components2.splice(components2.length - 1)
63-
if (v[0].startsWith('v')) {
64-
key = components2.join(' ')
65-
name = key
66-
ver = v[0]
67-
}
45+
version.include.forEach((include) => {
46+
if (include.ref === undefined) {
47+
include = {ref: include, parameters: {}}
6848
}
69-
if (matrix[key] === undefined) {
70-
matrix[key] = {name, columns: {}}
49+
const module = modules[include.ref]
50+
if (matrix[module.id] === undefined) {
51+
matrix[module.id] = {
52+
name: module.prettyName,
53+
columns: {},
54+
url: module.url,
55+
}
7156
}
72-
matrix[key].columns[version.version] = {
73-
version: ver,
74-
url,
75-
parameters: standard.parameters,
57+
matrix[module.id].columns[version.version] = {
58+
parameters: include.parameters,
7659
}
7760
})
7861
})
@@ -90,14 +73,14 @@ Note that the state _Stable_ is shown here if _stabilized at_ is in the future,
9073
lines.push('| :-- | ' + columns.map(() => ':--').join(' | ') + ' |')
9174
lines.push('| State | ' + columns.map((c) => versionsShown[c].state).join(' | ') + ' |')
9275
lines.push('| Stabilized at | ' + columns.map((c) => versionsShown[c].stabilized_at || '').join(' | ') + ' |')
93-
lines.push('| Deprecated at | ' + columns.map((c) => versionsShown[c].deprecated_at || '').join(' | ') + ' |')
76+
// lines.push('| Deprecated at | ' + columns.map((c) => versionsShown[c].deprecated_at || '').join(' | ') + ' |')
9477
// md doesn't allow intermediate header rows
9578
// lines.push('| :-- | ' + columns.map(() => ':--').join(' | ') + ' |')
96-
lines.push('| **Standards** | ' + columns.map((c) => ' '.repeat(c.length)).join(' | ') + ' |')
79+
lines.push('| **Modules** | ' + columns.map((c) => ' '.repeat(c.length)).join(' | ') + ' |')
9780
// md doesn't allow intermediate header rows
9881
// lines.push('| :-- | ' + columns.map(() => ':--').join(' | ') + ' |')
9982
rows.forEach((row) => {
100-
lines.push(`| ${row.name} | ` + columns.map((c) => row.columns[c]).map((col) => {
83+
lines.push(`| [${row.name}](${row.url}) | ` + columns.map((c) => row.columns[c]).map((col) => {
10184
if (col === undefined) {
10285
// this version of the cert does not include this standard
10386
return ''
@@ -106,9 +89,9 @@ Note that the state _Stable_ is shown here if _stabilized at_ is in the future,
10689
entry[1].startsWith('https://') ? `[${entry[0]}](${entry[1]})` : `${entry[0]}=${entry[1]}`
10790
).join(', ')
10891
if (params.length) {
109-
params = `(${params})`
92+
params = ` (${params})`
11093
}
111-
return `[${col.version}](${col.url}) ${params}`
94+
return `X${params}`
11295
}).join(' | ') + ' |')
11396
})
11497
lines.push('') // file should end with a single newline character

0 commit comments

Comments
 (0)