@orkestrel/guide 0.0.24 → 0.0.26
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/README.md +1 -1
- package/dist/src/core/index.cjs +696 -705
- package/dist/src/core/index.cjs.map +1 -1
- package/dist/src/core/index.d.cts +39 -4
- package/dist/src/core/index.d.ts +39 -4
- package/dist/src/core/index.js +696 -705
- package/dist/src/core/index.js.map +1 -1
- package/dist/src/server/index.cjs +10 -3598
- package/dist/src/server/index.cjs.map +1 -1
- package/dist/src/server/index.d.cts +6 -447
- package/dist/src/server/index.d.ts +6 -447
- package/dist/src/server/index.js +6 -3593
- package/dist/src/server/index.js.map +1 -1
- package/package.json +15 -15
package/dist/src/core/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { coalesceText, createMarkdown, flattenText, isBlockquoteNode, isCodeBlockNode, isCodeSpanNode, isEmphasisNode, isHeadingNode, isImageNode, isLinkNode, isParagraphNode, isTableNode, renderMarkdown, walkNodes } from "@orkestrel/markdown";
|
|
2
2
|
import { arrayOf, arrayShape, createContract, isEmptyString, isNonEmptyArray, isNonEmptyString, isString, literalOf, literalShape, objectShape, optionalShape, recordOf, stringShape, unionOf, unionShape } from "@orkestrel/contract";
|
|
3
|
-
|
|
3
|
+
// src/core/constants.ts
|
|
4
4
|
/**
|
|
5
5
|
* Lists the declaration keywords a documented or exported symbol carries, in the order the
|
|
6
6
|
* reflection grammar names them — the frozen population `ExportKeyword`, `isExportKeyword`, and
|
|
@@ -73,8 +73,7 @@ var EXTERNAL_SCHEMES = Object.freeze([
|
|
|
73
73
|
"mailto:",
|
|
74
74
|
"tel:"
|
|
75
75
|
]);
|
|
76
|
-
|
|
77
|
-
//#region src/core/validators.ts
|
|
76
|
+
// src/core/validators.ts
|
|
78
77
|
/**
|
|
79
78
|
* Checks whether `value` is one of the documented {@link ExportKeyword}
|
|
80
79
|
* literals — the guard behind extracting a Surface table's `Kind` cell into a
|
|
@@ -202,8 +201,7 @@ var isManifestEntry = recordOf({
|
|
|
202
201
|
source: unionOf(isString, arrayOf(isString)),
|
|
203
202
|
tests: isString
|
|
204
203
|
});
|
|
205
|
-
|
|
206
|
-
//#region src/core/helpers.ts
|
|
204
|
+
// src/core/helpers.ts
|
|
207
205
|
/**
|
|
208
206
|
* Extracts aligned physical source-line records in one character traversal.
|
|
209
207
|
* Real line and block comments and complete template tokens become spaces in
|
|
@@ -237,462 +235,468 @@ var isManifestEntry = recordOf({
|
|
|
237
235
|
*/
|
|
238
236
|
function extractSourceLines(source) {
|
|
239
237
|
const lines = [];
|
|
240
|
-
|
|
241
|
-
let jsdocCharacters = [];
|
|
238
|
+
const tokens = [];
|
|
242
239
|
const identifier = /#?[$_\p{ID_Start}][$_\u200C\u200D\p{ID_Continue}]*/uy;
|
|
243
|
-
const
|
|
244
|
-
const
|
|
245
|
-
|
|
246
|
-
let mode = "code";
|
|
247
|
-
let escaped = false;
|
|
248
|
-
let regexClass = false;
|
|
249
|
-
let operandExpected = true;
|
|
250
|
-
let memberExpected = false;
|
|
251
|
-
let pendingRole;
|
|
252
|
-
let restricted;
|
|
253
|
-
let separated = false;
|
|
254
|
-
let blockTemplate = false;
|
|
255
|
-
let lineTemplate = false;
|
|
256
|
-
let jsdoc = false;
|
|
257
|
-
let jsdocPresent = false;
|
|
258
|
-
for (let offset = 0; offset < source.length; offset += 1) {
|
|
259
|
-
const character = source[offset];
|
|
260
|
-
if (character === void 0) continue;
|
|
240
|
+
const numeric = /[A-Za-z0-9_$.]+/y;
|
|
241
|
+
const final = source.split("").reduce((state, character, offset) => {
|
|
242
|
+
if (offset < state.offset) return state;
|
|
261
243
|
const next = source[offset + 1];
|
|
262
244
|
const crlf = character === "\r" && next === "\n";
|
|
263
245
|
if (character === "\n" || crlf) {
|
|
264
|
-
const
|
|
265
|
-
const
|
|
246
|
+
const parts = tokens.slice(state.token);
|
|
247
|
+
const code = parts.map((part) => part.code).join("");
|
|
266
248
|
lines.push({
|
|
267
|
-
source: source.slice(start, offset),
|
|
249
|
+
source: source.slice(state.start, offset),
|
|
268
250
|
code,
|
|
269
|
-
jsdoc: present ?
|
|
251
|
+
jsdoc: state.present || state.jsdoc ? parts.map((part) => part.jsdoc ?? " ".repeat(part.code.length)).join("") : void 0
|
|
270
252
|
});
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
operandExpected = true;
|
|
291
|
-
regexClass = false;
|
|
292
|
-
} else if (mode === "single" || mode === "double") {
|
|
293
|
-
if (!escaped) {
|
|
294
|
-
mode = "code";
|
|
295
|
-
operandExpected = true;
|
|
296
|
-
}
|
|
297
|
-
} else if (mode === "templateSingle" || mode === "templateDouble") {
|
|
298
|
-
if (!escaped) {
|
|
299
|
-
mode = "templateCode";
|
|
300
|
-
operandExpected = true;
|
|
301
|
-
}
|
|
302
|
-
}
|
|
303
|
-
escaped = false;
|
|
304
|
-
continue;
|
|
305
|
-
}
|
|
306
|
-
if (mode === "line" || mode === "templateLine") {
|
|
307
|
-
characters.push(" ");
|
|
308
|
-
continue;
|
|
309
|
-
}
|
|
310
|
-
if (mode === "block" || mode === "templateBlock") {
|
|
311
|
-
characters.push(" ");
|
|
312
|
-
if (jsdoc) jsdocCharacters.push(character);
|
|
313
|
-
if (character === "*" && next === "/") {
|
|
314
|
-
characters.push(" ");
|
|
315
|
-
if (jsdoc) {
|
|
316
|
-
jsdocCharacters.push("/");
|
|
317
|
-
jsdoc = false;
|
|
318
|
-
}
|
|
319
|
-
offset += 1;
|
|
320
|
-
mode = blockTemplate ? "templateCode" : "code";
|
|
321
|
-
}
|
|
322
|
-
continue;
|
|
253
|
+
const regular = state.mode === "single" || state.mode === "double";
|
|
254
|
+
const quoted = state.mode === "templateSingle" || state.mode === "templateDouble";
|
|
255
|
+
const reset = state.mode === "regex" || state.mode === "templateLine" || state.mode === "templateRegex";
|
|
256
|
+
const mode = state.mode === "line" ? state.line ? "templateCode" : "code" : state.mode === "regex" ? "code" : state.mode === "templateLine" || state.mode === "templateRegex" ? "templateCode" : regular && !state.escaped ? "code" : quoted && !state.escaped ? "templateCode" : state.mode;
|
|
257
|
+
return {
|
|
258
|
+
...state,
|
|
259
|
+
offset: offset + (crlf ? 2 : 1),
|
|
260
|
+
start: offset + (crlf ? 2 : 1),
|
|
261
|
+
token: tokens.length,
|
|
262
|
+
mode,
|
|
263
|
+
escaped: false,
|
|
264
|
+
regex: reset ? false : state.regex,
|
|
265
|
+
operand: state.restricted !== void 0 || reset || (regular || quoted) && !state.escaped ? true : state.operand,
|
|
266
|
+
member: state.restricted !== void 0 ? false : state.member,
|
|
267
|
+
role: state.restricted !== void 0 ? void 0 : state.role,
|
|
268
|
+
restricted: void 0,
|
|
269
|
+
separated: state.mode !== "template" ? true : state.separated,
|
|
270
|
+
present: state.jsdoc
|
|
271
|
+
};
|
|
323
272
|
}
|
|
324
|
-
if (mode === "
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
escaped = false;
|
|
328
|
-
continue;
|
|
329
|
-
}
|
|
330
|
-
if (character === "\\") {
|
|
331
|
-
escaped = true;
|
|
332
|
-
continue;
|
|
333
|
-
}
|
|
334
|
-
if (mode === "single" && character === "'" || mode === "double" && character === "\"") {
|
|
335
|
-
mode = "code";
|
|
336
|
-
operandExpected = false;
|
|
337
|
-
}
|
|
338
|
-
continue;
|
|
273
|
+
if (state.mode === "line" || state.mode === "templateLine") {
|
|
274
|
+
tokens.push({ code: " " });
|
|
275
|
+
return state;
|
|
339
276
|
}
|
|
340
|
-
if (mode === "
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
}
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
else if (character === "/" && !regexClass) {
|
|
353
|
-
mode = "code";
|
|
354
|
-
operandExpected = false;
|
|
355
|
-
}
|
|
356
|
-
continue;
|
|
277
|
+
if (state.mode === "block" || state.mode === "templateBlock") {
|
|
278
|
+
const closes = character === "*" && next === "/";
|
|
279
|
+
tokens.push({
|
|
280
|
+
code: closes ? " " : " ",
|
|
281
|
+
...state.jsdoc ? { jsdoc: closes ? "*/" : character } : {}
|
|
282
|
+
});
|
|
283
|
+
return closes ? {
|
|
284
|
+
...state,
|
|
285
|
+
offset: offset + 2,
|
|
286
|
+
jsdoc: false,
|
|
287
|
+
mode: state.block ? "templateCode" : "code"
|
|
288
|
+
} : state;
|
|
357
289
|
}
|
|
358
|
-
if (mode === "templateSingle" || mode === "templateDouble") {
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
290
|
+
if (state.mode === "single" || state.mode === "double" || state.mode === "templateSingle" || state.mode === "templateDouble") {
|
|
291
|
+
const template = state.mode === "templateSingle" || state.mode === "templateDouble";
|
|
292
|
+
tokens.push({ code: template ? " " : character });
|
|
293
|
+
if (state.escaped) return {
|
|
294
|
+
...state,
|
|
295
|
+
escaped: false
|
|
296
|
+
};
|
|
297
|
+
if (character === "\\") return {
|
|
298
|
+
...state,
|
|
299
|
+
escaped: true
|
|
300
|
+
};
|
|
301
|
+
return (state.mode === "single" || state.mode === "templateSingle" ? character === "'" : character === "\"") ? {
|
|
302
|
+
...state,
|
|
303
|
+
mode: template ? "templateCode" : "code",
|
|
304
|
+
operand: false
|
|
305
|
+
} : state;
|
|
373
306
|
}
|
|
374
|
-
if (mode === "templateRegex") {
|
|
375
|
-
|
|
376
|
-
if (escaped) {
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
}
|
|
380
|
-
if (character === "\\") {
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
}
|
|
384
|
-
if (character === "[")
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
307
|
+
if (state.mode === "regex" || state.mode === "templateRegex") {
|
|
308
|
+
tokens.push({ code: state.mode === "templateRegex" ? " " : character });
|
|
309
|
+
if (state.escaped) return {
|
|
310
|
+
...state,
|
|
311
|
+
escaped: false
|
|
312
|
+
};
|
|
313
|
+
if (character === "\\") return {
|
|
314
|
+
...state,
|
|
315
|
+
escaped: true
|
|
316
|
+
};
|
|
317
|
+
if (character === "[") return {
|
|
318
|
+
...state,
|
|
319
|
+
regex: true
|
|
320
|
+
};
|
|
321
|
+
if (character === "]") return {
|
|
322
|
+
...state,
|
|
323
|
+
regex: false
|
|
324
|
+
};
|
|
325
|
+
if (character === "/" && !state.regex) return {
|
|
326
|
+
...state,
|
|
327
|
+
mode: state.mode === "templateRegex" ? "templateCode" : "code",
|
|
328
|
+
operand: false
|
|
329
|
+
};
|
|
330
|
+
return state;
|
|
391
331
|
}
|
|
392
|
-
if (mode === "template") {
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
332
|
+
if (state.mode === "template") {
|
|
333
|
+
const interpolation = !state.escaped && character === "$" && next === "{";
|
|
334
|
+
tokens.push({ code: interpolation ? " " : " " });
|
|
335
|
+
if (state.escaped) return {
|
|
336
|
+
...state,
|
|
337
|
+
escaped: false
|
|
338
|
+
};
|
|
339
|
+
if (character === "\\") return {
|
|
340
|
+
...state,
|
|
341
|
+
escaped: true
|
|
342
|
+
};
|
|
343
|
+
if (interpolation) return {
|
|
344
|
+
...state,
|
|
345
|
+
offset: offset + 2,
|
|
346
|
+
templates: state.templates === void 0 ? void 0 : {
|
|
347
|
+
...state.templates,
|
|
348
|
+
depth: 1
|
|
349
|
+
},
|
|
350
|
+
mode: "templateCode",
|
|
351
|
+
operand: true,
|
|
352
|
+
member: false,
|
|
353
|
+
role: void 0
|
|
354
|
+
};
|
|
413
355
|
if (character === "`") {
|
|
414
|
-
templates.
|
|
415
|
-
|
|
416
|
-
|
|
356
|
+
const templates = state.templates?.previous;
|
|
357
|
+
return {
|
|
358
|
+
...state,
|
|
359
|
+
templates,
|
|
360
|
+
mode: templates === void 0 ? "code" : "templateCode",
|
|
361
|
+
operand: false
|
|
362
|
+
};
|
|
417
363
|
}
|
|
418
|
-
|
|
364
|
+
return state;
|
|
419
365
|
}
|
|
420
|
-
const
|
|
366
|
+
const template = state.mode === "templateCode";
|
|
421
367
|
if (character === "/" && next === "/") {
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
368
|
+
tokens.push({ code: " " });
|
|
369
|
+
return {
|
|
370
|
+
...state,
|
|
371
|
+
offset: offset + 2,
|
|
372
|
+
line: template,
|
|
373
|
+
mode: template ? "templateLine" : "line"
|
|
374
|
+
};
|
|
427
375
|
}
|
|
428
376
|
if (character === "/" && next === "*") {
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
if (character === "'") {
|
|
443
|
-
characters.push(templateCode ? " " : character);
|
|
444
|
-
mode = templateCode ? "templateSingle" : "single";
|
|
445
|
-
escaped = false;
|
|
446
|
-
separated = false;
|
|
447
|
-
restricted = void 0;
|
|
448
|
-
continue;
|
|
449
|
-
}
|
|
450
|
-
if (character === "\"") {
|
|
451
|
-
characters.push(templateCode ? " " : character);
|
|
452
|
-
mode = templateCode ? "templateDouble" : "double";
|
|
453
|
-
escaped = false;
|
|
454
|
-
separated = false;
|
|
455
|
-
restricted = void 0;
|
|
456
|
-
continue;
|
|
377
|
+
const jsdoc = !template && source[offset + 2] === "*";
|
|
378
|
+
tokens.push({
|
|
379
|
+
code: " ",
|
|
380
|
+
...jsdoc ? { jsdoc: "/*" } : {}
|
|
381
|
+
});
|
|
382
|
+
return {
|
|
383
|
+
...state,
|
|
384
|
+
offset: offset + 2,
|
|
385
|
+
block: template,
|
|
386
|
+
mode: template ? "templateBlock" : "block",
|
|
387
|
+
jsdoc: jsdoc || state.jsdoc,
|
|
388
|
+
present: jsdoc || state.present
|
|
389
|
+
};
|
|
457
390
|
}
|
|
458
|
-
if (character === "`") {
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
391
|
+
if (character === "'" || character === "\"" || character === "`") {
|
|
392
|
+
tokens.push({ code: template || character === "`" ? " " : character });
|
|
393
|
+
return {
|
|
394
|
+
...state,
|
|
395
|
+
mode: character === "`" ? "template" : character === "'" ? template ? "templateSingle" : "single" : template ? "templateDouble" : "double",
|
|
396
|
+
templates: character === "`" ? {
|
|
397
|
+
depth: 0,
|
|
398
|
+
previous: state.templates
|
|
399
|
+
} : state.templates,
|
|
400
|
+
escaped: false,
|
|
401
|
+
separated: false,
|
|
402
|
+
restricted: void 0
|
|
403
|
+
};
|
|
466
404
|
}
|
|
467
|
-
const visible =
|
|
468
|
-
if (character === "/" && next === "=" && !
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
405
|
+
const visible = template ? " " : character;
|
|
406
|
+
if (character === "/" && next === "=" && !state.operand) {
|
|
407
|
+
tokens.push({ code: template ? " " : "/=" });
|
|
408
|
+
return {
|
|
409
|
+
...state,
|
|
410
|
+
offset: offset + 2,
|
|
411
|
+
operand: true,
|
|
412
|
+
member: false,
|
|
413
|
+
role: void 0,
|
|
414
|
+
separated: false,
|
|
415
|
+
restricted: void 0
|
|
416
|
+
};
|
|
477
417
|
}
|
|
478
418
|
if (character === "/") {
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
419
|
+
tokens.push({ code: visible });
|
|
420
|
+
return state.operand ? {
|
|
421
|
+
...state,
|
|
422
|
+
mode: template ? "templateRegex" : "regex",
|
|
423
|
+
escaped: false,
|
|
424
|
+
regex: false,
|
|
425
|
+
separated: false,
|
|
426
|
+
restricted: void 0
|
|
427
|
+
} : {
|
|
428
|
+
...state,
|
|
429
|
+
operand: true,
|
|
430
|
+
member: false,
|
|
431
|
+
role: void 0,
|
|
432
|
+
separated: false,
|
|
433
|
+
restricted: void 0
|
|
434
|
+
};
|
|
492
435
|
}
|
|
493
436
|
identifier.lastIndex = offset;
|
|
494
|
-
const
|
|
495
|
-
if (
|
|
496
|
-
const token =
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
if (
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
}
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
437
|
+
const matched = identifier.exec(source);
|
|
438
|
+
if (matched !== null) {
|
|
439
|
+
const token = matched[0];
|
|
440
|
+
tokens.push({ code: template ? " ".repeat(token.length) : token });
|
|
441
|
+
const stepped = {
|
|
442
|
+
...state,
|
|
443
|
+
offset: offset + token.length,
|
|
444
|
+
restricted: void 0,
|
|
445
|
+
separated: false
|
|
446
|
+
};
|
|
447
|
+
const frame = state.parentheses;
|
|
448
|
+
if (token.startsWith("#")) return {
|
|
449
|
+
...stepped,
|
|
450
|
+
operand: false,
|
|
451
|
+
member: false,
|
|
452
|
+
role: void 0
|
|
453
|
+
};
|
|
454
|
+
if (state.member) return {
|
|
455
|
+
...stepped,
|
|
456
|
+
member: false,
|
|
457
|
+
operand: false,
|
|
458
|
+
role: void 0
|
|
459
|
+
};
|
|
460
|
+
if (state.restricted === "label") return {
|
|
461
|
+
...stepped,
|
|
462
|
+
operand: false,
|
|
463
|
+
role: void 0,
|
|
464
|
+
restricted: "complete"
|
|
465
|
+
};
|
|
466
|
+
if (/^(?:if|while|with)$/.test(token)) return {
|
|
467
|
+
...stepped,
|
|
468
|
+
role: "statement",
|
|
469
|
+
operand: true
|
|
470
|
+
};
|
|
471
|
+
if (token === "for") return {
|
|
472
|
+
...stepped,
|
|
473
|
+
role: "for",
|
|
474
|
+
operand: true
|
|
475
|
+
};
|
|
476
|
+
if (token === "export") return {
|
|
477
|
+
...stepped,
|
|
478
|
+
role: "export",
|
|
479
|
+
operand: true
|
|
480
|
+
};
|
|
481
|
+
if (token === "default" && state.role === "export") return {
|
|
482
|
+
...stepped,
|
|
483
|
+
role: void 0,
|
|
484
|
+
operand: true
|
|
485
|
+
};
|
|
486
|
+
if (/^(?:switch|catch)$/.test(token)) return {
|
|
487
|
+
...stepped,
|
|
488
|
+
role: "block",
|
|
489
|
+
operand: true
|
|
490
|
+
};
|
|
491
|
+
if (token === "await" && state.role === "for") return {
|
|
492
|
+
...stepped,
|
|
493
|
+
operand: true
|
|
494
|
+
};
|
|
495
|
+
if (/^(?:return|throw|case|delete|void|typeof|new|await|yield|else|do|extends|in|instanceof)$/.test(token)) return {
|
|
496
|
+
...stepped,
|
|
497
|
+
role: void 0,
|
|
498
|
+
operand: true
|
|
499
|
+
};
|
|
500
|
+
if (/^(?:break|continue)$/.test(token)) return {
|
|
501
|
+
...stepped,
|
|
502
|
+
role: void 0,
|
|
503
|
+
operand: false,
|
|
504
|
+
restricted: "label"
|
|
505
|
+
};
|
|
506
|
+
if (token === "debugger") return {
|
|
507
|
+
...stepped,
|
|
508
|
+
role: void 0,
|
|
509
|
+
operand: false,
|
|
510
|
+
restricted: "complete"
|
|
511
|
+
};
|
|
512
|
+
if (token === "of" && frame?.role === "for" && frame.phase === "left" && !frame.binding && !state.operand) return {
|
|
513
|
+
...stepped,
|
|
514
|
+
parentheses: {
|
|
515
|
+
...frame,
|
|
516
|
+
phase: "right"
|
|
517
|
+
},
|
|
518
|
+
operand: true,
|
|
519
|
+
role: void 0
|
|
520
|
+
};
|
|
521
|
+
if (/^(?:const|let|var)$/.test(token) && frame?.role === "for" && frame.phase === "left") return {
|
|
522
|
+
...stepped,
|
|
523
|
+
parentheses: {
|
|
524
|
+
...frame,
|
|
525
|
+
binding: true
|
|
526
|
+
},
|
|
527
|
+
operand: true,
|
|
528
|
+
role: void 0
|
|
529
|
+
};
|
|
530
|
+
return {
|
|
531
|
+
...stepped,
|
|
532
|
+
parentheses: frame?.binding === true ? {
|
|
533
|
+
...frame,
|
|
534
|
+
binding: false
|
|
535
|
+
} : frame,
|
|
536
|
+
operand: false,
|
|
537
|
+
role: void 0
|
|
538
|
+
};
|
|
564
539
|
}
|
|
565
540
|
if (/[0-9]/.test(character)) {
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
separated = false;
|
|
579
|
-
offset = end - 1;
|
|
580
|
-
continue;
|
|
581
|
-
}
|
|
582
|
-
if (character === "!" && next === "=" && source[offset + 2] === "=" || character === "=" && next === "=" && source[offset + 2] === "=") {
|
|
583
|
-
characters.push(visible, templateCode ? " " : source.slice(offset + 1, offset + 3));
|
|
584
|
-
offset += 2;
|
|
585
|
-
operandExpected = true;
|
|
586
|
-
memberExpected = false;
|
|
587
|
-
pendingRole = void 0;
|
|
588
|
-
restricted = void 0;
|
|
589
|
-
separated = false;
|
|
590
|
-
continue;
|
|
541
|
+
numeric.lastIndex = offset;
|
|
542
|
+
const token = numeric.exec(source)?.[0] ?? character;
|
|
543
|
+
tokens.push({ code: template ? " ".repeat(token.length) : token });
|
|
544
|
+
return {
|
|
545
|
+
...state,
|
|
546
|
+
offset: offset + token.length,
|
|
547
|
+
operand: false,
|
|
548
|
+
member: false,
|
|
549
|
+
role: void 0,
|
|
550
|
+
restricted: void 0,
|
|
551
|
+
separated: false
|
|
552
|
+
};
|
|
591
553
|
}
|
|
592
554
|
if ((character === "!" || character === "=") && next === "=") {
|
|
593
|
-
|
|
594
|
-
offset
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
555
|
+
const width = source[offset + 2] === "=" ? 3 : 2;
|
|
556
|
+
tokens.push({ code: template ? " ".repeat(width) : source.slice(offset, offset + width) });
|
|
557
|
+
return {
|
|
558
|
+
...state,
|
|
559
|
+
offset: offset + width,
|
|
560
|
+
operand: true,
|
|
561
|
+
member: false,
|
|
562
|
+
role: void 0,
|
|
563
|
+
restricted: void 0,
|
|
564
|
+
separated: false
|
|
565
|
+
};
|
|
601
566
|
}
|
|
602
567
|
if (character === "+" && next === "+" || character === "-" && next === "-") {
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
568
|
+
tokens.push({ code: template ? " " : character + next });
|
|
569
|
+
return {
|
|
570
|
+
...state,
|
|
571
|
+
offset: offset + 2,
|
|
572
|
+
operand: state.separated ? true : state.operand,
|
|
573
|
+
member: false,
|
|
574
|
+
role: void 0,
|
|
575
|
+
restricted: void 0,
|
|
576
|
+
separated: false
|
|
577
|
+
};
|
|
611
578
|
}
|
|
612
579
|
if (character === "." && next === "." && source[offset + 2] === ".") {
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
580
|
+
tokens.push({ code: template ? " " : "..." });
|
|
581
|
+
return {
|
|
582
|
+
...state,
|
|
583
|
+
offset: offset + 3,
|
|
584
|
+
operand: true,
|
|
585
|
+
member: false,
|
|
586
|
+
role: void 0,
|
|
587
|
+
restricted: void 0,
|
|
588
|
+
separated: false
|
|
589
|
+
};
|
|
621
590
|
}
|
|
622
591
|
if (character === "?" && next === ".") {
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
592
|
+
tokens.push({ code: template ? " " : "?." });
|
|
593
|
+
return {
|
|
594
|
+
...state,
|
|
595
|
+
offset: offset + 2,
|
|
596
|
+
operand: false,
|
|
597
|
+
member: true,
|
|
598
|
+
role: void 0,
|
|
599
|
+
restricted: void 0,
|
|
600
|
+
separated: false
|
|
601
|
+
};
|
|
631
602
|
}
|
|
632
|
-
|
|
633
|
-
if (/\s/.test(character))
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
603
|
+
tokens.push({ code: visible });
|
|
604
|
+
if (/\s/.test(character)) return state;
|
|
605
|
+
const stepped = {
|
|
606
|
+
...state,
|
|
607
|
+
separated: false,
|
|
608
|
+
restricted: void 0,
|
|
609
|
+
role: void 0,
|
|
610
|
+
member: false
|
|
611
|
+
};
|
|
612
|
+
const frame = state.parentheses;
|
|
613
|
+
if (character === "(") return {
|
|
614
|
+
...stepped,
|
|
615
|
+
parentheses: {
|
|
616
|
+
role: state.role ?? "plain",
|
|
639
617
|
phase: "left",
|
|
640
|
-
binding: false
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
}
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
618
|
+
binding: false,
|
|
619
|
+
previous: frame
|
|
620
|
+
},
|
|
621
|
+
operand: true
|
|
622
|
+
};
|
|
623
|
+
if (character === ")") return {
|
|
624
|
+
...stepped,
|
|
625
|
+
parentheses: frame?.previous,
|
|
626
|
+
operand: frame?.role === "statement" || frame?.role === "for"
|
|
627
|
+
};
|
|
628
|
+
if (character === ";") return {
|
|
629
|
+
...stepped,
|
|
630
|
+
parentheses: frame?.role === "for" && frame.phase === "left" ? {
|
|
631
|
+
...frame,
|
|
632
|
+
phase: "classic"
|
|
633
|
+
} : frame,
|
|
634
|
+
operand: true
|
|
635
|
+
};
|
|
636
|
+
if (character === ".") return {
|
|
637
|
+
...stepped,
|
|
638
|
+
operand: false,
|
|
639
|
+
member: true
|
|
640
|
+
};
|
|
641
|
+
const parentheses = (character === "]" || character === "}") && frame?.role === "for" && frame.phase === "left" && frame.binding ? {
|
|
642
|
+
...frame,
|
|
643
|
+
binding: false
|
|
644
|
+
} : frame;
|
|
645
|
+
if (character === "]") return {
|
|
646
|
+
...stepped,
|
|
647
|
+
parentheses,
|
|
648
|
+
operand: false
|
|
649
|
+
};
|
|
650
|
+
const top = state.templates;
|
|
651
|
+
if (character === "}") return {
|
|
652
|
+
...stepped,
|
|
653
|
+
parentheses,
|
|
654
|
+
operand: false,
|
|
655
|
+
templates: template && top !== void 0 ? {
|
|
656
|
+
...top,
|
|
657
|
+
depth: top.depth - 1
|
|
658
|
+
} : top,
|
|
659
|
+
mode: template && top?.depth === 1 ? "template" : state.mode
|
|
660
|
+
};
|
|
661
|
+
if (character === "{") return {
|
|
662
|
+
...stepped,
|
|
663
|
+
parentheses,
|
|
664
|
+
operand: true,
|
|
665
|
+
templates: template && top !== void 0 ? {
|
|
666
|
+
...top,
|
|
667
|
+
depth: top.depth + 1
|
|
668
|
+
} : top
|
|
669
|
+
};
|
|
670
|
+
return {
|
|
671
|
+
...stepped,
|
|
672
|
+
parentheses,
|
|
673
|
+
operand: character !== "!" ? true : state.operand
|
|
674
|
+
};
|
|
675
|
+
}, {
|
|
676
|
+
offset: 0,
|
|
677
|
+
start: 0,
|
|
678
|
+
token: 0,
|
|
679
|
+
mode: "code",
|
|
680
|
+
escaped: false,
|
|
681
|
+
regex: false,
|
|
682
|
+
operand: true,
|
|
683
|
+
member: false,
|
|
684
|
+
role: void 0,
|
|
685
|
+
restricted: void 0,
|
|
686
|
+
separated: false,
|
|
687
|
+
block: false,
|
|
688
|
+
line: false,
|
|
689
|
+
jsdoc: false,
|
|
690
|
+
present: false,
|
|
691
|
+
parentheses: void 0,
|
|
692
|
+
templates: void 0
|
|
693
|
+
});
|
|
694
|
+
const parts = tokens.slice(final.token);
|
|
695
|
+
const code = parts.map((part) => part.code).join("");
|
|
692
696
|
lines.push({
|
|
693
|
-
source: source.slice(start),
|
|
697
|
+
source: source.slice(final.start),
|
|
694
698
|
code,
|
|
695
|
-
jsdoc: present ?
|
|
699
|
+
jsdoc: final.present || final.jsdoc ? parts.map((part) => part.jsdoc ?? " ".repeat(part.code.length)).join("") : void 0
|
|
696
700
|
});
|
|
697
701
|
return lines;
|
|
698
702
|
}
|
|
@@ -908,9 +912,7 @@ function findUnexampled(names, fences, examples) {
|
|
|
908
912
|
*/
|
|
909
913
|
function extractFenceImports(fence) {
|
|
910
914
|
const results = [];
|
|
911
|
-
const
|
|
912
|
-
let match;
|
|
913
|
-
while ((match = pattern.exec(fence)) !== null) {
|
|
915
|
+
for (const match of fence.matchAll(/import\s+(?:type\s+)?\{([^}]*)\}\s*from\s*['"]([^'"]+)['"]/gs)) {
|
|
914
916
|
const body = match[1];
|
|
915
917
|
const specifier = match[2];
|
|
916
918
|
if (body === void 0 || specifier === void 0) continue;
|
|
@@ -1067,11 +1069,11 @@ function normalizeIdentifier(code) {
|
|
|
1067
1069
|
* ```
|
|
1068
1070
|
*/
|
|
1069
1071
|
function extractCellText(cell) {
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1072
|
+
return Iterator.from(cell).map((node) => {
|
|
1073
|
+
if (isCodeSpanNode(node)) return `\`${node.value}\``;
|
|
1074
|
+
if (isEmphasisNode(node) || isLinkNode(node) || isImageNode(node)) return extractCellText(node.children);
|
|
1075
|
+
return flattenText(node);
|
|
1076
|
+
}).toArray().join("");
|
|
1075
1077
|
}
|
|
1076
1078
|
/**
|
|
1077
1079
|
* Builds one table cell's inline content from its compared text — the inverse of
|
|
@@ -1100,26 +1102,22 @@ function extractCellText(cell) {
|
|
|
1100
1102
|
*/
|
|
1101
1103
|
function buildCell(text) {
|
|
1102
1104
|
const nodes = [];
|
|
1103
|
-
const
|
|
1104
|
-
let cursor = 0;
|
|
1105
|
-
let span;
|
|
1106
|
-
while ((span = spans.exec(text)) !== null) {
|
|
1105
|
+
const cursor = Iterator.from(text.matchAll(/`([^`]+)`/g)).reduce((previous, span) => {
|
|
1107
1106
|
const value = span[1];
|
|
1108
|
-
if (value === void 0)
|
|
1109
|
-
if (span.index >
|
|
1107
|
+
if (value === void 0) return previous;
|
|
1108
|
+
if (span.index > previous) nodes.push({
|
|
1110
1109
|
element: "text",
|
|
1111
|
-
value: text.slice(
|
|
1110
|
+
value: text.slice(previous, span.index)
|
|
1112
1111
|
});
|
|
1113
|
-
|
|
1112
|
+
nodes.push(value.trim() === value ? {
|
|
1114
1113
|
element: "codeSpan",
|
|
1115
1114
|
value
|
|
1116
|
-
}
|
|
1117
|
-
else nodes.push({
|
|
1115
|
+
} : {
|
|
1118
1116
|
element: "text",
|
|
1119
1117
|
value: span[0]
|
|
1120
1118
|
});
|
|
1121
|
-
|
|
1122
|
-
}
|
|
1119
|
+
return span.index + span[0].length;
|
|
1120
|
+
}, 0);
|
|
1123
1121
|
if (cursor < text.length) nodes.push({
|
|
1124
1122
|
element: "text",
|
|
1125
1123
|
value: text.slice(cursor)
|
|
@@ -1143,7 +1141,7 @@ function buildCell(text) {
|
|
|
1143
1141
|
* ```
|
|
1144
1142
|
*/
|
|
1145
1143
|
function findColumnIndex(table, header) {
|
|
1146
|
-
for (
|
|
1144
|
+
for (const index of table.header.keys()) {
|
|
1147
1145
|
const cell = table.header[index];
|
|
1148
1146
|
if (cell !== void 0 && flattenText({
|
|
1149
1147
|
element: "paragraph",
|
|
@@ -1266,7 +1264,10 @@ function extractHidden(source) {
|
|
|
1266
1264
|
*/
|
|
1267
1265
|
function joinHead(lines, start) {
|
|
1268
1266
|
const parts = [];
|
|
1269
|
-
for (
|
|
1267
|
+
for (const distance of Array.prototype.keys.call({ get length() {
|
|
1268
|
+
return Math.max(0, Math.ceil(lines.length - start));
|
|
1269
|
+
} })) {
|
|
1270
|
+
const index = start + distance;
|
|
1270
1271
|
const line = lines[index];
|
|
1271
1272
|
if (line === void 0) break;
|
|
1272
1273
|
const text = line.trimEnd();
|
|
@@ -1342,7 +1343,7 @@ function collectDeclarations(source) {
|
|
|
1342
1343
|
const grammar = /^export (class|interface) ([^\s<]+)(?:<.*>)?(?: .*)? \{(?:\s*\})?$/;
|
|
1343
1344
|
const lines = extractSourceLines(source);
|
|
1344
1345
|
const projected = lines.map((line) => line.code);
|
|
1345
|
-
for (
|
|
1346
|
+
for (const index of projected.keys()) {
|
|
1346
1347
|
const line = projected[index];
|
|
1347
1348
|
if (line === void 0 || !opener.test(line)) continue;
|
|
1348
1349
|
const head = joinHead(projected, index);
|
|
@@ -1354,12 +1355,14 @@ function collectDeclarations(source) {
|
|
|
1354
1355
|
const key = `${keyword} ${name}`;
|
|
1355
1356
|
const known = declarations.get(key);
|
|
1356
1357
|
if (known !== void 0 && (known.body.length > 0 || known.bases.length > 0)) continue;
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1358
|
+
const visible = [];
|
|
1359
|
+
Iterator.from(head.text.slice(`export ${key}`.length, head.text.lastIndexOf("{"))).reduce((depth, character) => {
|
|
1360
|
+
if (character === "<") return depth + 1;
|
|
1361
|
+
if (character === ">") return Math.max(0, depth - 1);
|
|
1362
|
+
if (depth === 0) visible.push(character);
|
|
1363
|
+
return depth;
|
|
1364
|
+
}, 0);
|
|
1365
|
+
const clause = visible.join("").replace(/\bimplements\b[\s\S]*$/, "").match(/\bextends\b([\s\S]*)$/)?.[1];
|
|
1363
1366
|
const bases = clause === void 0 ? [] : clause.split(",").map((base) => base.trim()).filter(isNonEmptyString);
|
|
1364
1367
|
if (head.text.endsWith("}")) {
|
|
1365
1368
|
declarations.set(key, {
|
|
@@ -1368,14 +1371,11 @@ function collectDeclarations(source) {
|
|
|
1368
1371
|
});
|
|
1369
1372
|
continue;
|
|
1370
1373
|
}
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
});
|
|
1377
|
-
break;
|
|
1378
|
-
}
|
|
1374
|
+
const close = Array.prototype.keys.call({ length: projected.length - head.end - 1 }).map((distance) => head.end + 1 + distance).find((candidate) => projected[candidate] === "}");
|
|
1375
|
+
if (close !== void 0) declarations.set(key, {
|
|
1376
|
+
body: lines.slice(head.end + 1, close).map((record) => record.source),
|
|
1377
|
+
bases
|
|
1378
|
+
});
|
|
1379
1379
|
}
|
|
1380
1380
|
return declarations;
|
|
1381
1381
|
}
|
|
@@ -1460,19 +1460,27 @@ function extractMemberMethods(lines) {
|
|
|
1460
1460
|
* ```
|
|
1461
1461
|
*/
|
|
1462
1462
|
function selectSectionBlocks(document, heading) {
|
|
1463
|
-
const
|
|
1464
|
-
let active = false;
|
|
1463
|
+
const scanned = [];
|
|
1465
1464
|
for (const block of document.children) {
|
|
1465
|
+
const active = scanned.at(-1)?.active ?? false;
|
|
1466
1466
|
if (isHeadingNode(block) && block.level <= 2) {
|
|
1467
1467
|
if (block.level === 2 && flattenText(block).trim() === heading) {
|
|
1468
|
-
|
|
1468
|
+
scanned.push({
|
|
1469
|
+
block,
|
|
1470
|
+
active: true,
|
|
1471
|
+
heading: true
|
|
1472
|
+
});
|
|
1469
1473
|
continue;
|
|
1470
1474
|
}
|
|
1471
1475
|
if (active) break;
|
|
1472
1476
|
}
|
|
1473
|
-
|
|
1477
|
+
scanned.push({
|
|
1478
|
+
block,
|
|
1479
|
+
active,
|
|
1480
|
+
heading: false
|
|
1481
|
+
});
|
|
1474
1482
|
}
|
|
1475
|
-
return
|
|
1483
|
+
return scanned.filter((entry) => entry.active && !entry.heading).map((entry) => entry.block);
|
|
1476
1484
|
}
|
|
1477
1485
|
/**
|
|
1478
1486
|
* Extracts one `## Surface` table row's symbol — its column 0 code span as the name, its
|
|
@@ -1590,7 +1598,7 @@ function extractSurface(document) {
|
|
|
1590
1598
|
const seen = /* @__PURE__ */ new Set();
|
|
1591
1599
|
for (const block of selectSectionBlocks(document, SURFACE)) {
|
|
1592
1600
|
if (isTableNode(block)) {
|
|
1593
|
-
for (
|
|
1601
|
+
for (const row of block.rows.keys()) {
|
|
1594
1602
|
const symbol = extractRowSymbol(block, row);
|
|
1595
1603
|
if (symbol === void 0) continue;
|
|
1596
1604
|
const key = computeSymbolKey(symbol);
|
|
@@ -1634,7 +1642,7 @@ function extractMethods(document) {
|
|
|
1634
1642
|
const groups = [];
|
|
1635
1643
|
for (const [table, name] of collectGroups(document)) {
|
|
1636
1644
|
const methods = [];
|
|
1637
|
-
for (
|
|
1645
|
+
for (const row of table.rows.keys()) {
|
|
1638
1646
|
const entry = extractRowEntry(table, row);
|
|
1639
1647
|
if (entry !== void 0) methods.push(entry);
|
|
1640
1648
|
}
|
|
@@ -1661,20 +1669,19 @@ function extractMethods(document) {
|
|
|
1661
1669
|
* ```
|
|
1662
1670
|
*/
|
|
1663
1671
|
function collectGroups(document) {
|
|
1664
|
-
const groups =
|
|
1665
|
-
|
|
1666
|
-
for (const block of selectSectionBlocks(document, METHODS)) {
|
|
1672
|
+
const groups = [];
|
|
1673
|
+
selectSectionBlocks(document, METHODS).reduce((current, block) => {
|
|
1667
1674
|
if (isHeadingNode(block) && block.level === 4) {
|
|
1668
|
-
const
|
|
1669
|
-
|
|
1670
|
-
continue;
|
|
1675
|
+
const name = findFirstCode(block.children);
|
|
1676
|
+
return name === void 0 ? void 0 : normalizeIdentifier(name);
|
|
1671
1677
|
}
|
|
1672
1678
|
if (isTableNode(block) && current !== void 0) {
|
|
1673
|
-
groups.
|
|
1674
|
-
|
|
1679
|
+
groups.push([block, current]);
|
|
1680
|
+
return;
|
|
1675
1681
|
}
|
|
1676
|
-
|
|
1677
|
-
|
|
1682
|
+
return current;
|
|
1683
|
+
}, void 0);
|
|
1684
|
+
return new Map(groups);
|
|
1678
1685
|
}
|
|
1679
1686
|
/**
|
|
1680
1687
|
* Extracts every `## Surface` or `## Methods` table row whose first cell carries no code span.
|
|
@@ -1827,18 +1834,11 @@ function unwrapComment(comment) {
|
|
|
1827
1834
|
* ```
|
|
1828
1835
|
*/
|
|
1829
1836
|
function normalizeSummary(text) {
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
for (let index = 0; index < parts.length; index += 1) {
|
|
1833
|
-
const part = parts[index] ?? "";
|
|
1834
|
-
if (index % 2 === 0) {
|
|
1835
|
-
normalized += part.replace(/\{@link\s+[^}|]*\|\s*([^}]*?)\s*\}/g, "`$1`").replace(/\{@link\s+(?:import\([^)]*\)\.|[^}|#\s]*[@/][^}|#\s]*#)?([^}|]*?)\s*\}/g, "`$1`");
|
|
1836
|
-
continue;
|
|
1837
|
-
}
|
|
1837
|
+
return text.split(/((?<!`)`[^`]+`(?!`))/).map((part, index) => {
|
|
1838
|
+
if (index % 2 === 0) return part.replace(/\{@link\s+[^}|]*\|\s*([^}]*?)\s*\}/g, "`$1`").replace(/\{@link\s+(?:import\([^)]*\)\.|[^}|#\s]*[@/][^}|#\s]*#)?([^}|]*?)\s*\}/g, "`$1`");
|
|
1838
1839
|
const value = part.slice(1, -1).replace(/\s+/g, " ").trim();
|
|
1839
|
-
|
|
1840
|
-
}
|
|
1841
|
-
return normalized.replace(/\s+/g, " ").trim();
|
|
1840
|
+
return `\`${value.length === 0 ? " " : value}\``;
|
|
1841
|
+
}).join("").replace(/\s+/g, " ").trim();
|
|
1842
1842
|
}
|
|
1843
1843
|
/**
|
|
1844
1844
|
* Wraps one paragraph into greedy lines no longer than `width` characters. Every run of
|
|
@@ -1855,18 +1855,27 @@ function normalizeSummary(text) {
|
|
|
1855
1855
|
* ```
|
|
1856
1856
|
*/
|
|
1857
1857
|
function wrapText(text, width) {
|
|
1858
|
+
const words = text.split(/\s+/).filter((word) => word.length > 0);
|
|
1858
1859
|
const lines = [];
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
}
|
|
1868
|
-
|
|
1869
|
-
|
|
1860
|
+
const final = words.reduce((previous, word, index) => {
|
|
1861
|
+
if (index === previous.start) return {
|
|
1862
|
+
start: index,
|
|
1863
|
+
length: word.length
|
|
1864
|
+
};
|
|
1865
|
+
if (previous.length + 1 + word.length <= width) return {
|
|
1866
|
+
start: previous.start,
|
|
1867
|
+
length: previous.length + 1 + word.length
|
|
1868
|
+
};
|
|
1869
|
+
lines.push(words.slice(previous.start, index).join(" "));
|
|
1870
|
+
return {
|
|
1871
|
+
start: index,
|
|
1872
|
+
length: word.length
|
|
1873
|
+
};
|
|
1874
|
+
}, {
|
|
1875
|
+
start: 0,
|
|
1876
|
+
length: 0
|
|
1877
|
+
});
|
|
1878
|
+
if (words.length > 0) lines.push(words.slice(final.start).join(" "));
|
|
1870
1879
|
return lines;
|
|
1871
1880
|
}
|
|
1872
1881
|
/**
|
|
@@ -1911,18 +1920,16 @@ function buildComment(lines, indent) {
|
|
|
1911
1920
|
*/
|
|
1912
1921
|
function maskFences(text) {
|
|
1913
1922
|
const masked = [];
|
|
1914
|
-
|
|
1915
|
-
for (const line of text.split("\n")) {
|
|
1923
|
+
text.split("\n").reduce((marker, line) => {
|
|
1916
1924
|
const fence = /^[ \t]*(`{3,}|~{3,})/.exec(line)?.[1];
|
|
1917
1925
|
if (marker === void 0) {
|
|
1918
1926
|
masked.push(line);
|
|
1919
|
-
|
|
1920
|
-
continue;
|
|
1927
|
+
return fence;
|
|
1921
1928
|
}
|
|
1922
|
-
const
|
|
1923
|
-
masked.push(
|
|
1924
|
-
|
|
1925
|
-
}
|
|
1929
|
+
const closed = fence !== void 0 && fence.startsWith(marker);
|
|
1930
|
+
masked.push(closed ? line : " ".repeat(line.length));
|
|
1931
|
+
return closed ? void 0 : marker;
|
|
1932
|
+
}, void 0);
|
|
1926
1933
|
return masked.join("\n");
|
|
1927
1934
|
}
|
|
1928
1935
|
/**
|
|
@@ -1948,67 +1955,67 @@ function maskFences(text) {
|
|
|
1948
1955
|
*/
|
|
1949
1956
|
function extractSourceComments(lines) {
|
|
1950
1957
|
const comments = [];
|
|
1951
|
-
|
|
1952
|
-
let eligible = false;
|
|
1953
|
-
let span = [];
|
|
1954
|
-
let pending;
|
|
1955
|
-
for (const line of lines) {
|
|
1958
|
+
Iterator.from(lines).reduce((previous, line) => {
|
|
1956
1959
|
const projection = line.jsdoc;
|
|
1957
1960
|
const first = projection?.indexOf("/**") ?? -1;
|
|
1958
|
-
if (pending !== void 0) {
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
if (block)
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
|
|
1961
|
+
if (previous.pending !== void 0 && !(!previous.block && first >= 0 && line.source.slice(0, first).trim() === "")) comments.push({
|
|
1962
|
+
text: previous.pending,
|
|
1963
|
+
line
|
|
1964
|
+
});
|
|
1965
|
+
const state = {
|
|
1966
|
+
...previous,
|
|
1967
|
+
pending: void 0
|
|
1968
|
+
};
|
|
1969
|
+
if (projection === void 0) return state;
|
|
1970
|
+
const close = state.block ? projection.indexOf("*/") : -1;
|
|
1971
|
+
const end = close < 0 ? projection.length : close + 2;
|
|
1972
|
+
if (state.block) state.span.push(projection.slice(0, end));
|
|
1973
|
+
if (state.block && close < 0) return state;
|
|
1974
|
+
const opener = state.block ? projection.indexOf("/**", close + 2) : first;
|
|
1975
|
+
const whitespace = state.block ? line.source.slice(close + 2, opener < 0 ? line.source.length : opener).trim() === "" : line.source.slice(0, first).trim() === "";
|
|
1976
|
+
const eligible = state.block ? state.eligible && whitespace : whitespace;
|
|
1977
|
+
if (opener < 0) return state.block ? {
|
|
1978
|
+
...state,
|
|
1979
|
+
block: false,
|
|
1980
|
+
pending: eligible ? normalizeComment(state.span.join("\n")) : void 0
|
|
1981
|
+
} : state;
|
|
1982
|
+
const spans = /\/\*(?=\*)[\s\S]*?(?:\*\/|$)/g;
|
|
1983
|
+
spans.lastIndex = opener;
|
|
1984
|
+
return Iterator.from(projection.matchAll(spans)).reduce((current, match) => {
|
|
1985
|
+
const cursor = match.index;
|
|
1986
|
+
const closing = projection.indexOf("*/", cursor + 2);
|
|
1987
|
+
const finish = closing < 0 ? projection.length : closing + 2;
|
|
1988
|
+
const span = [projection.slice(cursor, finish)];
|
|
1989
|
+
if (closing < 0) return {
|
|
1990
|
+
...current,
|
|
1991
|
+
span,
|
|
1992
|
+
block: true
|
|
1993
|
+
};
|
|
1994
|
+
const next = projection.indexOf("/**", closing + 2);
|
|
1995
|
+
const gap = line.source.slice(closing + 2, next < 0 ? line.source.length : next).trim() === "";
|
|
1996
|
+
if (next < 0) return {
|
|
1997
|
+
...current,
|
|
1998
|
+
span,
|
|
1999
|
+
block: false,
|
|
2000
|
+
pending: current.eligible && gap ? normalizeComment(span.join("\n")) : void 0
|
|
2001
|
+
};
|
|
2002
|
+
return {
|
|
2003
|
+
...current,
|
|
2004
|
+
span,
|
|
2005
|
+
block: false,
|
|
2006
|
+
eligible: current.eligible && gap
|
|
2007
|
+
};
|
|
2008
|
+
}, {
|
|
2009
|
+
...state,
|
|
2010
|
+
block: false,
|
|
2011
|
+
eligible
|
|
2012
|
+
});
|
|
2013
|
+
}, {
|
|
2014
|
+
block: false,
|
|
2015
|
+
eligible: false,
|
|
2016
|
+
span: [],
|
|
2017
|
+
pending: void 0
|
|
2018
|
+
});
|
|
2012
2019
|
return comments;
|
|
2013
2020
|
}
|
|
2014
2021
|
/**
|
|
@@ -2107,28 +2114,24 @@ function extractBodyLines(lines) {
|
|
|
2107
2114
|
* ```
|
|
2108
2115
|
*/
|
|
2109
2116
|
function collectKeys(lines) {
|
|
2110
|
-
const keys =
|
|
2111
|
-
|
|
2112
|
-
for (const line of lines) {
|
|
2117
|
+
const keys = [];
|
|
2118
|
+
Iterator.from(lines).reduce((owner, line) => {
|
|
2113
2119
|
const head = /^export (?:async )?(?:abstract )?(function\*?|class|const|interface|type) (\w+)/.exec(line.code);
|
|
2114
2120
|
const keyword = head?.[1]?.replace(/\*$/, "");
|
|
2115
2121
|
const name = head?.[2];
|
|
2116
2122
|
if (isNonEmptyString(keyword) && isNonEmptyString(name) && isExportKeyword(keyword)) {
|
|
2117
|
-
keys.
|
|
2123
|
+
keys.push([line, computeSymbolKey({
|
|
2118
2124
|
name,
|
|
2119
2125
|
keyword
|
|
2120
|
-
}));
|
|
2121
|
-
|
|
2122
|
-
continue;
|
|
2123
|
-
}
|
|
2124
|
-
if (line.code === "}") {
|
|
2125
|
-
owner = void 0;
|
|
2126
|
-
continue;
|
|
2126
|
+
})]);
|
|
2127
|
+
return keyword === "class" || keyword === "interface" ? name : void 0;
|
|
2127
2128
|
}
|
|
2129
|
+
if (line.code === "}") return void 0;
|
|
2128
2130
|
const member = /^\t(?:async )?\*?(\w+)\??(?:<.*>)?\(/.exec(line.code)?.[1];
|
|
2129
|
-
if (owner !== void 0 && isNonEmptyString(member)) keys.
|
|
2130
|
-
|
|
2131
|
-
|
|
2131
|
+
if (owner !== void 0 && isNonEmptyString(member)) keys.push([line, `${owner}.${member}`]);
|
|
2132
|
+
return owner;
|
|
2133
|
+
}, void 0);
|
|
2134
|
+
return new Map(keys);
|
|
2132
2135
|
}
|
|
2133
2136
|
/**
|
|
2134
2137
|
* Collects the `@example` blocks one doc block's unwrapped text carries, each named for the
|
|
@@ -2149,9 +2152,7 @@ function collectKeys(lines) {
|
|
|
2149
2152
|
function collectExamples(comment, name) {
|
|
2150
2153
|
const examples = [];
|
|
2151
2154
|
const masked = maskFences(comment);
|
|
2152
|
-
const
|
|
2153
|
-
let tag;
|
|
2154
|
-
while ((tag = tags.exec(masked)) !== null) {
|
|
2155
|
+
for (const tag of masked.matchAll(/^[ \t]*@example(?=[ \t]|$)[ \t]*(.*)$/gm)) {
|
|
2155
2156
|
const title = (tag[1] ?? "").trim();
|
|
2156
2157
|
const start = tag.index + tag[0].length;
|
|
2157
2158
|
const rest = comment.slice(start).replace(/^\n/, "");
|
|
@@ -2276,20 +2277,17 @@ function extractFences(document) {
|
|
|
2276
2277
|
* ```
|
|
2277
2278
|
*/
|
|
2278
2279
|
function collectFences(document) {
|
|
2279
|
-
const fences =
|
|
2280
|
-
|
|
2281
|
-
|
|
2282
|
-
if (
|
|
2283
|
-
title = flattenText(node).trim();
|
|
2284
|
-
continue;
|
|
2285
|
-
}
|
|
2286
|
-
if (isCodeBlockNode(node)) fences.set(node, {
|
|
2280
|
+
const fences = [];
|
|
2281
|
+
Iterator.from(walkNodes(document)).reduce((title, node) => {
|
|
2282
|
+
if (isHeadingNode(node)) return flattenText(node).trim();
|
|
2283
|
+
if (isCodeBlockNode(node)) fences.push([node, {
|
|
2287
2284
|
language: node.lang,
|
|
2288
2285
|
code: node.code,
|
|
2289
2286
|
...title.length === 0 ? {} : { title }
|
|
2290
|
-
});
|
|
2291
|
-
|
|
2292
|
-
|
|
2287
|
+
}]);
|
|
2288
|
+
return title;
|
|
2289
|
+
}, "");
|
|
2290
|
+
return new Map(fences);
|
|
2293
2291
|
}
|
|
2294
2292
|
/**
|
|
2295
2293
|
* Extracts the guide's tagline — the text of the blockquote following the document's H1,
|
|
@@ -2305,17 +2303,30 @@ function collectFences(document) {
|
|
|
2305
2303
|
* ```
|
|
2306
2304
|
*/
|
|
2307
2305
|
function extractTagline(document) {
|
|
2308
|
-
|
|
2306
|
+
const scanned = [];
|
|
2309
2307
|
for (const block of document.children) {
|
|
2308
|
+
const opened = scanned.at(-1)?.opened ?? false;
|
|
2310
2309
|
if (isHeadingNode(block)) {
|
|
2311
|
-
if (opened)
|
|
2312
|
-
|
|
2310
|
+
if (opened) break;
|
|
2311
|
+
scanned.push({
|
|
2312
|
+
block,
|
|
2313
|
+
opened: block.level === 1,
|
|
2314
|
+
selected: void 0
|
|
2315
|
+
});
|
|
2313
2316
|
continue;
|
|
2314
2317
|
}
|
|
2315
|
-
|
|
2316
|
-
|
|
2317
|
-
|
|
2318
|
+
const selected = opened && isBlockquoteNode(block) ? block : void 0;
|
|
2319
|
+
scanned.push({
|
|
2320
|
+
block,
|
|
2321
|
+
opened,
|
|
2322
|
+
selected
|
|
2323
|
+
});
|
|
2324
|
+
if (selected !== void 0) break;
|
|
2318
2325
|
}
|
|
2326
|
+
const selected = scanned.find((entry) => entry.selected !== void 0)?.selected;
|
|
2327
|
+
if (selected === void 0) return void 0;
|
|
2328
|
+
const text = normalizeSummary(selected.children.filter(isParagraphNode).map((paragraph) => extractCellText(paragraph.children)).join(" "));
|
|
2329
|
+
return text.length === 0 ? void 0 : text;
|
|
2319
2330
|
}
|
|
2320
2331
|
/**
|
|
2321
2332
|
* Computes the drift between one compared key's guide text and source text. A pair agrees
|
|
@@ -2736,33 +2747,26 @@ function renderExample(example) {
|
|
|
2736
2747
|
function replaceCell(guide, key, summary) {
|
|
2737
2748
|
const markdown = createMarkdown(guide);
|
|
2738
2749
|
const document = markdown.document;
|
|
2739
|
-
|
|
2740
|
-
|
|
2741
|
-
|
|
2742
|
-
|
|
2743
|
-
|
|
2744
|
-
|
|
2745
|
-
|
|
2746
|
-
|
|
2747
|
-
|
|
2748
|
-
|
|
2749
|
-
|
|
2750
|
-
|
|
2751
|
-
|
|
2752
|
-
|
|
2753
|
-
|
|
2754
|
-
if (entry === void 0 || `${owner}.${entry.name}` !== key) continue;
|
|
2755
|
-
located = table;
|
|
2756
|
-
index = row;
|
|
2757
|
-
}
|
|
2758
|
-
}
|
|
2759
|
-
if (located === void 0) return void 0;
|
|
2760
|
-
const column = findColumnIndex(located, SUMMARY);
|
|
2750
|
+
const surface = Iterator.from(selectSectionBlocks(document, SURFACE)).filter(isTableNode).flatMap((table) => table.rows.keys().map((index) => ({
|
|
2751
|
+
table,
|
|
2752
|
+
index,
|
|
2753
|
+
symbol: extractRowSymbol(table, index)
|
|
2754
|
+
}))).find((row) => row.symbol !== void 0 && computeSymbolKey(row.symbol) === key);
|
|
2755
|
+
const groups = collectGroups(document);
|
|
2756
|
+
const selected = surface ?? Iterator.from(groups).flatMap(([table, owner]) => table.rows.keys().map((index) => ({
|
|
2757
|
+
table,
|
|
2758
|
+
index,
|
|
2759
|
+
owner,
|
|
2760
|
+
entry: extractRowEntry(table, index)
|
|
2761
|
+
}))).find((row) => row.entry !== void 0 && `${row.owner}.${row.entry.name}` === key);
|
|
2762
|
+
if (selected === void 0) return void 0;
|
|
2763
|
+
const { table, index } = selected;
|
|
2764
|
+
const column = findColumnIndex(table, SUMMARY);
|
|
2761
2765
|
if (column === void 0) return void 0;
|
|
2762
|
-
if ((extractRowSummary(
|
|
2763
|
-
const span = markdown.span(
|
|
2766
|
+
if ((extractRowSummary(table, index) ?? "") === normalizeSummary(summary)) return guide;
|
|
2767
|
+
const span = markdown.span(table);
|
|
2764
2768
|
if (span === void 0) return void 0;
|
|
2765
|
-
return spliceSpan(guide, span, renderMarkdown(buildTable(
|
|
2769
|
+
return spliceSpan(guide, span, renderMarkdown(buildTable(table, index, column, summary)));
|
|
2766
2770
|
}
|
|
2767
2771
|
/**
|
|
2768
2772
|
* Replaces one titled fence in a guide's text and returns the whole guide back. The first fence
|
|
@@ -2791,14 +2795,9 @@ function replaceCell(guide, key, summary) {
|
|
|
2791
2795
|
*/
|
|
2792
2796
|
function replaceFence(guide, title, example) {
|
|
2793
2797
|
const markdown = createMarkdown(guide);
|
|
2794
|
-
|
|
2795
|
-
|
|
2796
|
-
|
|
2797
|
-
if (located !== void 0 || fence.title !== title) continue;
|
|
2798
|
-
located = node;
|
|
2799
|
-
current = fence;
|
|
2800
|
-
}
|
|
2801
|
-
if (located === void 0 || current === void 0) return void 0;
|
|
2798
|
+
const selected = Iterator.from(collectFences(markdown.document)).find(([, fence]) => fence.title === title);
|
|
2799
|
+
if (selected === void 0) return void 0;
|
|
2800
|
+
const [located, current] = selected;
|
|
2802
2801
|
if (current.code === example.code && current.language === example.language) return guide;
|
|
2803
2802
|
const span = markdown.span(located);
|
|
2804
2803
|
if (span === void 0) return void 0;
|
|
@@ -2848,9 +2847,7 @@ function replaceSummary(comment, summary, width = 100) {
|
|
|
2848
2847
|
const indent = /^[ \t]*/.exec(comment)?.[0] ?? "";
|
|
2849
2848
|
const wrapped = wrapText(summary, width - indent.length - 3);
|
|
2850
2849
|
if (wrapped.length === 0) return void 0;
|
|
2851
|
-
const
|
|
2852
|
-
let tag = -1;
|
|
2853
|
-
for (let index = 0; index < masked.length && tag < 0; index += 1) if (/^[ \t]*@\w/.test(masked[index] ?? "")) tag = index;
|
|
2850
|
+
const tag = maskFences(content.join("\n")).split("\n").findIndex((line) => /^[ \t]*@\w/.test(line));
|
|
2854
2851
|
if (normalizeSummary(content.slice(0, tag < 0 ? content.length : tag).join("\n")) === normalizeSummary(summary)) return comment;
|
|
2855
2852
|
const tail = tag < 0 ? [] : content.slice(tag);
|
|
2856
2853
|
if (tail.length === 0 && wrapped.length === 1 && content.length === 1) {
|
|
@@ -2906,17 +2903,17 @@ function replaceExample(comment, example) {
|
|
|
2906
2903
|
const content = unwrapComment(comment);
|
|
2907
2904
|
const masked = maskFences(content.join("\n")).split("\n");
|
|
2908
2905
|
const title = example.title ?? "";
|
|
2909
|
-
|
|
2910
|
-
|
|
2911
|
-
|
|
2912
|
-
|
|
2913
|
-
}
|
|
2906
|
+
const start = masked.findIndex((line) => {
|
|
2907
|
+
const tag = /^[ \t]*@example(?=[ \t]|$)[ \t]*(.*)$/.exec(line);
|
|
2908
|
+
return tag !== null && (tag[1] ?? "").trim() === title;
|
|
2909
|
+
});
|
|
2914
2910
|
if (start < 0) return void 0;
|
|
2915
2911
|
const current = collectExamples(content.join("\n"), example.name).find((entry) => (entry.title ?? "") === title);
|
|
2916
2912
|
if (current !== void 0 && current.code === example.code && current.language === example.language) return comment;
|
|
2917
|
-
|
|
2918
|
-
|
|
2919
|
-
|
|
2913
|
+
const next = masked.findIndex((line, index) => index > start && /^[ \t]*@\w/.test(line));
|
|
2914
|
+
const boundary = next < 0 ? content.length : next;
|
|
2915
|
+
const last = content.findLastIndex((line, index) => index > start && index < boundary && line.length > 0);
|
|
2916
|
+
const end = last < 0 ? start + 1 : last + 1;
|
|
2920
2917
|
const indent = /^[ \t]*/.exec(comment)?.[0] ?? "";
|
|
2921
2918
|
const body = [
|
|
2922
2919
|
`\`\`\`${example.language ?? ""}`,
|
|
@@ -2974,52 +2971,56 @@ function replaceExample(comment, example) {
|
|
|
2974
2971
|
function locateComment(text, key) {
|
|
2975
2972
|
const lines = extractSourceLines(text);
|
|
2976
2973
|
const keys = collectKeys(lines);
|
|
2977
|
-
const
|
|
2978
|
-
const
|
|
2979
|
-
|
|
2980
|
-
for (let index = 0; index < lines.length; index += 1) {
|
|
2981
|
-
const line = lines[index];
|
|
2982
|
-
if (line === void 0) continue;
|
|
2983
|
-
offsets.push(offset);
|
|
2984
|
-
positions.set(line, index);
|
|
2974
|
+
const records = [];
|
|
2975
|
+
for (const [index, line] of lines.entries()) {
|
|
2976
|
+
const offset = records.at(-1)?.next ?? 0;
|
|
2985
2977
|
const after = offset + line.source.length;
|
|
2986
|
-
|
|
2978
|
+
records.push({
|
|
2979
|
+
line,
|
|
2980
|
+
index,
|
|
2981
|
+
offset,
|
|
2982
|
+
next: after + (text.startsWith("\r\n", after) ? 2 : 1)
|
|
2983
|
+
});
|
|
2987
2984
|
}
|
|
2985
|
+
const offsets = records.map((record) => record.offset);
|
|
2986
|
+
const positions = new Map(records.map((record) => [record.line, record.index]));
|
|
2988
2987
|
for (const comment of extractSourceComments(lines)) {
|
|
2989
2988
|
if (keys.get(comment.line) !== key) continue;
|
|
2990
2989
|
const close = (positions.get(comment.line) ?? 0) - 1;
|
|
2991
2990
|
const closing = lines[close]?.jsdoc;
|
|
2992
2991
|
const end = closing === void 0 ? -1 : closing.lastIndexOf("*/");
|
|
2993
2992
|
if (end < 0) continue;
|
|
2994
|
-
|
|
2995
|
-
|
|
2996
|
-
let inside = false;
|
|
2997
|
-
let line = -1;
|
|
2998
|
-
let column = -1;
|
|
2999
|
-
for (let index = first; index <= close; index += 1) {
|
|
2993
|
+
const first = lines.keys().take(close).map((index) => close - index).find((index) => lines[index - 1]?.jsdoc === void 0) ?? 0;
|
|
2994
|
+
const found = Array.prototype.keys.call({ length: close - first + 1 }).map((distance) => first + distance).reduce((state, index) => {
|
|
3000
2995
|
const projection = lines[index]?.jsdoc ?? "";
|
|
3001
|
-
|
|
3002
|
-
|
|
3003
|
-
|
|
3004
|
-
|
|
3005
|
-
|
|
3006
|
-
line
|
|
3007
|
-
column
|
|
3008
|
-
|
|
3009
|
-
|
|
3010
|
-
|
|
3011
|
-
|
|
3012
|
-
|
|
3013
|
-
|
|
3014
|
-
|
|
2996
|
+
return Iterator.from(projection.matchAll(/(?=\/\*\*|\*\/)/g)).reduce((current, match) => {
|
|
2997
|
+
const at = match.index;
|
|
2998
|
+
if (at < current.cursor || !projection.startsWith(current.inside ? "*/" : "/**", at)) return current;
|
|
2999
|
+
return {
|
|
3000
|
+
inside: !current.inside,
|
|
3001
|
+
line: current.inside ? current.line : index,
|
|
3002
|
+
column: current.inside ? current.column : at,
|
|
3003
|
+
cursor: at + (current.inside ? 2 : 3)
|
|
3004
|
+
};
|
|
3005
|
+
}, {
|
|
3006
|
+
...state,
|
|
3007
|
+
cursor: 0
|
|
3008
|
+
});
|
|
3009
|
+
}, {
|
|
3010
|
+
inside: false,
|
|
3011
|
+
line: -1,
|
|
3012
|
+
column: -1,
|
|
3013
|
+
cursor: 0
|
|
3014
|
+
});
|
|
3015
|
+
if (found.line < 0) continue;
|
|
3016
|
+
const start = (lines[found.line]?.source ?? "").slice(0, found.column).trim() === "" ? 0 : found.column;
|
|
3015
3017
|
return {
|
|
3016
|
-
start: (offsets[line] ?? 0) + start,
|
|
3018
|
+
start: (offsets[found.line] ?? 0) + start,
|
|
3017
3019
|
end: (offsets[close] ?? 0) + end + 2
|
|
3018
3020
|
};
|
|
3019
3021
|
}
|
|
3020
3022
|
}
|
|
3021
|
-
|
|
3022
|
-
//#region src/core/parsers.ts
|
|
3023
|
+
// src/core/parsers.ts
|
|
3023
3024
|
/**
|
|
3024
3025
|
* Parses a `## By concept` manifest table into its {@link ManifestEntry} rows —
|
|
3025
3026
|
* each row's Concept cell (flattened text), Spec / Tests cells (a single link
|
|
@@ -3071,8 +3072,7 @@ function parseManifest(markdown, directory) {
|
|
|
3071
3072
|
}
|
|
3072
3073
|
return entries;
|
|
3073
3074
|
}
|
|
3074
|
-
|
|
3075
|
-
//#region src/core/shapers.ts
|
|
3075
|
+
// src/core/shapers.ts
|
|
3076
3076
|
/**
|
|
3077
3077
|
* Shapes a {@link SurfaceSymbol} — a documented / exported symbol's `name`
|
|
3078
3078
|
* paired with its {@link ExportKeyword} and its optional compared `summary`.
|
|
@@ -3182,8 +3182,7 @@ var manifestEntryShape = objectShape({
|
|
|
3182
3182
|
source: unionShape(stringShape(), arrayShape(stringShape())),
|
|
3183
3183
|
tests: stringShape()
|
|
3184
3184
|
});
|
|
3185
|
-
|
|
3186
|
-
//#region src/core/Guide.ts
|
|
3185
|
+
// src/core/Guide.ts
|
|
3187
3186
|
/**
|
|
3188
3187
|
* Presents a pure, structured view over one parsed guide — the documented
|
|
3189
3188
|
* projections (`sections` / `tagline` / `surface` / `methods` / `unnamed` / `links` /
|
|
@@ -3248,8 +3247,7 @@ var Guide = class {
|
|
|
3248
3247
|
return this.#fences;
|
|
3249
3248
|
}
|
|
3250
3249
|
};
|
|
3251
|
-
|
|
3252
|
-
//#region src/core/sources/Source.ts
|
|
3250
|
+
// src/core/sources/Source.ts
|
|
3253
3251
|
/**
|
|
3254
3252
|
* Reflects, as a pure `SourceInterface`, a module scope's intentional direct declarations,
|
|
3255
3253
|
* conventional barrel-reachable surface, and member methods over a consumer-supplied file
|
|
@@ -3468,8 +3466,7 @@ var Source = class {
|
|
|
3468
3466
|
return declarations;
|
|
3469
3467
|
}
|
|
3470
3468
|
};
|
|
3471
|
-
|
|
3472
|
-
//#region src/core/sources/SourceManager.ts
|
|
3469
|
+
// src/core/sources/SourceManager.ts
|
|
3473
3470
|
/**
|
|
3474
3471
|
* Resolves a consumer-owned import-specifier policy into pure source views and
|
|
3475
3472
|
* caches those views by module, so aliases for one module share one entity.
|
|
@@ -3523,8 +3520,7 @@ var SourceManager = class {
|
|
|
3523
3520
|
return views;
|
|
3524
3521
|
}
|
|
3525
3522
|
};
|
|
3526
|
-
|
|
3527
|
-
//#region src/core/Parity.ts
|
|
3523
|
+
// src/core/Parity.ts
|
|
3528
3524
|
/**
|
|
3529
3525
|
* Composes generic guide-parity inspection and explicit in-memory rewrites over a caller inventory.
|
|
3530
3526
|
*/
|
|
@@ -3824,21 +3820,19 @@ var Parity = class Parity {
|
|
|
3824
3820
|
files: this.#options.files,
|
|
3825
3821
|
modules: this.#options.modules
|
|
3826
3822
|
});
|
|
3827
|
-
|
|
3828
|
-
|
|
3829
|
-
|
|
3830
|
-
for (const imported of extractFenceImports(fence.code)) {
|
|
3823
|
+
if (!Iterator.from(row.guide.fences()).reduce((previous, fence) => {
|
|
3824
|
+
if (fence.language !== this.#options.language) return previous;
|
|
3825
|
+
return Iterator.from(extractFenceImports(fence.code)).reduce((matched, imported) => {
|
|
3831
3826
|
const source = sources.source(imported.specifier);
|
|
3832
|
-
if (source === void 0)
|
|
3833
|
-
compared = true;
|
|
3827
|
+
if (source === void 0) return matched;
|
|
3834
3828
|
const surface = source.surface().map((symbol) => symbol.name);
|
|
3835
3829
|
for (const name of findMissing(imported.names, surface)) findings.push({
|
|
3836
3830
|
spec: row.entry.spec,
|
|
3837
3831
|
text: `${row.entry.spec} imports missing ${name} from ${imported.specifier}.`
|
|
3838
3832
|
});
|
|
3839
|
-
|
|
3840
|
-
|
|
3841
|
-
|
|
3833
|
+
return true;
|
|
3834
|
+
}, previous);
|
|
3835
|
+
}, false)) findings.push({
|
|
3842
3836
|
spec: row.entry.spec,
|
|
3843
3837
|
text: `${row.entry.spec} has no mapped self import.`
|
|
3844
3838
|
});
|
|
@@ -3940,17 +3934,16 @@ var Parity = class Parity {
|
|
|
3940
3934
|
for (const path of selectModuleKeys(inventory, normalizeDirectories(row.entry.source))) {
|
|
3941
3935
|
const text = files.get(path);
|
|
3942
3936
|
if (text === void 0) continue;
|
|
3943
|
-
|
|
3944
|
-
for (const key of keys) {
|
|
3937
|
+
const selected = keys.reduce((previous, key) => {
|
|
3945
3938
|
const span = locateComment(text, key);
|
|
3946
|
-
if (span === void 0)
|
|
3939
|
+
if (span === void 0) return previous;
|
|
3947
3940
|
const example = collectExamples(normalizeComment(text.slice(span.start, span.end)), target.name).find((entry) => entry.title === title);
|
|
3948
|
-
if (example === void 0)
|
|
3949
|
-
|
|
3941
|
+
if (example === void 0) return previous;
|
|
3942
|
+
return previous === void 0 || span.start < previous.span.start ? {
|
|
3950
3943
|
span,
|
|
3951
3944
|
example
|
|
3952
|
-
};
|
|
3953
|
-
}
|
|
3945
|
+
} : previous;
|
|
3946
|
+
}, void 0);
|
|
3954
3947
|
if (selected !== void 0) return {
|
|
3955
3948
|
path,
|
|
3956
3949
|
text,
|
|
@@ -3959,8 +3952,7 @@ var Parity = class Parity {
|
|
|
3959
3952
|
}
|
|
3960
3953
|
}
|
|
3961
3954
|
};
|
|
3962
|
-
|
|
3963
|
-
//#region src/core/factories.ts
|
|
3955
|
+
// src/core/factories.ts
|
|
3964
3956
|
/**
|
|
3965
3957
|
* Creates a structured {@link GuideInterface} view over one guide's markdown
|
|
3966
3958
|
* source — parses once and caches its `sections` / `surface` / `methods` /
|
|
@@ -4146,7 +4138,6 @@ function createMethodGroupContract() {
|
|
|
4146
4138
|
function createManifestEntryContract() {
|
|
4147
4139
|
return createContract(manifestEntryShape);
|
|
4148
4140
|
}
|
|
4149
|
-
//#endregion
|
|
4150
4141
|
export { DRIFT_CATEGORIES, EXPORT_KEYWORDS, EXTERNAL_SCHEMES, Guide, KIND, MANIFEST, METHODS, Parity, SUMMARY, SURFACE, Source, SourceManager, TESTS, WRAP_WIDTH, buildCell, buildComment, buildFence, buildTable, collectDeclarations, collectExamples, collectFences, collectGroups, collectKeys, collectSummaries, collectTitles, compareMembership, computeDrift, computeModuleKey, computeSymbolKey, createDriftContract, createGuide, createManifestEntryContract, createMethodEntryContract, createMethodGroupContract, createSource, createSourceExampleContract, createSourceManager, createSurfaceSymbolContract, driftShape, escapeRegExp, extractBodyLines, extractCellLinks, extractCellText, extractDeclaration, extractExampleLines, extractExampleMethods, extractExamples, extractExports, extractFenceImports, extractFences, extractHidden, extractLinks, extractMemberMethods, extractMethods, extractRowEntry, extractRowSummary, extractRowSymbol, extractSourceComments, extractSourceLines, extractSurface, extractTagline, extractTests, extractUnnamed, findColumnIndex, findDrift, findFirstCode, findMissing, findMissingSymbols, findUnexampled, findUnlisted, formatDrift, formatSide, hasBehaviouralSurface, hasCanonicalSegments, identifyDrift, isDrift, isDriftCategory, isExportKeyword, isExternalLink, isManifestEntry, isMethodEntry, isMethodGroup, isSourceExample, isSurfaceSymbol, joinHead, locateComment, manifestEntryShape, maskFences, methodEntryShape, methodGroupShape, normalizeComment, normalizeDirectories, normalizeIdentifier, normalizeSummary, parseManifest, renderExample, renderMethods, renderSurface, replaceCell, replaceExample, replaceFence, replaceSummary, resolveLink, resolvePath, selectModuleKeys, selectSectionBlocks, sourceExampleShape, spliceSpan, surfaceSymbolShape, unwrapComment, wrapText };
|
|
4151
4142
|
|
|
4152
4143
|
//# sourceMappingURL=index.js.map
|