@orkestrel/guide 0.0.23 → 0.0.24

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.
@@ -2340,9 +2340,12 @@ export declare function selectSectionBlocks(document: MarkdownDocument, heading:
2340
2340
  * remain valid. `methods` resolves a declaration's members through its
2341
2341
  * `extends` chain within the same module scope, keeping the keyword it started
2342
2342
  * from; a base the scope does not declare contributes nothing. One declaration
2343
- * answers for a name: the first file in sorted key order that declares the head
2344
- * supplies its members and its bases, and a second file declaring the same name
2345
- * adds nothing. Every reading derives once per instance from the immutable
2343
+ * answers under each keyword: the first file in sorted key order that declares
2344
+ * the head supplies its members and its bases, and a second file declaring the
2345
+ * same name under that keyword adds nothing. The interface answers for a name,
2346
+ * and the class when no interface declares it; one file declaring the name as
2347
+ * both shapes, a TypeScript declaration merge, answers with both, own members
2348
+ * ahead of inherited ones and the interface's own first. Every reading derives once per instance from the immutable
2346
2349
  * inventory and is reused — the scope's declaration map on the first `methods`
2347
2350
  * or `examples` lookup, then each name's members and each example collection
2348
2351
  * under the name asked for — so a reader asking twice reads the files once and
@@ -2502,13 +2505,17 @@ export declare interface SourceInterface {
2502
2505
  * block's description paragraph. The first file declaring the name answers for it.
2503
2506
  *
2504
2507
  * @remarks
2505
- * One declaration answers for `name`: the module scope's files are read in
2506
- * sorted key order and the first one whose located head has a body or has
2507
- * bases supplies both the members and the bases, so a second file
2508
- * declaring the same name adds nothing; a head with neither a body nor
2509
- * bases does not count as declared, so an empty `export interface X {}`
2510
- * is skipped and resolution continues to a later file or falls through to
2511
- * a same-named class. Resolution reads that head's `extends` clause and follows it
2508
+ * One declaration answers under each keyword: the module scope's files are
2509
+ * read in sorted key order and the first one whose located head has a body
2510
+ * or has bases supplies both the members and the bases, so a second file
2511
+ * declaring the same name under that keyword adds nothing; a head with
2512
+ * neither a body nor bases does not count as declared, so an empty
2513
+ * `export interface X {}` is skipped and resolution continues to a later
2514
+ * file. The interface answers for `name`, and the class answers when no
2515
+ * interface declares it. Where one file declares `name` as both an
2516
+ * interface and a class, which TypeScript merges into one type, both
2517
+ * answer: each shape's own members come ahead of inherited ones, the
2518
+ * interface's own first. Resolution reads each head's `extends` clause and follows it
2512
2519
  * through this same module scope, keeping the keyword it started from: an
2513
2520
  * `interface` chain resolves through interfaces and a `class` chain through
2514
2521
  * classes, so a class's `implements` clause is outside the walk. A base the
@@ -2340,9 +2340,12 @@ export declare function selectSectionBlocks(document: MarkdownDocument, heading:
2340
2340
  * remain valid. `methods` resolves a declaration's members through its
2341
2341
  * `extends` chain within the same module scope, keeping the keyword it started
2342
2342
  * from; a base the scope does not declare contributes nothing. One declaration
2343
- * answers for a name: the first file in sorted key order that declares the head
2344
- * supplies its members and its bases, and a second file declaring the same name
2345
- * adds nothing. Every reading derives once per instance from the immutable
2343
+ * answers under each keyword: the first file in sorted key order that declares
2344
+ * the head supplies its members and its bases, and a second file declaring the
2345
+ * same name under that keyword adds nothing. The interface answers for a name,
2346
+ * and the class when no interface declares it; one file declaring the name as
2347
+ * both shapes, a TypeScript declaration merge, answers with both, own members
2348
+ * ahead of inherited ones and the interface's own first. Every reading derives once per instance from the immutable
2346
2349
  * inventory and is reused — the scope's declaration map on the first `methods`
2347
2350
  * or `examples` lookup, then each name's members and each example collection
2348
2351
  * under the name asked for — so a reader asking twice reads the files once and
@@ -2502,13 +2505,17 @@ export declare interface SourceInterface {
2502
2505
  * block's description paragraph. The first file declaring the name answers for it.
2503
2506
  *
2504
2507
  * @remarks
2505
- * One declaration answers for `name`: the module scope's files are read in
2506
- * sorted key order and the first one whose located head has a body or has
2507
- * bases supplies both the members and the bases, so a second file
2508
- * declaring the same name adds nothing; a head with neither a body nor
2509
- * bases does not count as declared, so an empty `export interface X {}`
2510
- * is skipped and resolution continues to a later file or falls through to
2511
- * a same-named class. Resolution reads that head's `extends` clause and follows it
2508
+ * One declaration answers under each keyword: the module scope's files are
2509
+ * read in sorted key order and the first one whose located head has a body
2510
+ * or has bases supplies both the members and the bases, so a second file
2511
+ * declaring the same name under that keyword adds nothing; a head with
2512
+ * neither a body nor bases does not count as declared, so an empty
2513
+ * `export interface X {}` is skipped and resolution continues to a later
2514
+ * file. The interface answers for `name`, and the class answers when no
2515
+ * interface declares it. Where one file declares `name` as both an
2516
+ * interface and a class, which TypeScript merges into one type, both
2517
+ * answer: each shape's own members come ahead of inherited ones, the
2518
+ * interface's own first. Resolution reads each head's `extends` clause and follows it
2512
2519
  * through this same module scope, keeping the keyword it started from: an
2513
2520
  * `interface` chain resolves through interfaces and a `class` chain through
2514
2521
  * classes, so a class's `implements` clause is outside the walk. A base the
@@ -3269,9 +3269,12 @@ var Guide = class {
3269
3269
  * remain valid. `methods` resolves a declaration's members through its
3270
3270
  * `extends` chain within the same module scope, keeping the keyword it started
3271
3271
  * from; a base the scope does not declare contributes nothing. One declaration
3272
- * answers for a name: the first file in sorted key order that declares the head
3273
- * supplies its members and its bases, and a second file declaring the same name
3274
- * adds nothing. Every reading derives once per instance from the immutable
3272
+ * answers under each keyword: the first file in sorted key order that declares
3273
+ * the head supplies its members and its bases, and a second file declaring the
3274
+ * same name under that keyword adds nothing. The interface answers for a name,
3275
+ * and the class when no interface declares it; one file declaring the name as
3276
+ * both shapes, a TypeScript declaration merge, answers with both, own members
3277
+ * ahead of inherited ones and the interface's own first. Every reading derives once per instance from the immutable
3275
3278
  * inventory and is reused — the scope's declaration map on the first `methods`
3276
3279
  * or `examples` lookup, then each name's members and each example collection
3277
3280
  * under the name asked for — so a reader asking twice reads the files once and
@@ -3311,6 +3314,7 @@ var Source = class {
3311
3314
  #surface;
3312
3315
  #hidden;
3313
3316
  #declarations;
3317
+ #origins = /* @__PURE__ */ new Map();
3314
3318
  constructor(options) {
3315
3319
  this.#files = options.files;
3316
3320
  this.#directories = normalizeDirectories(options.module);
@@ -3345,10 +3349,18 @@ var Source = class {
3345
3349
  return examples;
3346
3350
  }
3347
3351
  #scanMethods(name) {
3348
- const declared = this.#members("interface", name, /* @__PURE__ */ new Set());
3349
- if (declared !== void 0) return declared;
3350
- const inherited = this.#members("class", name, /* @__PURE__ */ new Set());
3351
- return inherited === void 0 ? [] : inherited.filter((entry) => entry.name !== "constructor");
3352
+ const fromInterface = this.#members("interface", name, /* @__PURE__ */ new Set());
3353
+ const fromClass = this.#members("class", name, /* @__PURE__ */ new Set())?.filter((entry) => entry.name !== "constructor");
3354
+ const origin = this.#origin("interface", name);
3355
+ if (origin === void 0 || origin !== this.#origin("class", name)) return fromInterface ?? fromClass ?? [];
3356
+ const methods = /* @__PURE__ */ new Map();
3357
+ for (const entry of [
3358
+ ...extractMemberMethods(this.#locate("interface", name)?.body ?? []),
3359
+ ...extractMemberMethods(this.#locate("class", name)?.body ?? []),
3360
+ ...fromInterface ?? [],
3361
+ ...fromClass ?? []
3362
+ ]) if (entry.name !== "constructor" && !methods.has(entry.name)) methods.set(entry.name, entry);
3363
+ return Array.from(methods.values()).sort((a, b) => a.name === b.name ? 0 : a.name < b.name ? -1 : 1);
3352
3364
  }
3353
3365
  #scanExamples() {
3354
3366
  const examples = [];
@@ -3438,6 +3450,9 @@ var Source = class {
3438
3450
  if (this.#declarations === void 0) this.#declarations = this.#scanDeclarations();
3439
3451
  return this.#declarations.get(`${keyword} ${name}`);
3440
3452
  }
3453
+ #origin(keyword, name) {
3454
+ return this.#locate(keyword, name) === void 0 ? void 0 : this.#origins.get(`${keyword} ${name}`);
3455
+ }
3441
3456
  #scanDeclarations() {
3442
3457
  const declarations = /* @__PURE__ */ new Map();
3443
3458
  for (const key of selectModuleKeys(this.#files, this.#directories)) {
@@ -3447,6 +3462,7 @@ var Source = class {
3447
3462
  if (declarations.has(identity)) continue;
3448
3463
  if (declaration.body.length === 0 && declaration.bases.length === 0) continue;
3449
3464
  declarations.set(identity, declaration);
3465
+ this.#origins.set(identity, key);
3450
3466
  }
3451
3467
  }
3452
3468
  return declarations;
@@ -3720,12 +3736,14 @@ var Parity = class Parity {
3720
3736
  const groups = row.guide.methods();
3721
3737
  const documented = groups.map((group) => group.interface);
3722
3738
  const declared = new Set(row.source.surface().map((symbol) => symbol.name));
3739
+ const classes = new Set(row.source.surface().filter((symbol) => symbol.keyword === "class").map((symbol) => symbol.name));
3723
3740
  for (const group of groups) {
3724
3741
  const finding = compareMembership(row.entry.spec, group.interface, group.methods.map((entry) => entry.name), row.source.methods(group.interface).map((entry) => entry.name));
3725
3742
  if (finding !== void 0) findings.push(finding);
3726
3743
  }
3727
3744
  for (const symbol of row.source.surface()) {
3728
3745
  if (symbol.keyword !== "interface" && symbol.keyword !== "class") continue;
3746
+ if (symbol.keyword === "interface" && classes.has(symbol.name)) continue;
3729
3747
  const members = row.source.methods(symbol.name).map((entry) => entry.name);
3730
3748
  if (members.length === 0) continue;
3731
3749
  const contract = `${symbol.name}Interface`;