@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
package/dist/src/server/index.js
CHANGED
|
@@ -893,6 +893,23 @@ function findMissingSymbols(symbols, source) {
|
|
|
893
893
|
return findMissing(symbols.map(computeSymbolKey), source.map(computeSymbolKey));
|
|
894
894
|
}
|
|
895
895
|
/**
|
|
896
|
+
* Checks whether a source declares at least one behavioural member — a `class` or `interface`
|
|
897
|
+
* in its surface that carries a call-signature member — so a guide owes a `## Methods` group only
|
|
898
|
+
* where the source has one to document.
|
|
899
|
+
*
|
|
900
|
+
* @param source - The reflected source under parity
|
|
901
|
+
* @returns True if a surface `class` or `interface` declares a member; false otherwise
|
|
902
|
+
*
|
|
903
|
+
* @example
|
|
904
|
+
* ```ts
|
|
905
|
+
* hasBehaviouralSurface(createSource({ files: { 'src/types.ts': 'export interface Widget { render(): void }' }, module: 'src' })) // true
|
|
906
|
+
* hasBehaviouralSurface(createSource({ files: { 'src/constants.ts': 'export const NAMES = Object.freeze({})' }, module: 'src' })) // false
|
|
907
|
+
* ```
|
|
908
|
+
*/
|
|
909
|
+
function hasBehaviouralSurface(source) {
|
|
910
|
+
return source.surface().some((symbol) => (symbol.keyword === "class" || symbol.keyword === "interface") && source.methods(symbol.name).length > 0);
|
|
911
|
+
}
|
|
912
|
+
/**
|
|
896
913
|
* Finds the names in `names` that have no example — a fence containing the name at a
|
|
897
914
|
* word boundary in `fences`, or a membership in `examples`, both count as
|
|
898
915
|
* "has an example"; presence-only, fence and JSDoc content are never checked.
|
|
@@ -1270,7 +1287,14 @@ function extractHidden(source) {
|
|
|
1270
1287
|
}
|
|
1271
1288
|
/**
|
|
1272
1289
|
* Joins the declaration head starting at `start` into one space-separated
|
|
1273
|
-
* line, consuming lines until the first that ends with
|
|
1290
|
+
* line, consuming lines until the first that opens a body: one that ends with
|
|
1291
|
+
* `{`, or one that closes an empty body with `{}` or `{ }`.
|
|
1292
|
+
*
|
|
1293
|
+
* @remarks
|
|
1294
|
+
* A line ending with `{}` closes an empty body only when every angle, round,
|
|
1295
|
+
* and square bracket the head opened outside quoted text has closed; inside
|
|
1296
|
+
* one, `{}` is a type or an argument, and an arrow's `=>` closes nothing. A
|
|
1297
|
+
* head that reaches the next column-zero `export` line opens no body.
|
|
1274
1298
|
*
|
|
1275
1299
|
* @param lines - The file's source lines
|
|
1276
1300
|
* @param start - The index of the head's first line
|
|
@@ -1279,6 +1303,7 @@ function extractHidden(source) {
|
|
|
1279
1303
|
* @example
|
|
1280
1304
|
* ```ts
|
|
1281
1305
|
* joinHead(['export class X {'], 0) // { text: 'export class X {', end: 0 }
|
|
1306
|
+
* joinHead(['export interface Y extends X {}'], 0) // { text: 'export interface Y extends X {}', end: 0 }
|
|
1282
1307
|
* ```
|
|
1283
1308
|
*/
|
|
1284
1309
|
function joinHead(lines, start) {
|
|
@@ -1286,8 +1311,15 @@ function joinHead(lines, start) {
|
|
|
1286
1311
|
for (let index = start; index < lines.length; index += 1) {
|
|
1287
1312
|
const line = lines[index];
|
|
1288
1313
|
if (line === void 0) break;
|
|
1289
|
-
|
|
1290
|
-
if (
|
|
1314
|
+
const text = line.trimEnd();
|
|
1315
|
+
if (index > start && text.startsWith("export ")) return void 0;
|
|
1316
|
+
parts.push(index === start ? text : text.trimStart());
|
|
1317
|
+
if (text.endsWith("{")) return {
|
|
1318
|
+
text: parts.join(" "),
|
|
1319
|
+
end: index
|
|
1320
|
+
};
|
|
1321
|
+
const bare = parts.join(" ").replace(/'(?:[^'\\]|\\.)*'|"(?:[^"\\]|\\.)*"/g, "");
|
|
1322
|
+
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 {
|
|
1291
1323
|
text: parts.join(" "),
|
|
1292
1324
|
end: index
|
|
1293
1325
|
};
|
|
@@ -1328,12 +1360,14 @@ function escapeRegExp(value) {
|
|
|
1328
1360
|
* optional heritage clause between the identifier and the opening `{`; the identifier is the head's
|
|
1329
1361
|
* own run up to that list or clause, so it enters the key as literal text and no name reaches a
|
|
1330
1362
|
* `RegExp`. Body lines are the raw source between the head and the first projected column-zero `}`,
|
|
1331
|
-
* keeping JSDoc evidence intact
|
|
1363
|
+
* keeping JSDoc evidence intact; a head whose last line closes its own body with `{}` or `{ }`
|
|
1364
|
+
* records an empty body. Every balanced `<...>` span is removed from the head before its
|
|
1332
1365
|
* `extends` clause is read, so a `T extends Base` type parameter is never a base and `Base<T>`
|
|
1333
1366
|
* reads as `Base`; a class's `implements` clause and everything after it is excluded, and a
|
|
1334
1367
|
* qualified base such as `namespace.Base` is returned verbatim. The first head of a key that opens
|
|
1335
1368
|
* a column-zero close answers for that key: a head that opens none records nothing, and a later
|
|
1336
|
-
* head of a key already collected adds nothing
|
|
1369
|
+
* head of a key already collected adds nothing unless the earlier head recorded neither a body
|
|
1370
|
+
* nor bases, which declares nothing as {@link Source} reads it, so the later head replaces it.
|
|
1337
1371
|
*
|
|
1338
1372
|
* @param source - The file's source text to read
|
|
1339
1373
|
* @returns One entry per collected declaration, keyed `${keyword} ${name}`
|
|
@@ -1347,7 +1381,7 @@ function escapeRegExp(value) {
|
|
|
1347
1381
|
function collectDeclarations(source) {
|
|
1348
1382
|
const declarations = /* @__PURE__ */ new Map();
|
|
1349
1383
|
const opener = /^export (?:class|interface) /;
|
|
1350
|
-
const grammar = /^export (class|interface) ([^\s<]+)(?:<.*>)?(?: .*)? \{
|
|
1384
|
+
const grammar = /^export (class|interface) ([^\s<]+)(?:<.*>)?(?: .*)? \{(?:\s*\})?$/;
|
|
1351
1385
|
const lines = extractSourceLines(source);
|
|
1352
1386
|
const projected = lines.map((line) => line.code);
|
|
1353
1387
|
for (let index = 0; index < projected.length; index += 1) {
|
|
@@ -1360,14 +1394,22 @@ function collectDeclarations(source) {
|
|
|
1360
1394
|
const name = declared?.[2];
|
|
1361
1395
|
if (keyword === void 0 || name === void 0) continue;
|
|
1362
1396
|
const key = `${keyword} ${name}`;
|
|
1363
|
-
|
|
1397
|
+
const known = declarations.get(key);
|
|
1398
|
+
if (known !== void 0 && (known.body.length > 0 || known.bases.length > 0)) continue;
|
|
1364
1399
|
let depth = 0;
|
|
1365
1400
|
let flat = "";
|
|
1366
|
-
for (const character of head.text.slice(`export ${key}`.length,
|
|
1401
|
+
for (const character of head.text.slice(`export ${key}`.length, head.text.lastIndexOf("{"))) if (character === "<") depth += 1;
|
|
1367
1402
|
else if (character === ">") depth = Math.max(0, depth - 1);
|
|
1368
1403
|
else if (depth === 0) flat += character;
|
|
1369
1404
|
const clause = flat.replace(/\bimplements\b[\s\S]*$/, "").match(/\bextends\b([\s\S]*)$/)?.[1];
|
|
1370
1405
|
const bases = clause === void 0 ? [] : clause.split(",").map((base) => base.trim()).filter(isNonEmptyString);
|
|
1406
|
+
if (head.text.endsWith("}")) {
|
|
1407
|
+
declarations.set(key, {
|
|
1408
|
+
body: [],
|
|
1409
|
+
bases
|
|
1410
|
+
});
|
|
1411
|
+
continue;
|
|
1412
|
+
}
|
|
1371
1413
|
for (let close = head.end + 1; close < projected.length; close += 1) {
|
|
1372
1414
|
if (projected[close] !== "}") continue;
|
|
1373
1415
|
declarations.set(key, {
|
|
@@ -3308,7 +3350,7 @@ var Parity = class Parity {
|
|
|
3308
3350
|
text: `${row.entry.spec} has no ## ${heading} section.`
|
|
3309
3351
|
});
|
|
3310
3352
|
}
|
|
3311
|
-
if (row.guide.methods().length === 0) findings.push({
|
|
3353
|
+
if (row.guide.methods().length === 0 && hasBehaviouralSurface(row.source)) findings.push({
|
|
3312
3354
|
spec: row.entry.spec,
|
|
3313
3355
|
text: `${row.entry.spec} has no documented method groups.`
|
|
3314
3356
|
});
|