@orkestrel/guide 0.0.21 → 0.0.23
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/dist/src/core/index.cjs +52 -9
- package/dist/src/core/index.cjs.map +1 -1
- package/dist/src/core/index.d.cts +31 -5
- package/dist/src/core/index.d.ts +31 -5
- package/dist/src/core/index.js +52 -10
- package/dist/src/core/index.js.map +1 -1
- package/dist/src/server/index.cjs +51 -9
- package/dist/src/server/index.cjs.map +1 -1
- package/dist/src/server/index.js +51 -9
- package/dist/src/server/index.js.map +1 -1
- package/package.json +7 -7
|
@@ -917,6 +917,23 @@ function findMissingSymbols(symbols, source) {
|
|
|
917
917
|
return findMissing(symbols.map(computeSymbolKey), source.map(computeSymbolKey));
|
|
918
918
|
}
|
|
919
919
|
/**
|
|
920
|
+
* Checks whether a source declares at least one behavioural member — a `class` or `interface`
|
|
921
|
+
* in its surface that carries a call-signature member — so a guide owes a `## Methods` group only
|
|
922
|
+
* where the source has one to document.
|
|
923
|
+
*
|
|
924
|
+
* @param source - The reflected source under parity
|
|
925
|
+
* @returns True if a surface `class` or `interface` declares a member; false otherwise
|
|
926
|
+
*
|
|
927
|
+
* @example
|
|
928
|
+
* ```ts
|
|
929
|
+
* hasBehaviouralSurface(createSource({ files: { 'src/types.ts': 'export interface Widget { render(): void }' }, module: 'src' })) // true
|
|
930
|
+
* hasBehaviouralSurface(createSource({ files: { 'src/constants.ts': 'export const NAMES = Object.freeze({})' }, module: 'src' })) // false
|
|
931
|
+
* ```
|
|
932
|
+
*/
|
|
933
|
+
function hasBehaviouralSurface(source) {
|
|
934
|
+
return source.surface().some((symbol) => (symbol.keyword === "class" || symbol.keyword === "interface") && source.methods(symbol.name).length > 0);
|
|
935
|
+
}
|
|
936
|
+
/**
|
|
920
937
|
* Finds the names in `names` that have no example — a fence containing the name at a
|
|
921
938
|
* word boundary in `fences`, or a membership in `examples`, both count as
|
|
922
939
|
* "has an example"; presence-only, fence and JSDoc content are never checked.
|
|
@@ -1294,7 +1311,14 @@ function extractHidden(source) {
|
|
|
1294
1311
|
}
|
|
1295
1312
|
/**
|
|
1296
1313
|
* Joins the declaration head starting at `start` into one space-separated
|
|
1297
|
-
* line, consuming lines until the first that ends with
|
|
1314
|
+
* line, consuming lines until the first that opens a body: one that ends with
|
|
1315
|
+
* `{`, or one that closes an empty body with `{}` or `{ }`.
|
|
1316
|
+
*
|
|
1317
|
+
* @remarks
|
|
1318
|
+
* A line ending with `{}` closes an empty body only when every angle, round,
|
|
1319
|
+
* and square bracket the head opened outside quoted text has closed; inside
|
|
1320
|
+
* one, `{}` is a type or an argument, and an arrow's `=>` closes nothing. A
|
|
1321
|
+
* head that reaches the next column-zero `export` line opens no body.
|
|
1298
1322
|
*
|
|
1299
1323
|
* @param lines - The file's source lines
|
|
1300
1324
|
* @param start - The index of the head's first line
|
|
@@ -1303,6 +1327,7 @@ function extractHidden(source) {
|
|
|
1303
1327
|
* @example
|
|
1304
1328
|
* ```ts
|
|
1305
1329
|
* joinHead(['export class X {'], 0) // { text: 'export class X {', end: 0 }
|
|
1330
|
+
* joinHead(['export interface Y extends X {}'], 0) // { text: 'export interface Y extends X {}', end: 0 }
|
|
1306
1331
|
* ```
|
|
1307
1332
|
*/
|
|
1308
1333
|
function joinHead(lines, start) {
|
|
@@ -1310,8 +1335,15 @@ function joinHead(lines, start) {
|
|
|
1310
1335
|
for (let index = start; index < lines.length; index += 1) {
|
|
1311
1336
|
const line = lines[index];
|
|
1312
1337
|
if (line === void 0) break;
|
|
1313
|
-
|
|
1314
|
-
if (
|
|
1338
|
+
const text = line.trimEnd();
|
|
1339
|
+
if (index > start && text.startsWith("export ")) return void 0;
|
|
1340
|
+
parts.push(index === start ? text : text.trimStart());
|
|
1341
|
+
if (text.endsWith("{")) return {
|
|
1342
|
+
text: parts.join(" "),
|
|
1343
|
+
end: index
|
|
1344
|
+
};
|
|
1345
|
+
const bare = parts.join(" ").replace(/'(?:[^'\\]|\\.)*'|"(?:[^"\\]|\\.)*"/g, "");
|
|
1346
|
+
if ((bare.match(/</g)?.length ?? 0) <= (bare.match(/(?<!=)>/g)?.length ?? 0) && (bare.match(/\(/g)?.length ?? 0) <= (bare.match(/\)/g)?.length ?? 0) && (bare.match(/\[/g)?.length ?? 0) <= (bare.match(/\]/g)?.length ?? 0) && /\{\s*\}$/.test(text)) return {
|
|
1315
1347
|
text: parts.join(" "),
|
|
1316
1348
|
end: index
|
|
1317
1349
|
};
|
|
@@ -1352,12 +1384,14 @@ function escapeRegExp(value) {
|
|
|
1352
1384
|
* optional heritage clause between the identifier and the opening `{`; the identifier is the head's
|
|
1353
1385
|
* own run up to that list or clause, so it enters the key as literal text and no name reaches a
|
|
1354
1386
|
* `RegExp`. Body lines are the raw source between the head and the first projected column-zero `}`,
|
|
1355
|
-
* keeping JSDoc evidence intact
|
|
1387
|
+
* keeping JSDoc evidence intact; a head whose last line closes its own body with `{}` or `{ }`
|
|
1388
|
+
* records an empty body. Every balanced `<...>` span is removed from the head before its
|
|
1356
1389
|
* `extends` clause is read, so a `T extends Base` type parameter is never a base and `Base<T>`
|
|
1357
1390
|
* reads as `Base`; a class's `implements` clause and everything after it is excluded, and a
|
|
1358
1391
|
* qualified base such as `namespace.Base` is returned verbatim. The first head of a key that opens
|
|
1359
1392
|
* a column-zero close answers for that key: a head that opens none records nothing, and a later
|
|
1360
|
-
* head of a key already collected adds nothing
|
|
1393
|
+
* head of a key already collected adds nothing unless the earlier head recorded neither a body
|
|
1394
|
+
* nor bases, which declares nothing as {@link Source} reads it, so the later head replaces it.
|
|
1361
1395
|
*
|
|
1362
1396
|
* @param source - The file's source text to read
|
|
1363
1397
|
* @returns One entry per collected declaration, keyed `${keyword} ${name}`
|
|
@@ -1371,7 +1405,7 @@ function escapeRegExp(value) {
|
|
|
1371
1405
|
function collectDeclarations(source) {
|
|
1372
1406
|
const declarations = /* @__PURE__ */ new Map();
|
|
1373
1407
|
const opener = /^export (?:class|interface) /;
|
|
1374
|
-
const grammar = /^export (class|interface) ([^\s<]+)(?:<.*>)?(?: .*)? \{
|
|
1408
|
+
const grammar = /^export (class|interface) ([^\s<]+)(?:<.*>)?(?: .*)? \{(?:\s*\})?$/;
|
|
1375
1409
|
const lines = extractSourceLines(source);
|
|
1376
1410
|
const projected = lines.map((line) => line.code);
|
|
1377
1411
|
for (let index = 0; index < projected.length; index += 1) {
|
|
@@ -1384,14 +1418,22 @@ function collectDeclarations(source) {
|
|
|
1384
1418
|
const name = declared?.[2];
|
|
1385
1419
|
if (keyword === void 0 || name === void 0) continue;
|
|
1386
1420
|
const key = `${keyword} ${name}`;
|
|
1387
|
-
|
|
1421
|
+
const known = declarations.get(key);
|
|
1422
|
+
if (known !== void 0 && (known.body.length > 0 || known.bases.length > 0)) continue;
|
|
1388
1423
|
let depth = 0;
|
|
1389
1424
|
let flat = "";
|
|
1390
|
-
for (const character of head.text.slice(`export ${key}`.length,
|
|
1425
|
+
for (const character of head.text.slice(`export ${key}`.length, head.text.lastIndexOf("{"))) if (character === "<") depth += 1;
|
|
1391
1426
|
else if (character === ">") depth = Math.max(0, depth - 1);
|
|
1392
1427
|
else if (depth === 0) flat += character;
|
|
1393
1428
|
const clause = flat.replace(/\bimplements\b[\s\S]*$/, "").match(/\bextends\b([\s\S]*)$/)?.[1];
|
|
1394
1429
|
const bases = clause === void 0 ? [] : clause.split(",").map((base) => base.trim()).filter(_orkestrel_contract.isNonEmptyString);
|
|
1430
|
+
if (head.text.endsWith("}")) {
|
|
1431
|
+
declarations.set(key, {
|
|
1432
|
+
body: [],
|
|
1433
|
+
bases
|
|
1434
|
+
});
|
|
1435
|
+
continue;
|
|
1436
|
+
}
|
|
1395
1437
|
for (let close = head.end + 1; close < projected.length; close += 1) {
|
|
1396
1438
|
if (projected[close] !== "}") continue;
|
|
1397
1439
|
declarations.set(key, {
|
|
@@ -3332,7 +3374,7 @@ var Parity = class Parity {
|
|
|
3332
3374
|
text: `${row.entry.spec} has no ## ${heading} section.`
|
|
3333
3375
|
});
|
|
3334
3376
|
}
|
|
3335
|
-
if (row.guide.methods().length === 0) findings.push({
|
|
3377
|
+
if (row.guide.methods().length === 0 && hasBehaviouralSurface(row.source)) findings.push({
|
|
3336
3378
|
spec: row.entry.spec,
|
|
3337
3379
|
text: `${row.entry.spec} has no documented method groups.`
|
|
3338
3380
|
});
|