reffy 6.2.0 → 6.2.1

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 (43) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +158 -158
  3. package/index.js +11 -11
  4. package/package.json +53 -53
  5. package/reffy.js +248 -248
  6. package/src/browserlib/canonicalize-url.mjs +50 -50
  7. package/src/browserlib/create-outline.mjs +352 -352
  8. package/src/browserlib/extract-cssdfn.mjs +319 -319
  9. package/src/browserlib/extract-dfns.mjs +686 -686
  10. package/src/browserlib/extract-elements.mjs +205 -205
  11. package/src/browserlib/extract-headings.mjs +48 -48
  12. package/src/browserlib/extract-ids.mjs +28 -28
  13. package/src/browserlib/extract-links.mjs +28 -28
  14. package/src/browserlib/extract-references.mjs +203 -203
  15. package/src/browserlib/extract-webidl.mjs +134 -134
  16. package/src/browserlib/get-absolute-url.mjs +21 -21
  17. package/src/browserlib/get-generator.mjs +26 -26
  18. package/src/browserlib/get-lastmodified-date.mjs +13 -13
  19. package/src/browserlib/get-title.mjs +11 -11
  20. package/src/browserlib/informative-selector.mjs +16 -16
  21. package/src/browserlib/map-ids-to-headings.mjs +136 -136
  22. package/src/browserlib/reffy.json +53 -53
  23. package/src/cli/check-missing-dfns.js +609 -609
  24. package/src/cli/generate-idlnames.js +430 -430
  25. package/src/cli/generate-idlparsed.js +139 -139
  26. package/src/cli/merge-crawl-results.js +128 -128
  27. package/src/cli/parse-webidl.js +430 -430
  28. package/src/lib/css-grammar-parse-tree.schema.json +109 -109
  29. package/src/lib/css-grammar-parser.js +440 -440
  30. package/src/lib/fetch.js +55 -55
  31. package/src/lib/nock-server.js +119 -119
  32. package/src/lib/specs-crawler.js +605 -603
  33. package/src/lib/util.js +898 -898
  34. package/src/specs/missing-css-rules.json +197 -197
  35. package/src/specs/spec-equivalents.json +149 -149
  36. package/src/browserlib/extract-editors.mjs~ +0 -14
  37. package/src/browserlib/generate-es-dfn-report.sh~ +0 -4
  38. package/src/cli/csstree-grammar-check.js +0 -28
  39. package/src/cli/csstree-grammar-check.js~ +0 -10
  40. package/src/cli/csstree-grammar-parser.js +0 -11
  41. package/src/cli/csstree-grammar-parser.js~ +0 -1
  42. package/src/cli/extract-editors.js~ +0 -38
  43. package/src/cli/process-specs.js~ +0 -28
package/src/lib/fetch.js CHANGED
@@ -1,56 +1,56 @@
1
- /**
2
- * Wrapper around the fetch module to setup a few config parameters from
3
- * config.json
4
- *
5
- * @module finder
6
- */
7
-
8
- const os = require('os');
9
- const path = require('path');
10
- const baseFetch = require('fetch-filecache-for-crawling');
11
-
12
- // Read configuration parameters from `config.json` file
13
- let config = null;
14
- try {
15
- config = require(path.resolve('config.json'));
16
- }
17
- catch (err) {
18
- config = {};
19
- }
20
-
21
-
22
- /**
23
- * Fetch function that applies fetch parameters defined in `config.json`
24
- * unless parameters are already set.
25
- *
26
- * By default, force the HTTP refresh strategy to "once", so that only one
27
- * HTTP request gets sent on a given URL per crawl.
28
- *
29
- * @function
30
- * @param {String} url URL to fetch
31
- * @param {Object} options Fetch options (and options for node-fetch, and
32
- * options for fetch-filecache-for-crawling)
33
- * @return {Promise(Response)} Promise to get an HTTP response
34
- */
35
- async function fetch(url, options) {
36
- options = Object.assign({}, options);
37
- ['cacheFolder', 'resetCache', 'cacheRefresh', 'logToConsole'].forEach(param => {
38
- let fetchParam = (param === 'cacheRefresh') ? 'refresh' : param;
39
- if (config[param] && !options.hasOwnProperty(fetchParam)) {
40
- options[fetchParam] = config[param];
41
- }
42
- });
43
- if (!options.refresh) {
44
- options.refresh = 'once';
45
- }
46
-
47
- // Use cache folder in tmp folder by default
48
- if (!options.cacheFolder) {
49
- options.cacheFolder = path.resolve(os.tmpdir(), 'reffy-cache');
50
- }
51
-
52
- return baseFetch(url, options);
53
- }
54
-
55
-
1
+ /**
2
+ * Wrapper around the fetch module to setup a few config parameters from
3
+ * config.json
4
+ *
5
+ * @module finder
6
+ */
7
+
8
+ const os = require('os');
9
+ const path = require('path');
10
+ const baseFetch = require('fetch-filecache-for-crawling');
11
+
12
+ // Read configuration parameters from `config.json` file
13
+ let config = null;
14
+ try {
15
+ config = require(path.resolve('config.json'));
16
+ }
17
+ catch (err) {
18
+ config = {};
19
+ }
20
+
21
+
22
+ /**
23
+ * Fetch function that applies fetch parameters defined in `config.json`
24
+ * unless parameters are already set.
25
+ *
26
+ * By default, force the HTTP refresh strategy to "once", so that only one
27
+ * HTTP request gets sent on a given URL per crawl.
28
+ *
29
+ * @function
30
+ * @param {String} url URL to fetch
31
+ * @param {Object} options Fetch options (and options for node-fetch, and
32
+ * options for fetch-filecache-for-crawling)
33
+ * @return {Promise(Response)} Promise to get an HTTP response
34
+ */
35
+ async function fetch(url, options) {
36
+ options = Object.assign({}, options);
37
+ ['cacheFolder', 'resetCache', 'cacheRefresh', 'logToConsole'].forEach(param => {
38
+ let fetchParam = (param === 'cacheRefresh') ? 'refresh' : param;
39
+ if (config[param] && !options.hasOwnProperty(fetchParam)) {
40
+ options[fetchParam] = config[param];
41
+ }
42
+ });
43
+ if (!options.refresh) {
44
+ options.refresh = 'once';
45
+ }
46
+
47
+ // Use cache folder in tmp folder by default
48
+ if (!options.cacheFolder) {
49
+ options.cacheFolder = path.resolve(os.tmpdir(), 'reffy-cache');
50
+ }
51
+
52
+ return baseFetch(url, options);
53
+ }
54
+
55
+
56
56
  module.exports = fetch;
@@ -1,120 +1,120 @@
1
- /**
2
- * Setup a proxy server that intercepts some network requests. To be used in
3
- * tests not to hit the network.
4
- *
5
- * @module nock-server
6
- */
7
-
8
- const nock = require("nock");
9
- const path = require("path");
10
- const { existsSync } = require('fs');
11
-
12
- /**
13
- * Determine the path to the "node_modules" folder. The path depends on whether
14
- * Reffy is run directly, or installed as a library.
15
- *
16
- * @function
17
- * @return {String} Path to the node_modules folder.
18
- */
19
- function getModulesFolder() {
20
- const rootFolder = path.resolve(__dirname, '../..');
21
- let folder = path.resolve(rootFolder, 'node_modules');
22
- if (existsSync(folder)) {
23
- return folder;
24
- }
25
- folder = path.resolve(rootFolder, '..');
26
- return folder;
27
- }
28
- const modulesFolder = getModulesFolder();
29
-
30
- const mockSpecs = {
31
- "/woff/woff2/": {
32
- html: `
33
- <title>WOFF2</title>
34
- <body>
35
- <dfn id='foo'>Foo</dfn>
36
- <a href="https://www.w3.org/TR/bar/#baz">bar</a>
37
- <ul class='toc'><li><a href='page.html'>page</a></ul>`,
38
- pages: {
39
- "page.html": `<h2 id='bar'>Heading in subpage</h2>`
40
- }
41
- },
42
- "/mediacapture-output/": `
43
- <script>respecConfig = { shortName: 'test' };</script>
44
- <script src='https://www.w3.org/Tools/respec/respec-w3c'></script>
45
- <div id=abstract></div>
46
- <pre class='idl'>[Exposed=Window] interface Foo { attribute DOMString bar; };</pre>`,
47
- "/accelerometer/": `<html>
48
- <h2>Normative references</h2>
49
- <dl>
50
- <dt>FOO</dt>
51
- <dd><a href='https://www.w3.org/TR/Foo'>Foo</a></dd>
52
- </dl>`,
53
- "/pointerlock/": `<html>
54
- <h1>Pointer Lock 2.0`
55
- };
56
-
57
- nock.disableNetConnect();
58
- // for chrome devtool protocol
59
- nock.enableNetConnect('127.0.0.1');
60
-
61
- Object.keys(mockSpecs).forEach(path => {
62
- nock("https://w3c.github.io")
63
- .persist()
64
- .get(path)
65
- .reply(200,
66
- typeof mockSpecs[path] === "string" ? mockSpecs[path] : mockSpecs[path].html,
67
- { 'Content-Type': 'text/html' }
68
- );
69
-
70
- Object.keys(mockSpecs[path].pages || {}).forEach(page => {
71
- nock("https://w3c.github.io")
72
- .persist()
73
- .get(path + page)
74
- .reply(200,
75
- mockSpecs[path].pages[page],
76
- { 'Content-Type': 'text/html' });
77
-
78
- });
79
- });
80
-
81
-
82
- // Handling requests generated by ReSpec documents
83
- nock("https://api.specref.org")
84
- .persist()
85
- .get("/bibrefs?refs=webidl,html").reply(200,
86
- { webidl: { href: "https://webidl.spec.whatwg.org/" } },
87
- { "Access-Control-Allow-Origin": "*" }
88
- );
89
-
90
- nock("https://www.w3.org")
91
- .persist()
92
- .get("/scripts/TR/2021/fixup.js").reply(200, '')
93
- .get("/StyleSheets/TR/2021/logos/W3C").reply(200, '')
94
- .get("/StyleSheets/TR/2021/base.css").reply(200, '')
95
- .get("/Tools/respec/respec-highlight").replyWithFile(200,
96
- path.join(modulesFolder, "respec-hljs", "dist", "respec-highlight.js"),
97
- { "Content-Type": "application/js" })
98
- .get("/Tools/respec/respec-w3c").replyWithFile(200,
99
- path.join(modulesFolder, "respec", "builds", "respec-w3c.js"),
100
- { "Content-Type": "application/js" })
101
- .get("/TR/idontexist/").reply(404, '');
102
-
103
- nock("https://drafts.csswg.org")
104
- .persist()
105
- .get("/server-hiccup/").reply(200,
106
- `<html><title>Server hiccup</title>
107
- <h1> Index of Server Hiccup Module Level 42 </h1>`,
108
- { 'Content-Type': 'text/html' });
109
-
110
- nock.emitter.on('error', function (err) {
111
- console.error(err);
112
- });
113
- nock.emitter.on('no match', function(req, options, requestBody) {
114
- // 127.0.0.1 is used by the devtool protocol, we ignore it
115
- if (req && req.hostname !== '127.0.0.1') {
116
- console.error("No match for nock request on " + (options ? options.href : req.href));
117
- }
118
- });
119
-
1
+ /**
2
+ * Setup a proxy server that intercepts some network requests. To be used in
3
+ * tests not to hit the network.
4
+ *
5
+ * @module nock-server
6
+ */
7
+
8
+ const nock = require("nock");
9
+ const path = require("path");
10
+ const { existsSync } = require('fs');
11
+
12
+ /**
13
+ * Determine the path to the "node_modules" folder. The path depends on whether
14
+ * Reffy is run directly, or installed as a library.
15
+ *
16
+ * @function
17
+ * @return {String} Path to the node_modules folder.
18
+ */
19
+ function getModulesFolder() {
20
+ const rootFolder = path.resolve(__dirname, '../..');
21
+ let folder = path.resolve(rootFolder, 'node_modules');
22
+ if (existsSync(folder)) {
23
+ return folder;
24
+ }
25
+ folder = path.resolve(rootFolder, '..');
26
+ return folder;
27
+ }
28
+ const modulesFolder = getModulesFolder();
29
+
30
+ const mockSpecs = {
31
+ "/woff/woff2/": {
32
+ html: `
33
+ <title>WOFF2</title>
34
+ <body>
35
+ <dfn id='foo'>Foo</dfn>
36
+ <a href="https://www.w3.org/TR/bar/#baz">bar</a>
37
+ <ul class='toc'><li><a href='page.html'>page</a></ul>`,
38
+ pages: {
39
+ "page.html": `<h2 id='bar'>Heading in subpage</h2>`
40
+ }
41
+ },
42
+ "/mediacapture-output/": `
43
+ <script>respecConfig = { shortName: 'test' };</script>
44
+ <script src='https://www.w3.org/Tools/respec/respec-w3c'></script>
45
+ <div id=abstract></div>
46
+ <pre class='idl'>[Exposed=Window] interface Foo { attribute DOMString bar; };</pre>`,
47
+ "/accelerometer/": `<html>
48
+ <h2>Normative references</h2>
49
+ <dl>
50
+ <dt>FOO</dt>
51
+ <dd><a href='https://www.w3.org/TR/Foo'>Foo</a></dd>
52
+ </dl>`,
53
+ "/pointerlock/": `<html>
54
+ <h1>Pointer Lock 2.0`
55
+ };
56
+
57
+ nock.disableNetConnect();
58
+ // for chrome devtool protocol
59
+ nock.enableNetConnect('127.0.0.1');
60
+
61
+ Object.keys(mockSpecs).forEach(path => {
62
+ nock("https://w3c.github.io")
63
+ .persist()
64
+ .get(path)
65
+ .reply(200,
66
+ typeof mockSpecs[path] === "string" ? mockSpecs[path] : mockSpecs[path].html,
67
+ { 'Content-Type': 'text/html' }
68
+ );
69
+
70
+ Object.keys(mockSpecs[path].pages || {}).forEach(page => {
71
+ nock("https://w3c.github.io")
72
+ .persist()
73
+ .get(path + page)
74
+ .reply(200,
75
+ mockSpecs[path].pages[page],
76
+ { 'Content-Type': 'text/html' });
77
+
78
+ });
79
+ });
80
+
81
+
82
+ // Handling requests generated by ReSpec documents
83
+ nock("https://api.specref.org")
84
+ .persist()
85
+ .get("/bibrefs?refs=webidl,html").reply(200,
86
+ { webidl: { href: "https://webidl.spec.whatwg.org/" } },
87
+ { "Access-Control-Allow-Origin": "*" }
88
+ );
89
+
90
+ nock("https://www.w3.org")
91
+ .persist()
92
+ .get("/scripts/TR/2021/fixup.js").reply(200, '')
93
+ .get("/StyleSheets/TR/2021/logos/W3C").reply(200, '')
94
+ .get("/StyleSheets/TR/2021/base.css").reply(200, '')
95
+ .get("/Tools/respec/respec-highlight").replyWithFile(200,
96
+ path.join(modulesFolder, "respec-hljs", "dist", "respec-highlight.js"),
97
+ { "Content-Type": "application/js" })
98
+ .get("/Tools/respec/respec-w3c").replyWithFile(200,
99
+ path.join(modulesFolder, "respec", "builds", "respec-w3c.js"),
100
+ { "Content-Type": "application/js" })
101
+ .get("/TR/idontexist/").reply(404, '');
102
+
103
+ nock("https://drafts.csswg.org")
104
+ .persist()
105
+ .get("/server-hiccup/").reply(200,
106
+ `<html><title>Server hiccup</title>
107
+ <h1> Index of Server Hiccup Module Level 42 </h1>`,
108
+ { 'Content-Type': 'text/html' });
109
+
110
+ nock.emitter.on('error', function (err) {
111
+ console.error(err);
112
+ });
113
+ nock.emitter.on('no match', function(req, options, requestBody) {
114
+ // 127.0.0.1 is used by the devtool protocol, we ignore it
115
+ if (req && req.hostname !== '127.0.0.1') {
116
+ console.error("No match for nock request on " + (options ? options.href : req.href));
117
+ }
118
+ });
119
+
120
120
  module.exports = nock;