Skip to content

Commit 0c98d20

Browse files
authored
Merge branch 'develop' into pr-timvdlippe-root-resource-exception
2 parents f8f995d + b6f040a commit 0c98d20

File tree

4 files changed

+50
-118
lines changed

4 files changed

+50
-118
lines changed

index.html

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,8 @@
99
</title>
1010
<link href="https://gitdocumentatie.logius.nl/publicatie/respec/style/nlgov/adr-style.css" rel="stylesheet" type="text/css"/>
1111
<link href="https://gitdocumentatie.logius.nl/publicatie/respec/style/nlgov/adr-dark.css" rel="stylesheet" type="text/css" media="(prefers-color-scheme: dark)">
12-
<script class="remove" src="https://logius-standaarden.github.io/publicatie/respec/organisation-config.js">
13-
</script>
14-
<script class="remove" src="js/config.js">
15-
</script>
16-
<script class="remove">
17-
respecConfig = {...organisationConfig, ...globalThis.respecConfig};
18-
</script>
1912
<link href="https://gitdocumentatie.logius.nl/publicatie/respec/style/logos/logius.ico" rel="shortcut icon" type="image/x-icon"/>
20-
<script async="" class="remove" src="https://gitdocumentatie.logius.nl/publicatie/respec/builds/respec-nlgov.js">
21-
</script>
22-
<script class="remove" src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.4/jquery.min.js">
23-
</script>
24-
<script class="remove" defer="" src="js/rules.js">
25-
</script>
13+
<script class="remove" type="module" src="js/config.mjs"></script>
2614
</head>
2715
<body>
2816
<section data-include="sections/abstract.md" data-include-format="markdown" id="abstract">

js/config.js renamed to js/config.mjs

Lines changed: 6 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
import {processRuleBlocks} from "https://logius-standaarden.github.io/publicatie/respec/plugins/adr.mjs";
2+
import { loadRespecWithConfiguration } from "https://logius-standaarden.github.io/publicatie/respec/organisation-config.mjs";
3+
14
async function initializeHighlightJSYaml() {
25
//this is the function you call in 'preProcess', to load the highlighter
36
const worker = await new Promise(resolve => {
@@ -48,62 +51,7 @@ async function highlightSpectralCode(config, document) {
4851
});
4952
}
5053

51-
function processRuleBlocks(config, document) {
52-
const functionalRules = [];
53-
const technicalRules = [];
54-
for (const rule of document.querySelectorAll('.rule')) {
55-
if (!rule.id) {
56-
throw new Error(`Missing id for rule: ${rule.outerHTML}`);
57-
}
58-
const ruleId = rule.id;
59-
60-
const ruleLabElement = rule.querySelector('.rulelab');
61-
ruleLabElement.innerText = `: ${ruleLabElement.innerText}`;
62-
const ruleLinkElement = document.createElement('a');
63-
ruleLinkElement.href = `#${ruleId}`;
64-
ruleLinkElement.innerText = ruleId;
65-
ruleLabElement.prepend(ruleLinkElement);
66-
67-
let flagTitle;
68-
const flagType = rule.dataset.type;
69-
if (flagType === 'technical') {
70-
flagTitle = 'This is a technical design rule and hence should be tested automatically.';
71-
technicalRules.push(ruleLabElement);
72-
73-
if (spectralConfiguration.includes(`#${ruleId}`)) {
74-
const lastDataListItem = rule.querySelector('dt:last-of-type');
75-
if (lastDataListItem.textContent !== 'How to test') {
76-
throw new Error(`Last element should be the "How to test" section. Found ${lastDataListItem.outerHTML}`);
77-
}
78-
const howToTest = rule.querySelector('dd:last-of-type');
79-
howToTest.innerHTML += `This rule can be automatically checked and an example test is shown in the <a href="#:~:text=${encodeURIComponent(`#${ruleId}`).replaceAll('-', '%2D')}">linter configuration</a>.`;
80-
}
81-
} else if (flagType === 'functional') {
82-
flagTitle = 'This is a functional design rule and hence cannot be tested automatically.';
83-
functionalRules.push(ruleLabElement);
84-
} else {
85-
throw new Error(`Missing type for rule: ${rule.outerHTML}`);
86-
}
87-
88-
const flagElement = document.createElement('div');
89-
flagElement.title = flagTitle;
90-
flagElement.innerText = flagType;
91-
flagElement.classList.add('flag');
92-
rule.prepend(flagElement);
93-
}
94-
95-
for (const [list, elementId] of [[functionalRules, '#functionalList'], [technicalRules, '#technicalList']]) {
96-
const listElement = document.querySelector(elementId);
97-
98-
for (const ruleLabElement of list) {
99-
const listItem = document.createElement('li');
100-
listItem.innerHTML = ruleLabElement.innerHTML;
101-
listElement.append(listItem);
102-
}
103-
}
104-
}
105-
106-
globalThis.respecConfig = {
54+
loadRespecWithConfiguration({
10755
alternateFormats: [ {
10856
"label" : "pdf",
10957
"uri" : "API-Design-Rules.pdf"
@@ -159,5 +107,5 @@ globalThis.respecConfig = {
159107
pluralize: true,
160108

161109
preProcess: [initializeHighlightJSYaml, fetchSpectralConfiguration],
162-
postProcess: [highlightSpectralCode, processRuleBlocks],
163-
};
110+
postProcess: [highlightSpectralCode, (config, document, utils) => processRuleBlocks(config, document, utils, spectralConfiguration)],
111+
});

0 commit comments

Comments
 (0)