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.
Files changed (78) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +151 -151
  3. package/index.js +29 -29
  4. package/package.json +3 -3
  5. package/reffy.js +324 -324
  6. package/schemas/browserlib/extract-algorithms.json +52 -52
  7. package/schemas/browserlib/extract-cssdfn.json +108 -108
  8. package/schemas/browserlib/extract-dfns.json +90 -90
  9. package/schemas/browserlib/extract-elements.json +17 -17
  10. package/schemas/browserlib/extract-events.json +31 -31
  11. package/schemas/browserlib/extract-headings.json +19 -19
  12. package/schemas/browserlib/extract-ids.json +7 -7
  13. package/schemas/browserlib/extract-links.json +12 -12
  14. package/schemas/browserlib/extract-refs.json +12 -12
  15. package/schemas/common.json +876 -876
  16. package/schemas/files/extracts/algorithms.json +12 -12
  17. package/schemas/files/extracts/css.json +16 -16
  18. package/schemas/files/extracts/dfns.json +12 -12
  19. package/schemas/files/extracts/elements.json +12 -12
  20. package/schemas/files/extracts/events.json +12 -12
  21. package/schemas/files/extracts/headings.json +12 -12
  22. package/schemas/files/extracts/ids.json +12 -12
  23. package/schemas/files/extracts/links.json +12 -12
  24. package/schemas/files/extracts/refs.json +12 -12
  25. package/schemas/files/index.json +59 -59
  26. package/schemas/postprocessing/events.json +50 -50
  27. package/schemas/postprocessing/idlnames-parsed.json +27 -27
  28. package/schemas/postprocessing/idlnames.json +17 -17
  29. package/schemas/postprocessing/idlparsed.json +67 -67
  30. package/src/browserlib/clone-and-clean.mjs +24 -24
  31. package/src/browserlib/create-outline.mjs +353 -353
  32. package/src/browserlib/extract-algorithms.mjs +723 -723
  33. package/src/browserlib/extract-cddl.mjs +125 -125
  34. package/src/browserlib/extract-dfns.mjs +1093 -1093
  35. package/src/browserlib/extract-headings.mjs +76 -76
  36. package/src/browserlib/extract-ids.mjs +28 -28
  37. package/src/browserlib/extract-links.mjs +45 -45
  38. package/src/browserlib/extract-references.mjs +308 -308
  39. package/src/browserlib/extract-webidl.mjs +89 -89
  40. package/src/browserlib/get-absolute-url.mjs +29 -29
  41. package/src/browserlib/get-code-elements.mjs +20 -20
  42. package/src/browserlib/get-generator.mjs +26 -26
  43. package/src/browserlib/get-lastmodified-date.mjs +13 -13
  44. package/src/browserlib/get-revision.mjs +12 -12
  45. package/src/browserlib/get-title.mjs +14 -14
  46. package/src/browserlib/informative-selector.mjs +24 -24
  47. package/src/browserlib/map-ids-to-headings.mjs +173 -173
  48. package/src/browserlib/reffy.json +85 -85
  49. package/src/browserlib/trim-spaces.mjs +35 -35
  50. package/src/cli/check-missing-dfns.js +587 -587
  51. package/src/cli/merge-crawl-results.js +132 -132
  52. package/src/cli/parse-webidl.js +447 -447
  53. package/src/lib/css-grammar-parse-tree.schema.json +109 -109
  54. package/src/lib/css-grammar-parser.js +440 -440
  55. package/src/lib/fetch.js +51 -51
  56. package/src/lib/markdown-report.js +360 -360
  57. package/src/lib/mock-server.js +218 -218
  58. package/src/lib/post-processor.js +322 -322
  59. package/src/lib/throttled-queue.js +129 -129
  60. package/src/postprocessing/annotate-links.js +41 -41
  61. package/src/postprocessing/csscomplete.js +48 -48
  62. package/src/postprocessing/idlnames.js +391 -391
  63. package/src/postprocessing/idlparsed.js +179 -179
  64. package/src/postprocessing/patch-dfns.js +51 -51
  65. package/src/specs/missing-css-rules.json +197 -197
  66. package/src/specs/spec-equivalents.json +149 -149
  67. package/src/browserlib/extract-editors.mjs~ +0 -14
  68. package/src/browserlib/extract-events.mjs~ +0 -3
  69. package/src/browserlib/generate-es-dfn-report.sh~ +0 -4
  70. package/src/browserlib/get-revision.mjs~ +0 -7
  71. package/src/cli/csstree-grammar-check.js +0 -28
  72. package/src/cli/csstree-grammar-check.js~ +0 -10
  73. package/src/cli/csstree-grammar-parser.js +0 -11
  74. package/src/cli/csstree-grammar-parser.js~ +0 -1
  75. package/src/cli/extract-editors.js~ +0 -38
  76. package/src/cli/process-specs.js~ +0 -28
  77. package/src/postprocessing/annotate-links.js~ +0 -8
  78. 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
+ }