reffy 10.2.3 → 10.3.0
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "reffy",
|
|
3
|
-
"version": "10.
|
|
3
|
+
"version": "10.3.0",
|
|
4
4
|
"description": "W3C/WHATWG spec dependencies exploration companion. Features a short set of tools to study spec references as well as WebIDL term definitions and references found in W3C specifications.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -33,13 +33,13 @@
|
|
|
33
33
|
"bin": "./reffy.js",
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"abortcontroller-polyfill": "1.7.5",
|
|
36
|
-
"ajv": "8.11.
|
|
36
|
+
"ajv": "8.11.2",
|
|
37
37
|
"ajv-formats": "2.1.1",
|
|
38
38
|
"commander": "9.4.1",
|
|
39
39
|
"fetch-filecache-for-crawling": "4.1.0",
|
|
40
|
-
"puppeteer": "19.
|
|
40
|
+
"puppeteer": "19.3.0",
|
|
41
41
|
"semver": "^7.3.5",
|
|
42
|
-
"web-specs": "2.
|
|
42
|
+
"web-specs": "2.36.0",
|
|
43
43
|
"webidl2": "24.2.2"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"nock": "13.2.9",
|
|
49
49
|
"respec": "32.3.0",
|
|
50
50
|
"respec-hljs": "2.1.1",
|
|
51
|
-
"rollup": "3.
|
|
51
|
+
"rollup": "3.5.0"
|
|
52
52
|
},
|
|
53
53
|
"scripts": {
|
|
54
54
|
"test": "mocha --recursive tests/"
|
|
@@ -24,6 +24,13 @@ import {parse} from "../../node_modules/webidl2/index.js";
|
|
|
24
24
|
* "prose" (last one indicates that definition appears in the main body of
|
|
25
25
|
* the spec)
|
|
26
26
|
*
|
|
27
|
+
* The extraction ignores definitions with an unknown type. A warning is issued
|
|
28
|
+
* to the console when that happens.
|
|
29
|
+
*
|
|
30
|
+
* The extraction uses the first definition it finds when it bumps into a term
|
|
31
|
+
* that is defined more than once (same "linkingText", same "type", same "for").
|
|
32
|
+
* A warning is issued to the console when that happens.
|
|
33
|
+
*
|
|
27
34
|
* @function
|
|
28
35
|
* @public
|
|
29
36
|
* @return {Array(Object)} An Array of definitions
|
|
@@ -99,8 +106,22 @@ function hasValidType(el) {
|
|
|
99
106
|
return isValid;
|
|
100
107
|
}
|
|
101
108
|
|
|
109
|
+
// Return true when definition is not already defined in the list,
|
|
110
|
+
// Return false and issue a warning when it is already defined.
|
|
111
|
+
function isNotAlreadyDefined(dfn, idx, list) {
|
|
112
|
+
const first = list.find(d => d === dfn ||
|
|
113
|
+
(d.type === dfn.type &&
|
|
114
|
+
d.linkingText.length === dfn.linkingText.length &&
|
|
115
|
+
d.linkingText.every(lt => dfn.linkingText.find(t => t == lt)) &&
|
|
116
|
+
d.for.length === dfn.for.length &&
|
|
117
|
+
d.for.every(lt => dfn.for.find(t => t === lt))));
|
|
118
|
+
if (first !== dfn) {
|
|
119
|
+
console.warn('[reffy]', `Duplicate dfn found for "${dfn.linkingText[0]}", type="${dfn.type}", for="${dfn.for[0]}"`);
|
|
120
|
+
}
|
|
121
|
+
return first === dfn;
|
|
122
|
+
}
|
|
102
123
|
|
|
103
|
-
function definitionMapper(el, idToHeading) {
|
|
124
|
+
function definitionMapper(el, idToHeading, usesDfnDataModel) {
|
|
104
125
|
let definedIn = 'prose';
|
|
105
126
|
const enclosingEl = el.closest('dt,pre,table,h1,h2,h3,h4,h5,h6,.note,.example') || el;
|
|
106
127
|
switch (enclosingEl.nodeName) {
|
|
@@ -165,8 +186,10 @@ function definitionMapper(el, idToHeading) {
|
|
|
165
186
|
[],
|
|
166
187
|
|
|
167
188
|
// Definition is public if explicitly marked as exportable or if export has
|
|
168
|
-
// not been explicitly disallowed and its type is not "dfn"
|
|
169
|
-
|
|
189
|
+
// not been explicitly disallowed and its type is not "dfn", or if the spec
|
|
190
|
+
// is an old spec that does not use the "data-dfn-type" convention.
|
|
191
|
+
access: (!usesDfnDataModel ||
|
|
192
|
+
el.hasAttribute('data-export') ||
|
|
170
193
|
(!el.hasAttribute('data-noexport') &&
|
|
171
194
|
el.hasAttribute('data-dfn-type') &&
|
|
172
195
|
el.getAttribute('data-dfn-type') !== 'dfn')) ?
|
|
@@ -200,7 +223,6 @@ export default function (spec, idToHeading = {}) {
|
|
|
200
223
|
'h6[id][data-dfn-type]:not([data-lt=""])'
|
|
201
224
|
].join(',');
|
|
202
225
|
|
|
203
|
-
let extraDefinitions = [];
|
|
204
226
|
const shortname = (typeof spec === 'string') ? spec : spec.shortname;
|
|
205
227
|
switch (shortname) {
|
|
206
228
|
case "html":
|
|
@@ -214,7 +236,14 @@ export default function (spec, idToHeading = {}) {
|
|
|
214
236
|
break;
|
|
215
237
|
}
|
|
216
238
|
|
|
217
|
-
|
|
239
|
+
const definitions = [...document.querySelectorAll(definitionsSelector)];
|
|
240
|
+
const usesDfnDataModel = definitions.some(dfn =>
|
|
241
|
+
dfn.hasAttribute('data-dfn-type') ||
|
|
242
|
+
dfn.hasAttribute('data-dfn-for') ||
|
|
243
|
+
dfn.hasAttribute('data-export') ||
|
|
244
|
+
dfn.hasAttribute('data-noexport'));
|
|
245
|
+
|
|
246
|
+
return definitions
|
|
218
247
|
.map(node => {
|
|
219
248
|
// 2021-06-21: Temporary preprocessing of invalid "idl" dfn type (used for
|
|
220
249
|
// internal slots) while fix for https://github.com/w3c/respec/issues/3644
|
|
@@ -237,7 +266,8 @@ export default function (spec, idToHeading = {}) {
|
|
|
237
266
|
const link = node.querySelector('a[href^="http"]');
|
|
238
267
|
return !link || (node.textContent.trim() !== link.textContent.trim());
|
|
239
268
|
})
|
|
240
|
-
.map(node => definitionMapper(node, idToHeading))
|
|
269
|
+
.map(node => definitionMapper(node, idToHeading, usesDfnDataModel))
|
|
270
|
+
.filter(isNotAlreadyDefined);
|
|
241
271
|
}
|
|
242
272
|
|
|
243
273
|
function preProcessEcmascript() {
|
package/src/lib/nock-server.js
CHANGED
|
@@ -32,7 +32,7 @@ const mockSpecs = {
|
|
|
32
32
|
html: `
|
|
33
33
|
<title>WOFF2</title>
|
|
34
34
|
<body>
|
|
35
|
-
<dfn id='foo'>Foo</dfn>
|
|
35
|
+
<dfn id='foo' data-dfn-type="dfn">Foo</dfn>
|
|
36
36
|
<a href="https://www.w3.org/TR/bar/#baz">bar</a>
|
|
37
37
|
<ul class='toc'><li><a href='page.html'>page</a></ul>`,
|
|
38
38
|
pages: {
|