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,90 +1,90 @@
1
- import getGenerator from './get-generator.mjs';
2
- import getCodeElements from './get-code-elements.mjs';
3
- import trimSpaces from './trim-spaces.mjs';
4
-
5
- /**
6
- * Extract the list of WebIDL definitions in the current spec
7
- *
8
- * @function
9
- * @public
10
- * @return {String} A dump of the IDL definitions, or an empty string if the
11
- * spec does not contain any IDL.
12
- */
13
- export default function () {
14
- const generator = getGenerator();
15
- let idl = '';
16
- if (generator === 'bikeshed') {
17
- idl = extractBikeshedIdl();
18
- }
19
- else if (document.title.startsWith('Web IDL')) {
20
- // IDL content in the Web IDL spec are... examples,
21
- // not real definitions
22
- }
23
- else {
24
- // Most non-ReSpec specs still follow the ReSpec conventions
25
- // for IDL definitions
26
- idl = extractRespecIdl();
27
- }
28
-
29
- if (idl) {
30
- // Remove trailing spaces and use spaces throughout
31
- idl = idl
32
- .replace(/\s+$/gm, '\n')
33
- .replace(/\t/g, ' ')
34
- .trim();
35
- }
36
- return idl;
37
- }
38
-
39
-
40
- /**
41
- * Extract IDL definitions from a Bikeshed spec
42
- *
43
- * Note Bikeshed summarizes IDL definitions in an appendix. This is
44
- * what the code uses.
45
- */
46
- function extractBikeshedIdl() {
47
- const idlHeading = document.getElementById('idl-index');
48
- if (idlHeading) {
49
- const nextEl = idlHeading.nextElementSibling;
50
- if (nextEl) {
51
- return nextEl.textContent;
52
- }
53
- else {
54
- throw new Error('Could not find IDL in IDL index');
55
- }
56
- }
57
- else {
58
- // the document may have been generated with "omit idl-index"
59
- // in which case, we try the simple way
60
- return extractRespecIdl();
61
- }
62
- }
63
-
64
-
65
- /**
66
- * Extract IDL definitions from a ReSpec spec, and in practice from
67
- * most other specs as well.
68
- *
69
- * The function tries all known patterns used to define IDL content, making
70
- * sure that it only extracts elements once.
71
- */
72
- function extractRespecIdl() {
73
- const idlSelectors = [
74
- 'pre.idl:not(.exclude):not(.extract):not(#actual-idl-index)',
75
- 'pre:not(.exclude):not(.extract) > code.idl-code:not(.exclude):not(.extract)',
76
- 'pre:not(.exclude):not(.extract) > code.idl:not(.exclude):not(.extract)',
77
- 'div.idl-code:not(.exclude):not(.extract) > pre:not(.exclude):not(.extract)',
78
- 'pre.widl:not(.exclude):not(.extract)'
79
- ];
80
-
81
- const excludeSelectors = [
82
- '#idl-index',
83
- '.chapter-idl'
84
- ];
85
-
86
- const idlElements = getCodeElements(idlSelectors, { excludeSelectors });
87
- return idlElements
88
- .map(el => trimSpaces(el.textContent))
89
- .join('\n\n');
1
+ import getGenerator from './get-generator.mjs';
2
+ import getCodeElements from './get-code-elements.mjs';
3
+ import trimSpaces from './trim-spaces.mjs';
4
+
5
+ /**
6
+ * Extract the list of WebIDL definitions in the current spec
7
+ *
8
+ * @function
9
+ * @public
10
+ * @return {String} A dump of the IDL definitions, or an empty string if the
11
+ * spec does not contain any IDL.
12
+ */
13
+ export default function () {
14
+ const generator = getGenerator();
15
+ let idl = '';
16
+ if (generator === 'bikeshed') {
17
+ idl = extractBikeshedIdl();
18
+ }
19
+ else if (document.title.startsWith('Web IDL')) {
20
+ // IDL content in the Web IDL spec are... examples,
21
+ // not real definitions
22
+ }
23
+ else {
24
+ // Most non-ReSpec specs still follow the ReSpec conventions
25
+ // for IDL definitions
26
+ idl = extractRespecIdl();
27
+ }
28
+
29
+ if (idl) {
30
+ // Remove trailing spaces and use spaces throughout
31
+ idl = idl
32
+ .replace(/\s+$/gm, '\n')
33
+ .replace(/\t/g, ' ')
34
+ .trim();
35
+ }
36
+ return idl;
37
+ }
38
+
39
+
40
+ /**
41
+ * Extract IDL definitions from a Bikeshed spec
42
+ *
43
+ * Note Bikeshed summarizes IDL definitions in an appendix. This is
44
+ * what the code uses.
45
+ */
46
+ function extractBikeshedIdl() {
47
+ const idlHeading = document.getElementById('idl-index');
48
+ if (idlHeading) {
49
+ const nextEl = idlHeading.nextElementSibling;
50
+ if (nextEl) {
51
+ return nextEl.textContent;
52
+ }
53
+ else {
54
+ throw new Error('Could not find IDL in IDL index');
55
+ }
56
+ }
57
+ else {
58
+ // the document may have been generated with "omit idl-index"
59
+ // in which case, we try the simple way
60
+ return extractRespecIdl();
61
+ }
62
+ }
63
+
64
+
65
+ /**
66
+ * Extract IDL definitions from a ReSpec spec, and in practice from
67
+ * most other specs as well.
68
+ *
69
+ * The function tries all known patterns used to define IDL content, making
70
+ * sure that it only extracts elements once.
71
+ */
72
+ function extractRespecIdl() {
73
+ const idlSelectors = [
74
+ 'pre.idl:not(.exclude):not(.extract):not(#actual-idl-index)',
75
+ 'pre:not(.exclude):not(.extract) > code.idl-code:not(.exclude):not(.extract)',
76
+ 'pre:not(.exclude):not(.extract) > code.idl:not(.exclude):not(.extract)',
77
+ 'div.idl-code:not(.exclude):not(.extract) > pre:not(.exclude):not(.extract)',
78
+ 'pre.widl:not(.exclude):not(.extract)'
79
+ ];
80
+
81
+ const excludeSelectors = [
82
+ '#idl-index',
83
+ '.chapter-idl'
84
+ ];
85
+
86
+ const idlElements = getCodeElements(idlSelectors, { excludeSelectors });
87
+ return idlElements
88
+ .map(el => trimSpaces(el.textContent))
89
+ .join('\n\n');
90
90
  }
@@ -1,29 +1,29 @@
1
- /**
2
- * Gets the absolute URL with fragment to the given node
3
- *
4
- * @function
5
- * @public
6
- * @param {Element} node DOM node to look at. Must have an ID.
7
- * @param {Object} options "singlePage" asserts whether the spec is single page
8
- * or whether that's unknown. Default is false for "unknown".
9
- * "attribute" tells function to use value of given attribute name instead of
10
- * the node's ID. Default is "id".
11
- * @return {String} Absolute URL ending with fragment ref
12
- */
13
- export default function (node, { singlePage, attribute } =
14
- { singlePage: false, attribute: 'id' }) {
15
- attribute = attribute ?? 'id';
16
- const page = singlePage ? null :
17
- node.closest('[data-reffy-page]')?.getAttribute('data-reffy-page');
18
- const url = new URL(page ?? window.location.href);
19
- const hashid = node.getAttribute(attribute);
20
- if (hashid) {
21
- let fragment = hashid;
22
- if (hashid.match(/^#/) && attribute === 'href') {
23
- // Function is called to turn a fragment ref into an absolute URL
24
- fragment = hashid.substring(1);
25
- }
26
- url.hash = '#' + encodeURIComponent(fragment);
27
- }
28
- return url.toString();
29
- }
1
+ /**
2
+ * Gets the absolute URL with fragment to the given node
3
+ *
4
+ * @function
5
+ * @public
6
+ * @param {Element} node DOM node to look at. Must have an ID.
7
+ * @param {Object} options "singlePage" asserts whether the spec is single page
8
+ * or whether that's unknown. Default is false for "unknown".
9
+ * "attribute" tells function to use value of given attribute name instead of
10
+ * the node's ID. Default is "id".
11
+ * @return {String} Absolute URL ending with fragment ref
12
+ */
13
+ export default function (node, { singlePage, attribute } =
14
+ { singlePage: false, attribute: 'id' }) {
15
+ attribute = attribute ?? 'id';
16
+ const page = singlePage ? null :
17
+ node.closest('[data-reffy-page]')?.getAttribute('data-reffy-page');
18
+ const url = new URL(page ?? window.location.href);
19
+ const hashid = node.getAttribute(attribute);
20
+ if (hashid) {
21
+ let fragment = hashid;
22
+ if (hashid.match(/^#/) && attribute === 'href') {
23
+ // Function is called to turn a fragment ref into an absolute URL
24
+ fragment = hashid.substring(1);
25
+ }
26
+ url.hash = '#' + encodeURIComponent(fragment);
27
+ }
28
+ return url.toString();
29
+ }
@@ -1,21 +1,21 @@
1
- import informativeSelector from './informative-selector.mjs';
2
- import cloneAndClean from './clone-and-clean.mjs';
3
-
4
- /**
5
- * Helper function that returns a set of code elements in document order based
6
- * on a given set of selectors, excluding elements that are within an index.
7
- *
8
- * The function excludes elements defined in informative sections.
9
- *
10
- * The code elements are cloned and cleaned before they are returned to strip
11
- * annotations and other asides.
12
- */
13
- export default function getCodeElements(codeSelectors, { excludeSelectors = [] }) {
14
- return [...document.querySelectorAll(codeSelectors.join(', '))]
15
- // Skip excluded and elements and those in informative content
16
- .filter(el => !el.closest(excludeSelectors.join(', ')))
17
- .filter(el => !el.closest(informativeSelector))
18
-
19
- // Clone and clean the elements
20
- .map(cloneAndClean);
1
+ import informativeSelector from './informative-selector.mjs';
2
+ import cloneAndClean from './clone-and-clean.mjs';
3
+
4
+ /**
5
+ * Helper function that returns a set of code elements in document order based
6
+ * on a given set of selectors, excluding elements that are within an index.
7
+ *
8
+ * The function excludes elements defined in informative sections.
9
+ *
10
+ * The code elements are cloned and cleaned before they are returned to strip
11
+ * annotations and other asides.
12
+ */
13
+ export default function getCodeElements(codeSelectors, { excludeSelectors = [] }) {
14
+ return [...document.querySelectorAll(codeSelectors.join(', '))]
15
+ // Skip excluded and elements and those in informative content
16
+ .filter(el => !el.closest(excludeSelectors.join(', ')))
17
+ .filter(el => !el.closest(informativeSelector))
18
+
19
+ // Clone and clean the elements
20
+ .map(cloneAndClean);
21
21
  }
@@ -1,27 +1,27 @@
1
- /**
2
- * Return the name of a well-known generator that was used to generate the
3
- * spec, if known.
4
- *
5
- * This function expects to run within a browser context.
6
- *
7
- * @function
8
- * @public
9
- * @param {Window} window
10
- * @return {Promise} The promise to get a document ready for extraction and
11
- * the name of the generator (or null if generator is unknown).
12
- */
13
- export default function () {
14
- const generator = window.document.querySelector('meta[name="generator"]');
15
- if (generator && generator.content.match(/bikeshed/i)) {
16
- return 'bikeshed';
17
- }
18
- else if ((generator && generator.content.match(/respec/i)) ||
19
- (document.body.id === 'respecDocument') ||
20
- window.respecConfig ||
21
- window.eval('typeof respecConfig !== "undefined"')) {
22
- return 'respec';
23
- }
24
- else {
25
- return null;
26
- }
1
+ /**
2
+ * Return the name of a well-known generator that was used to generate the
3
+ * spec, if known.
4
+ *
5
+ * This function expects to run within a browser context.
6
+ *
7
+ * @function
8
+ * @public
9
+ * @param {Window} window
10
+ * @return {Promise} The promise to get a document ready for extraction and
11
+ * the name of the generator (or null if generator is unknown).
12
+ */
13
+ export default function () {
14
+ const generator = window.document.querySelector('meta[name="generator"]');
15
+ if (generator && generator.content.match(/bikeshed/i)) {
16
+ return 'bikeshed';
17
+ }
18
+ else if ((generator && generator.content.match(/respec/i)) ||
19
+ (document.body.id === 'respecDocument') ||
20
+ window.respecConfig ||
21
+ window.eval('typeof respecConfig !== "undefined"')) {
22
+ return 'respec';
23
+ }
24
+ else {
25
+ return null;
26
+ }
27
27
  }
@@ -1,14 +1,14 @@
1
- export default function () {
2
- const dateEl = document.querySelector('.head time');
3
- const statusAndDate = [...document.querySelectorAll('.head h2')]
4
- .map(el => el.textContent).join(' ').trim();
5
- const lastModified = new Date(Date.parse(document.lastModified));
6
- const date = dateEl ? dateEl.textContent.trim() :
7
- (statusAndDate ? statusAndDate.split(/\s+/).slice(-3).join(' ') :
8
- [
9
- lastModified.toLocaleDateString('en-US', { day: 'numeric' }),
10
- lastModified.toLocaleDateString('en-US', { month: 'long' }),
11
- lastModified.toLocaleDateString('en-US', { year: 'numeric' })
12
- ].join(' '));
13
- return date;
1
+ export default function () {
2
+ const dateEl = document.querySelector('.head time');
3
+ const statusAndDate = [...document.querySelectorAll('.head h2')]
4
+ .map(el => el.textContent).join(' ').trim();
5
+ const lastModified = new Date(Date.parse(document.lastModified));
6
+ const date = dateEl ? dateEl.textContent.trim() :
7
+ (statusAndDate ? statusAndDate.split(/\s+/).slice(-3).join(' ') :
8
+ [
9
+ lastModified.toLocaleDateString('en-US', { day: 'numeric' }),
10
+ lastModified.toLocaleDateString('en-US', { month: 'long' }),
11
+ lastModified.toLocaleDateString('en-US', { year: 'numeric' })
12
+ ].join(' '));
13
+ return date;
14
14
  }
@@ -1,12 +1,12 @@
1
- export default function () {
2
- // bikeshed uses 'document-revision'
3
- // but the documented convention in https://wiki.whatwg.org/wiki/MetaExtensions
4
- // is just 'revision' per https://github.com/krallin/meta-revision
5
- const meta = document.querySelector('meta[name="document-revision"], meta[name="revision"]');
6
- const revision = meta?.content.trim();
7
- // git commit shas are 40 hexadecimal characters
8
- if (revision?.match(/[0-9a-f]{40}/)) {
9
- return revision;
10
- }
11
- return null;
12
- }
1
+ export default function () {
2
+ // bikeshed uses 'document-revision'
3
+ // but the documented convention in https://wiki.whatwg.org/wiki/MetaExtensions
4
+ // is just 'revision' per https://github.com/krallin/meta-revision
5
+ const meta = document.querySelector('meta[name="document-revision"], meta[name="revision"]');
6
+ const revision = meta?.content.trim();
7
+ // git commit shas are 40 hexadecimal characters
8
+ if (revision?.match(/[0-9a-f]{40}/)) {
9
+ return revision;
10
+ }
11
+ return null;
12
+ }
@@ -1,15 +1,15 @@
1
- /**
2
- * Gets the title of the document
3
- */
4
- export default function (spec) {
5
- const title = window.document.querySelector('title');
6
- if (title) {
7
- return title.textContent.replace(/\s+/g, ' ').trim();
8
- }
9
- else if (spec?.title) {
10
- return spec.title;
11
- }
12
- else {
13
- return '[No title found for ' + window.location.href + ']';
14
- }
1
+ /**
2
+ * Gets the title of the document
3
+ */
4
+ export default function (spec) {
5
+ const title = window.document.querySelector('title');
6
+ if (title) {
7
+ return title.textContent.replace(/\s+/g, ' ').trim();
8
+ }
9
+ else if (spec?.title) {
10
+ return spec.title;
11
+ }
12
+ else {
13
+ return '[No title found for ' + window.location.href + ']';
14
+ }
15
15
  }
@@ -1,25 +1,25 @@
1
- /**
2
- * Query selector that matches informative sections
3
- *
4
- * Based on:
5
- * https://github.com/w3c/respec/blob/develop/src/core/utils.js#L45
6
- * https://tabatkins.github.io/bikeshed/#metadata-informative-classes
7
- */
8
- export default [
9
- '.informative',
10
- '.informative-bg',
11
- '.note',
12
- '.issue',
13
- '.example',
14
- '.ednote',
15
- '.annotation',
16
- '.practice',
17
- '.introductory',
18
- '.non-normative',
19
- 'aside',
20
- '.idlHeader',
21
- '[id^=dfn-panel-]',
22
- '.mdn-anno',
23
- '.wpt-tests-block',
24
- 'details.respec-tests-details'
1
+ /**
2
+ * Query selector that matches informative sections
3
+ *
4
+ * Based on:
5
+ * https://github.com/w3c/respec/blob/develop/src/core/utils.js#L45
6
+ * https://tabatkins.github.io/bikeshed/#metadata-informative-classes
7
+ */
8
+ export default [
9
+ '.informative',
10
+ '.informative-bg',
11
+ '.note',
12
+ '.issue',
13
+ '.example',
14
+ '.ednote',
15
+ '.annotation',
16
+ '.practice',
17
+ '.introductory',
18
+ '.non-normative',
19
+ 'aside',
20
+ '.idlHeader',
21
+ '[id^=dfn-panel-]',
22
+ '.mdn-anno',
23
+ '.wpt-tests-block',
24
+ 'details.respec-tests-details'
25
25
  ].join(',');