reffy 20.0.13 → 20.0.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -21
- package/README.md +151 -151
- package/index.js +29 -29
- package/package.json +3 -3
- package/reffy.js +324 -324
- package/schemas/browserlib/extract-algorithms.json +52 -52
- package/schemas/browserlib/extract-cssdfn.json +108 -108
- package/schemas/browserlib/extract-dfns.json +90 -90
- package/schemas/browserlib/extract-elements.json +17 -17
- package/schemas/browserlib/extract-events.json +31 -31
- package/schemas/browserlib/extract-headings.json +19 -19
- package/schemas/browserlib/extract-ids.json +7 -7
- package/schemas/browserlib/extract-links.json +12 -12
- package/schemas/browserlib/extract-refs.json +12 -12
- package/schemas/common.json +876 -876
- package/schemas/files/extracts/algorithms.json +12 -12
- package/schemas/files/extracts/css.json +16 -16
- package/schemas/files/extracts/dfns.json +12 -12
- package/schemas/files/extracts/elements.json +12 -12
- package/schemas/files/extracts/events.json +12 -12
- package/schemas/files/extracts/headings.json +12 -12
- package/schemas/files/extracts/ids.json +12 -12
- package/schemas/files/extracts/links.json +12 -12
- package/schemas/files/extracts/refs.json +12 -12
- package/schemas/files/index.json +59 -59
- package/schemas/postprocessing/events.json +50 -50
- package/schemas/postprocessing/idlnames-parsed.json +27 -27
- package/schemas/postprocessing/idlnames.json +17 -17
- package/schemas/postprocessing/idlparsed.json +67 -67
- package/src/browserlib/clone-and-clean.mjs +24 -24
- package/src/browserlib/create-outline.mjs +353 -353
- package/src/browserlib/extract-algorithms.mjs +723 -723
- package/src/browserlib/extract-cddl.mjs +125 -125
- package/src/browserlib/extract-dfns.mjs +1093 -1093
- package/src/browserlib/extract-headings.mjs +76 -76
- package/src/browserlib/extract-ids.mjs +28 -28
- package/src/browserlib/extract-links.mjs +45 -45
- package/src/browserlib/extract-references.mjs +308 -308
- package/src/browserlib/extract-webidl.mjs +89 -89
- package/src/browserlib/get-absolute-url.mjs +29 -29
- package/src/browserlib/get-code-elements.mjs +20 -20
- package/src/browserlib/get-generator.mjs +26 -26
- package/src/browserlib/get-lastmodified-date.mjs +13 -13
- package/src/browserlib/get-revision.mjs +12 -12
- package/src/browserlib/get-title.mjs +14 -14
- package/src/browserlib/informative-selector.mjs +24 -24
- package/src/browserlib/map-ids-to-headings.mjs +173 -173
- package/src/browserlib/reffy.json +85 -85
- package/src/browserlib/trim-spaces.mjs +35 -35
- package/src/cli/check-missing-dfns.js +587 -587
- package/src/cli/merge-crawl-results.js +132 -132
- package/src/cli/parse-webidl.js +447 -447
- package/src/lib/css-grammar-parse-tree.schema.json +109 -109
- package/src/lib/css-grammar-parser.js +440 -440
- package/src/lib/fetch.js +51 -51
- package/src/lib/markdown-report.js +360 -360
- package/src/lib/mock-server.js +218 -218
- package/src/lib/post-processor.js +322 -322
- package/src/lib/throttled-queue.js +129 -129
- package/src/postprocessing/annotate-links.js +41 -41
- package/src/postprocessing/csscomplete.js +48 -48
- package/src/postprocessing/idlnames.js +391 -391
- package/src/postprocessing/idlparsed.js +179 -179
- package/src/postprocessing/patch-dfns.js +51 -51
- package/src/specs/missing-css-rules.json +197 -197
- package/src/specs/spec-equivalents.json +149 -149
- package/src/browserlib/extract-editors.mjs~ +0 -14
- package/src/browserlib/extract-events.mjs~ +0 -3
- package/src/browserlib/generate-es-dfn-report.sh~ +0 -4
- package/src/browserlib/get-revision.mjs~ +0 -7
- package/src/cli/csstree-grammar-check.js +0 -28
- package/src/cli/csstree-grammar-check.js~ +0 -10
- package/src/cli/csstree-grammar-parser.js +0 -11
- package/src/cli/csstree-grammar-parser.js~ +0 -1
- package/src/cli/extract-editors.js~ +0 -38
- package/src/cli/process-specs.js~ +0 -28
- package/src/postprocessing/annotate-links.js~ +0 -8
- package/src/postprocessing/events.js~ +0 -245
|
@@ -1,76 +1,76 @@
|
|
|
1
|
-
import getAbsoluteUrl from './get-absolute-url.mjs';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Extract headings data from documents
|
|
5
|
-
*/
|
|
6
|
-
export default function (spec, idToHeading) {
|
|
7
|
-
// Compute once whether we created a single page version out of multiple pages
|
|
8
|
-
const singlePage = !document.querySelector('[data-reffy-page]');
|
|
9
|
-
|
|
10
|
-
// Headings using the markup convention of the EcmaScript spec
|
|
11
|
-
const esHeadings = [...document.querySelectorAll('emu-clause[id] > h1')].map(n => {
|
|
12
|
-
const headingNumber = n.querySelector(".secnum")?.textContent;
|
|
13
|
-
const headingLevel = headingNumber ? headingNumber.split(".").length : undefined;
|
|
14
|
-
return {
|
|
15
|
-
id: n.parentNode.id,
|
|
16
|
-
href: getAbsoluteUrl(n.parentNode, { singlePage }),
|
|
17
|
-
title: n.textContent.replace(headingNumber, '').trim(),
|
|
18
|
-
level: headingLevel,
|
|
19
|
-
number: headingNumber
|
|
20
|
-
};
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
// Headings using spans in www.rfc-editor.org RFCs
|
|
24
|
-
const rfcSelector = 'pre > span:is(.h2,.h3,.h4,.h5,.h6) > a.selflink[id]';
|
|
25
|
-
const rfcHeadings = [...document.querySelectorAll(rfcSelector)].map(n => {
|
|
26
|
-
const headingNumber = n.textContent;
|
|
27
|
-
const headingLevel = headingNumber ? headingNumber.split(".").length : undefined;
|
|
28
|
-
return {
|
|
29
|
-
id: n.id,
|
|
30
|
-
href: getAbsoluteUrl(n, { singlePage }),
|
|
31
|
-
title: n.parentNode.textContent
|
|
32
|
-
.replace(headingNumber, '')
|
|
33
|
-
.replace(/^\s*\./, '')
|
|
34
|
-
.trim(),
|
|
35
|
-
level: headingLevel,
|
|
36
|
-
number: headingNumber.replace(/\s*appendix\s+/i, '')
|
|
37
|
-
};
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
const headingsSelector = [
|
|
41
|
-
':is(h1,h2,h3,h4,h5,h6)[id]', // Regular headings
|
|
42
|
-
':is(h1,h2,h3,h4,h5,h6):not([id]) > a[name]' // CSS 2.1 headings
|
|
43
|
-
].join(',');
|
|
44
|
-
|
|
45
|
-
return esHeadings.concat(rfcHeadings).concat([...document.querySelectorAll(headingsSelector)].map(n => {
|
|
46
|
-
// Note: In theory, all <hX> heading elements that have an ID are associated
|
|
47
|
-
// with a heading in idToHeading. One exception to the rule: when the
|
|
48
|
-
// heading element appears in a <hgroup> element, the mapping is not
|
|
49
|
-
// properly done (the outline creation algorithm explicitly skips these
|
|
50
|
-
// headings not to create a mess in the outline). In practice, this only
|
|
51
|
-
// really happens so far for WHATWG spec titles that (correctly) group the
|
|
52
|
-
// title and subtitle headings in a <hgroup>.
|
|
53
|
-
const idAttr = n.id ? 'id' : 'name';
|
|
54
|
-
const headingEl = n.id ? n : n.parentNode;
|
|
55
|
-
const href = getAbsoluteUrl(n, { singlePage, attribute: idAttr });
|
|
56
|
-
const heading = idToHeading[href] || {
|
|
57
|
-
id: n.getAttribute(idAttr),
|
|
58
|
-
href,
|
|
59
|
-
title: n.textContent.trim()
|
|
60
|
-
};
|
|
61
|
-
const res = {
|
|
62
|
-
id: heading.id,
|
|
63
|
-
href: heading.href,
|
|
64
|
-
level: parseInt(headingEl.tagName.slice(1), 10),
|
|
65
|
-
title: heading.title
|
|
66
|
-
};
|
|
67
|
-
if (heading.alternateIds?.length) {
|
|
68
|
-
res.alternateIds = heading.alternateIds;
|
|
69
|
-
}
|
|
70
|
-
if (heading.number) {
|
|
71
|
-
res.number = heading.number;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
return res;
|
|
75
|
-
}));
|
|
76
|
-
}
|
|
1
|
+
import getAbsoluteUrl from './get-absolute-url.mjs';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Extract headings data from documents
|
|
5
|
+
*/
|
|
6
|
+
export default function (spec, idToHeading) {
|
|
7
|
+
// Compute once whether we created a single page version out of multiple pages
|
|
8
|
+
const singlePage = !document.querySelector('[data-reffy-page]');
|
|
9
|
+
|
|
10
|
+
// Headings using the markup convention of the EcmaScript spec
|
|
11
|
+
const esHeadings = [...document.querySelectorAll('emu-clause[id] > h1')].map(n => {
|
|
12
|
+
const headingNumber = n.querySelector(".secnum")?.textContent;
|
|
13
|
+
const headingLevel = headingNumber ? headingNumber.split(".").length : undefined;
|
|
14
|
+
return {
|
|
15
|
+
id: n.parentNode.id,
|
|
16
|
+
href: getAbsoluteUrl(n.parentNode, { singlePage }),
|
|
17
|
+
title: n.textContent.replace(headingNumber, '').trim(),
|
|
18
|
+
level: headingLevel,
|
|
19
|
+
number: headingNumber
|
|
20
|
+
};
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
// Headings using spans in www.rfc-editor.org RFCs
|
|
24
|
+
const rfcSelector = 'pre > span:is(.h2,.h3,.h4,.h5,.h6) > a.selflink[id]';
|
|
25
|
+
const rfcHeadings = [...document.querySelectorAll(rfcSelector)].map(n => {
|
|
26
|
+
const headingNumber = n.textContent;
|
|
27
|
+
const headingLevel = headingNumber ? headingNumber.split(".").length : undefined;
|
|
28
|
+
return {
|
|
29
|
+
id: n.id,
|
|
30
|
+
href: getAbsoluteUrl(n, { singlePage }),
|
|
31
|
+
title: n.parentNode.textContent
|
|
32
|
+
.replace(headingNumber, '')
|
|
33
|
+
.replace(/^\s*\./, '')
|
|
34
|
+
.trim(),
|
|
35
|
+
level: headingLevel,
|
|
36
|
+
number: headingNumber.replace(/\s*appendix\s+/i, '')
|
|
37
|
+
};
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
const headingsSelector = [
|
|
41
|
+
':is(h1,h2,h3,h4,h5,h6)[id]', // Regular headings
|
|
42
|
+
':is(h1,h2,h3,h4,h5,h6):not([id]) > a[name]' // CSS 2.1 headings
|
|
43
|
+
].join(',');
|
|
44
|
+
|
|
45
|
+
return esHeadings.concat(rfcHeadings).concat([...document.querySelectorAll(headingsSelector)].map(n => {
|
|
46
|
+
// Note: In theory, all <hX> heading elements that have an ID are associated
|
|
47
|
+
// with a heading in idToHeading. One exception to the rule: when the
|
|
48
|
+
// heading element appears in a <hgroup> element, the mapping is not
|
|
49
|
+
// properly done (the outline creation algorithm explicitly skips these
|
|
50
|
+
// headings not to create a mess in the outline). In practice, this only
|
|
51
|
+
// really happens so far for WHATWG spec titles that (correctly) group the
|
|
52
|
+
// title and subtitle headings in a <hgroup>.
|
|
53
|
+
const idAttr = n.id ? 'id' : 'name';
|
|
54
|
+
const headingEl = n.id ? n : n.parentNode;
|
|
55
|
+
const href = getAbsoluteUrl(n, { singlePage, attribute: idAttr });
|
|
56
|
+
const heading = idToHeading[href] || {
|
|
57
|
+
id: n.getAttribute(idAttr),
|
|
58
|
+
href,
|
|
59
|
+
title: n.textContent.trim()
|
|
60
|
+
};
|
|
61
|
+
const res = {
|
|
62
|
+
id: heading.id,
|
|
63
|
+
href: heading.href,
|
|
64
|
+
level: parseInt(headingEl.tagName.slice(1), 10),
|
|
65
|
+
title: heading.title
|
|
66
|
+
};
|
|
67
|
+
if (heading.alternateIds?.length) {
|
|
68
|
+
res.alternateIds = heading.alternateIds;
|
|
69
|
+
}
|
|
70
|
+
if (heading.number) {
|
|
71
|
+
res.number = heading.number;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
return res;
|
|
75
|
+
}));
|
|
76
|
+
}
|
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
import getAbsoluteUrl from './get-absolute-url.mjs';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Extract absolute ids from documents
|
|
5
|
-
*/
|
|
6
|
-
export default function () {
|
|
7
|
-
// Compute once whether we created a single page version out of multiple pages
|
|
8
|
-
const singlePage = !document.querySelector('[data-reffy-page]');
|
|
9
|
-
|
|
10
|
-
return [...document.querySelectorAll('*[id]')]
|
|
11
|
-
// Ignore respec- prefixed ids to avoid keeping track of their evolution
|
|
12
|
-
// They're clearly not meant to be link target in any case
|
|
13
|
-
.filter(n => !n.id.startsWith('respec-'))
|
|
14
|
-
|
|
15
|
-
// Ignore dfn-panel- prefixed ids that ReSpec generates to avoid keeping
|
|
16
|
-
// track of their evolution. They're clearly not meant to be link target
|
|
17
|
-
// either.
|
|
18
|
-
.filter(n => !n.id.startsWith('dfn-panel-'))
|
|
19
|
-
|
|
20
|
-
// Convert IDs to absolute URLs (needed to handle multipage specs)
|
|
21
|
-
.map(n => getAbsoluteUrl(n, { singlePage }))
|
|
22
|
-
|
|
23
|
-
// Capture anchors set in <a name> when they're not dup of ids
|
|
24
|
-
.concat([...document.querySelectorAll('a[name]')]
|
|
25
|
-
.filter(n => !n.id || n.id !== n.name)
|
|
26
|
-
.map(n => getAbsoluteUrl(n, { singlePage, attribute: 'name' }))
|
|
27
|
-
);
|
|
28
|
-
}
|
|
1
|
+
import getAbsoluteUrl from './get-absolute-url.mjs';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Extract absolute ids from documents
|
|
5
|
+
*/
|
|
6
|
+
export default function () {
|
|
7
|
+
// Compute once whether we created a single page version out of multiple pages
|
|
8
|
+
const singlePage = !document.querySelector('[data-reffy-page]');
|
|
9
|
+
|
|
10
|
+
return [...document.querySelectorAll('*[id]')]
|
|
11
|
+
// Ignore respec- prefixed ids to avoid keeping track of their evolution
|
|
12
|
+
// They're clearly not meant to be link target in any case
|
|
13
|
+
.filter(n => !n.id.startsWith('respec-'))
|
|
14
|
+
|
|
15
|
+
// Ignore dfn-panel- prefixed ids that ReSpec generates to avoid keeping
|
|
16
|
+
// track of their evolution. They're clearly not meant to be link target
|
|
17
|
+
// either.
|
|
18
|
+
.filter(n => !n.id.startsWith('dfn-panel-'))
|
|
19
|
+
|
|
20
|
+
// Convert IDs to absolute URLs (needed to handle multipage specs)
|
|
21
|
+
.map(n => getAbsoluteUrl(n, { singlePage }))
|
|
22
|
+
|
|
23
|
+
// Capture anchors set in <a name> when they're not dup of ids
|
|
24
|
+
.concat([...document.querySelectorAll('a[name]')]
|
|
25
|
+
.filter(n => !n.id || n.id !== n.name)
|
|
26
|
+
.map(n => getAbsoluteUrl(n, { singlePage, attribute: 'name' }))
|
|
27
|
+
);
|
|
28
|
+
}
|
|
@@ -1,45 +1,45 @@
|
|
|
1
|
-
function fromLinksToAnchors(links) {
|
|
2
|
-
return Object.keys(links)
|
|
3
|
-
.sort()
|
|
4
|
-
// turning sets into arrays
|
|
5
|
-
.reduce((acc, u) => {
|
|
6
|
-
acc[u] = {};
|
|
7
|
-
if (links[u].anchors.size > 0) {
|
|
8
|
-
acc[u].anchors = [...links[u].anchors];
|
|
9
|
-
}
|
|
10
|
-
return acc;
|
|
11
|
-
}, {});
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Extract absolute links of the document and their fragments
|
|
16
|
-
* in two set: autolinks (generated by spec authoring tools from webref)
|
|
17
|
-
* and rawlinks (the rest)
|
|
18
|
-
*/
|
|
19
|
-
export default function () {
|
|
20
|
-
const rawlinks = {};
|
|
21
|
-
const autolinks = {};
|
|
22
|
-
document.querySelectorAll('a[href^=http]').forEach(n => {
|
|
23
|
-
// Ignore links from the "head" section, which either link to
|
|
24
|
-
// self, the GitHub repo, the implementation report, and other
|
|
25
|
-
// documents that don't need to appear in the list of references.
|
|
26
|
-
// Also ignore links in <del> elements that appear when specs
|
|
27
|
-
// carry their diff (e.g. W3C Recs with candidate corrections).
|
|
28
|
-
// And then ignore links in aside dfn panels. They only contain internal
|
|
29
|
-
// links or links that already appear elsewhere in the spec.
|
|
30
|
-
if (n.closest('.head, del, .dfn-panel')) return;
|
|
31
|
-
const pageUrl = n.href.split('#')[0];
|
|
32
|
-
// links generated by authoring tools have data-link-type or data-xref-type set
|
|
33
|
-
let linkSet = n.dataset.linkType || n.dataset.xrefType ? autolinks : rawlinks;
|
|
34
|
-
if (!linkSet[pageUrl]) {
|
|
35
|
-
linkSet[pageUrl] = {anchors: new Set()};
|
|
36
|
-
}
|
|
37
|
-
if (n.href.includes('#') && n.href.split('#')[1]) {
|
|
38
|
-
linkSet[pageUrl].anchors.add(n.href.split('#')[1]);
|
|
39
|
-
}
|
|
40
|
-
});
|
|
41
|
-
return {
|
|
42
|
-
rawlinks: fromLinksToAnchors(rawlinks),
|
|
43
|
-
autolinks: fromLinksToAnchors(autolinks)
|
|
44
|
-
};
|
|
45
|
-
}
|
|
1
|
+
function fromLinksToAnchors(links) {
|
|
2
|
+
return Object.keys(links)
|
|
3
|
+
.sort()
|
|
4
|
+
// turning sets into arrays
|
|
5
|
+
.reduce((acc, u) => {
|
|
6
|
+
acc[u] = {};
|
|
7
|
+
if (links[u].anchors.size > 0) {
|
|
8
|
+
acc[u].anchors = [...links[u].anchors];
|
|
9
|
+
}
|
|
10
|
+
return acc;
|
|
11
|
+
}, {});
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Extract absolute links of the document and their fragments
|
|
16
|
+
* in two set: autolinks (generated by spec authoring tools from webref)
|
|
17
|
+
* and rawlinks (the rest)
|
|
18
|
+
*/
|
|
19
|
+
export default function () {
|
|
20
|
+
const rawlinks = {};
|
|
21
|
+
const autolinks = {};
|
|
22
|
+
document.querySelectorAll('a[href^=http]').forEach(n => {
|
|
23
|
+
// Ignore links from the "head" section, which either link to
|
|
24
|
+
// self, the GitHub repo, the implementation report, and other
|
|
25
|
+
// documents that don't need to appear in the list of references.
|
|
26
|
+
// Also ignore links in <del> elements that appear when specs
|
|
27
|
+
// carry their diff (e.g. W3C Recs with candidate corrections).
|
|
28
|
+
// And then ignore links in aside dfn panels. They only contain internal
|
|
29
|
+
// links or links that already appear elsewhere in the spec.
|
|
30
|
+
if (n.closest('.head, del, .dfn-panel')) return;
|
|
31
|
+
const pageUrl = n.href.split('#')[0];
|
|
32
|
+
// links generated by authoring tools have data-link-type or data-xref-type set
|
|
33
|
+
let linkSet = n.dataset.linkType || n.dataset.xrefType ? autolinks : rawlinks;
|
|
34
|
+
if (!linkSet[pageUrl]) {
|
|
35
|
+
linkSet[pageUrl] = {anchors: new Set()};
|
|
36
|
+
}
|
|
37
|
+
if (n.href.includes('#') && n.href.split('#')[1]) {
|
|
38
|
+
linkSet[pageUrl].anchors.add(n.href.split('#')[1]);
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
return {
|
|
42
|
+
rawlinks: fromLinksToAnchors(rawlinks),
|
|
43
|
+
autolinks: fromLinksToAnchors(autolinks)
|
|
44
|
+
};
|
|
45
|
+
}
|