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,132 +1,132 @@
1
- #!/usr/bin/env node
2
- /**
3
- * The crawl report merger can be used to merge a new crawl report into a
4
- * reference one. This tool is typically useful to make incremental updates to a
5
- * reference crawl, used as knowledge database. It replaces the crawl results of
6
- * a given spec by the new results where appropriate.
7
- *
8
- * The crawl report merge can be called directly through:
9
- *
10
- * `node merge-crawl-results.js [new report] [ref report] [merged report]`
11
- *
12
- * where `new report` is the name of the new report to merge into `ref report`
13
- * to produce the `merged report` file.
14
- *
15
- * @module merger
16
- */
17
-
18
- import fs from 'node:fs';
19
- import { fileURLToPath } from 'node:url';
20
- import process from 'node:process';
21
- import { loadJSON } from '../lib/util.js';
22
-
23
-
24
- /**
25
- * Compares specs for ordering by URL
26
- */
27
- const byURL = (a, b) => a.url.localeCompare(b.url);
28
-
29
-
30
- /**
31
- * Merge given crawl results with the given reference crawl results and return
32
- * the new results.
33
- *
34
- * @function
35
- * @param {String} newCrawl The crawl results to merge
36
- * @param {String} refCrawl The reference crawl results
37
- * @param {Object} options Merge options. Only "matchTitle" is supported for now
38
- * @return {Promise} The promise to get a new crawl results that contains the
39
- * results of the merge
40
- */
41
- function mergeCrawlResults(newCrawl, refCrawl, options) {
42
- options = options || {};
43
-
44
- let newResults = newCrawl.results || [];
45
- let refResults = refCrawl.results || [];
46
-
47
- let results = refResults.filter(refSpec => !newResults.some(newSpec =>
48
- (refSpec.url && newSpec.url && (refSpec.url === newSpec.url)) ||
49
- (refSpec.html && newSpec.html && (refSpec.html === newSpec.html)) ||
50
- (refSpec.latest && newSpec.latest && (refSpec.latest === newSpec.latest)) ||
51
- (refSpec.shortname && newSpec.shortname && (refSpec.shortname === newSpec.shortname)) ||
52
- (refSpec.versions && newSpec.versions &&
53
- refSpec.versions.some(refVersion => newSpec.versions.some(newVersion => (refVersion === newVersion)))) ||
54
- (options.matchTitle && refSpec.title && newSpec.title && (refSpec.title === newSpec.title))
55
- )).concat(newResults);
56
-
57
- let crawlData = {};
58
- crawlData.title = newCrawl.title || refCrawl.title || 'Reffy crawl';
59
- if (newCrawl.description || refCrawl.description) {
60
- crawlData.description = newCrawl.description || refCrawl.description;
61
- }
62
- crawlData.date = (new Date()).toJSON();
63
- crawlData.stats = {};
64
- crawlData.results = results;
65
- crawlData.results.sort(byURL);
66
- crawlData.stats = {
67
- crawled: crawlData.results.length,
68
- errors: crawlData.results.filter(spec => !!spec.error).length
69
- };
70
-
71
- return Promise.resolve(crawlData);
72
- }
73
-
74
-
75
- /**
76
- * Merge the crawl results in the first JSON file with the crawl results in the
77
- * second JSON file, and create a third JSON file with the results.
78
- *
79
- * @function
80
- * @param {String} newCrawlPath The JSON file that contains the results to merge
81
- * @param {String} refCrawlPath The JSON file that contains the reference results
82
- * @param {String} resPath The JSON file that will contain the result of the merge
83
- * @param {Object} options Merge options. Only "matchTitle" is supported for now
84
- * @return {Promise} The promise to have merged the two JSON files into one
85
- */
86
- async function mergeCrawlFiles(newCrawlPath, refCrawlPath, resPath, options) {
87
- options = options || {};
88
-
89
- let newCrawl = await loadJSON(newCrawlPath);
90
- let refCrawl = await loadJSON(refCrawlPath);
91
- return mergeCrawlResults(newCrawl, refCrawl, options)
92
- .then(filedata => new Promise((resolve, reject) =>
93
- fs.writeFile(resPath, JSON.stringify(filedata, null, 2),
94
- err => { if (err) return reject(err); resolve(); })))
95
- }
96
-
97
-
98
- /**************************************************
99
- Export the methods for use as module
100
- **************************************************/
101
- export {
102
- mergeCrawlResults,
103
- mergeCrawlFiles
104
- };
105
-
106
-
107
- /**************************************************
108
- Code run if the code is run as a stand-alone module
109
- **************************************************/
110
- if (process.argv[1] === fileURLToPath(import.meta.url)) {
111
- let newCrawlPath = process.argv[2];
112
- let refCrawlPath = process.argv[3];
113
- let resPath = process.argv[4];
114
- if (!newCrawlPath || !refCrawlPath || !resPath) {
115
- console.error('Command needs 3 filename parameters:');
116
- console.error(' 1. the crawl results to merge into the reference crawl results');
117
- console.error(' 2. the reference crawl results');
118
- console.error(' 3. where to save the result of the merge');
119
- process.exit(2);
120
- }
121
- let mergeOptions = {
122
- matchTitle: true
123
- };
124
-
125
- console.log('Merging crawl files into: ' + resPath);
126
- mergeCrawlFiles(newCrawlPath, refCrawlPath, resPath, mergeOptions)
127
- .then(_ => console.log('Finished'))
128
- .catch(err => {
129
- console.error(err);
130
- process.exit(64)
131
- });
132
- }
1
+ #!/usr/bin/env node
2
+ /**
3
+ * The crawl report merger can be used to merge a new crawl report into a
4
+ * reference one. This tool is typically useful to make incremental updates to a
5
+ * reference crawl, used as knowledge database. It replaces the crawl results of
6
+ * a given spec by the new results where appropriate.
7
+ *
8
+ * The crawl report merge can be called directly through:
9
+ *
10
+ * `node merge-crawl-results.js [new report] [ref report] [merged report]`
11
+ *
12
+ * where `new report` is the name of the new report to merge into `ref report`
13
+ * to produce the `merged report` file.
14
+ *
15
+ * @module merger
16
+ */
17
+
18
+ import fs from 'node:fs';
19
+ import { fileURLToPath } from 'node:url';
20
+ import process from 'node:process';
21
+ import { loadJSON } from '../lib/util.js';
22
+
23
+
24
+ /**
25
+ * Compares specs for ordering by URL
26
+ */
27
+ const byURL = (a, b) => a.url.localeCompare(b.url);
28
+
29
+
30
+ /**
31
+ * Merge given crawl results with the given reference crawl results and return
32
+ * the new results.
33
+ *
34
+ * @function
35
+ * @param {String} newCrawl The crawl results to merge
36
+ * @param {String} refCrawl The reference crawl results
37
+ * @param {Object} options Merge options. Only "matchTitle" is supported for now
38
+ * @return {Promise} The promise to get a new crawl results that contains the
39
+ * results of the merge
40
+ */
41
+ function mergeCrawlResults(newCrawl, refCrawl, options) {
42
+ options = options || {};
43
+
44
+ let newResults = newCrawl.results || [];
45
+ let refResults = refCrawl.results || [];
46
+
47
+ let results = refResults.filter(refSpec => !newResults.some(newSpec =>
48
+ (refSpec.url && newSpec.url && (refSpec.url === newSpec.url)) ||
49
+ (refSpec.html && newSpec.html && (refSpec.html === newSpec.html)) ||
50
+ (refSpec.latest && newSpec.latest && (refSpec.latest === newSpec.latest)) ||
51
+ (refSpec.shortname && newSpec.shortname && (refSpec.shortname === newSpec.shortname)) ||
52
+ (refSpec.versions && newSpec.versions &&
53
+ refSpec.versions.some(refVersion => newSpec.versions.some(newVersion => (refVersion === newVersion)))) ||
54
+ (options.matchTitle && refSpec.title && newSpec.title && (refSpec.title === newSpec.title))
55
+ )).concat(newResults);
56
+
57
+ let crawlData = {};
58
+ crawlData.title = newCrawl.title || refCrawl.title || 'Reffy crawl';
59
+ if (newCrawl.description || refCrawl.description) {
60
+ crawlData.description = newCrawl.description || refCrawl.description;
61
+ }
62
+ crawlData.date = (new Date()).toJSON();
63
+ crawlData.stats = {};
64
+ crawlData.results = results;
65
+ crawlData.results.sort(byURL);
66
+ crawlData.stats = {
67
+ crawled: crawlData.results.length,
68
+ errors: crawlData.results.filter(spec => !!spec.error).length
69
+ };
70
+
71
+ return Promise.resolve(crawlData);
72
+ }
73
+
74
+
75
+ /**
76
+ * Merge the crawl results in the first JSON file with the crawl results in the
77
+ * second JSON file, and create a third JSON file with the results.
78
+ *
79
+ * @function
80
+ * @param {String} newCrawlPath The JSON file that contains the results to merge
81
+ * @param {String} refCrawlPath The JSON file that contains the reference results
82
+ * @param {String} resPath The JSON file that will contain the result of the merge
83
+ * @param {Object} options Merge options. Only "matchTitle" is supported for now
84
+ * @return {Promise} The promise to have merged the two JSON files into one
85
+ */
86
+ async function mergeCrawlFiles(newCrawlPath, refCrawlPath, resPath, options) {
87
+ options = options || {};
88
+
89
+ let newCrawl = await loadJSON(newCrawlPath);
90
+ let refCrawl = await loadJSON(refCrawlPath);
91
+ return mergeCrawlResults(newCrawl, refCrawl, options)
92
+ .then(filedata => new Promise((resolve, reject) =>
93
+ fs.writeFile(resPath, JSON.stringify(filedata, null, 2),
94
+ err => { if (err) return reject(err); resolve(); })))
95
+ }
96
+
97
+
98
+ /**************************************************
99
+ Export the methods for use as module
100
+ **************************************************/
101
+ export {
102
+ mergeCrawlResults,
103
+ mergeCrawlFiles
104
+ };
105
+
106
+
107
+ /**************************************************
108
+ Code run if the code is run as a stand-alone module
109
+ **************************************************/
110
+ if (process.argv[1] === fileURLToPath(import.meta.url)) {
111
+ let newCrawlPath = process.argv[2];
112
+ let refCrawlPath = process.argv[3];
113
+ let resPath = process.argv[4];
114
+ if (!newCrawlPath || !refCrawlPath || !resPath) {
115
+ console.error('Command needs 3 filename parameters:');
116
+ console.error(' 1. the crawl results to merge into the reference crawl results');
117
+ console.error(' 2. the reference crawl results');
118
+ console.error(' 3. where to save the result of the merge');
119
+ process.exit(2);
120
+ }
121
+ let mergeOptions = {
122
+ matchTitle: true
123
+ };
124
+
125
+ console.log('Merging crawl files into: ' + resPath);
126
+ mergeCrawlFiles(newCrawlPath, refCrawlPath, resPath, mergeOptions)
127
+ .then(_ => console.log('Finished'))
128
+ .catch(err => {
129
+ console.error(err);
130
+ process.exit(64)
131
+ });
132
+ }