@ts-for-gir/generator-json 4.0.0-rc.6 → 4.0.0-rc.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +8 -8
- package/src/typedoc-pipeline.ts +65 -11
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ts-for-gir/generator-json",
|
|
3
|
-
"version": "4.0.0-rc.
|
|
3
|
+
"version": "4.0.0-rc.8",
|
|
4
4
|
"description": "JSON generator for ts-for-gir",
|
|
5
5
|
"main": "src/index.ts",
|
|
6
6
|
"module": "src/index.ts",
|
|
@@ -36,17 +36,17 @@
|
|
|
36
36
|
"json"
|
|
37
37
|
],
|
|
38
38
|
"devDependencies": {
|
|
39
|
-
"@ts-for-gir/tsconfig": "^4.0.0-rc.
|
|
39
|
+
"@ts-for-gir/tsconfig": "^4.0.0-rc.8",
|
|
40
40
|
"@types/node": "^25.6.0",
|
|
41
41
|
"typescript": "^6.0.3"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@gi.ts/parser": "^4.0.0-rc.
|
|
45
|
-
"@ts-for-gir/generator-base": "^4.0.0-rc.
|
|
46
|
-
"@ts-for-gir/generator-typescript": "^4.0.0-rc.
|
|
47
|
-
"@ts-for-gir/gir-module-metadata": "^4.0.0-rc.
|
|
48
|
-
"@ts-for-gir/lib": "^4.0.0-rc.
|
|
49
|
-
"@ts-for-gir/reporter": "^4.0.0-rc.
|
|
44
|
+
"@gi.ts/parser": "^4.0.0-rc.8",
|
|
45
|
+
"@ts-for-gir/generator-base": "^4.0.0-rc.8",
|
|
46
|
+
"@ts-for-gir/generator-typescript": "^4.0.0-rc.8",
|
|
47
|
+
"@ts-for-gir/gir-module-metadata": "^4.0.0-rc.8",
|
|
48
|
+
"@ts-for-gir/lib": "^4.0.0-rc.8",
|
|
49
|
+
"@ts-for-gir/reporter": "^4.0.0-rc.8",
|
|
50
50
|
"typedoc": "^0.28.19"
|
|
51
51
|
}
|
|
52
52
|
}
|
package/src/typedoc-pipeline.ts
CHANGED
|
@@ -16,9 +16,11 @@ import {
|
|
|
16
16
|
type ProjectReflection,
|
|
17
17
|
ReferenceReflection,
|
|
18
18
|
ReflectionCategory,
|
|
19
|
+
ReflectionKind,
|
|
19
20
|
Serializer,
|
|
20
21
|
TSConfigReader,
|
|
21
22
|
type TypeDocOptions,
|
|
23
|
+
type Reflection as TypeDocReflection,
|
|
22
24
|
} from "typedoc";
|
|
23
25
|
import { GirMetadataDeserializer } from "./gir-metadata-deserializer.ts";
|
|
24
26
|
import { buildGirLookupIndex } from "./gir-metadata-index.ts";
|
|
@@ -548,25 +550,77 @@ export class TypeDocPipeline {
|
|
|
548
550
|
|
|
549
551
|
/**
|
|
550
552
|
* Extract a human-readable source name from an inherited member's `inheritedFrom`.
|
|
551
|
-
*
|
|
553
|
+
*
|
|
554
|
+
* Two TypeDoc quirks are handled:
|
|
555
|
+
*
|
|
556
|
+
* 1. Per-class phantom inheritance chain. For `Window extends Widget extends
|
|
557
|
+
* InitiallyUnowned extends Object`, Window's `bind_property.inheritedFrom`
|
|
558
|
+
* points to `Widget.bind_property` (itself inherited from
|
|
559
|
+
* `InitiallyUnowned.bind_property`), not directly to the original definer.
|
|
560
|
+
* Walking the chain transitively yields the most-original visible source,
|
|
561
|
+
* matching gi-docgen's upstream documentation convention. When the chain
|
|
562
|
+
* crosses a package boundary the reference can't be resolved at runtime
|
|
563
|
+
* (target=-1), but the reference's `name` field still records the
|
|
564
|
+
* qualified original definer.
|
|
565
|
+
*
|
|
566
|
+
* 2. Accessor signatures. For an inherited accessor like Widget.cursor,
|
|
567
|
+
* `inheritedFrom.reflection` may be the get/set signature whose `parent`
|
|
568
|
+
* is the Accessor reflection (`Gtk.Widget.cursor`), not the class. Using
|
|
569
|
+
* that name verbatim creates a per-property "Inherited from
|
|
570
|
+
* Widget.cursor" section instead of a single "Inherited from Gtk.Widget"
|
|
571
|
+
* section. Walking up to the nearest containing class/interface fixes it.
|
|
552
572
|
*/
|
|
553
573
|
private extractInheritedSourceName(child: DeclarationReflection): string | null {
|
|
554
574
|
if (!child.inheritedFrom) return null;
|
|
555
575
|
|
|
556
|
-
//
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
576
|
+
// 1. Follow `inheritedFrom` transitively to the original definer.
|
|
577
|
+
// Capture the *unresolved* boundary name if we hit one — TypeDoc's
|
|
578
|
+
// per-package conversion can't follow `inheritedFrom` across package
|
|
579
|
+
// boundaries (target=-1), but the reference's `name` field still
|
|
580
|
+
// records the original definer's qualified name.
|
|
581
|
+
let target = child.inheritedFrom.reflection as DeclarationReflection | undefined;
|
|
582
|
+
let unresolvedBoundaryName: string | undefined = target ? undefined : child.inheritedFrom.name;
|
|
583
|
+
const seen = new Set<number>();
|
|
584
|
+
while (target?.isDeclaration() && target.inheritedFrom) {
|
|
585
|
+
if (!target.inheritedFrom.reflection) {
|
|
586
|
+
unresolvedBoundaryName = target.inheritedFrom.name;
|
|
587
|
+
break;
|
|
588
|
+
}
|
|
589
|
+
if (seen.has(target.id)) break;
|
|
590
|
+
seen.add(target.id);
|
|
591
|
+
target = target.inheritedFrom.reflection as DeclarationReflection;
|
|
592
|
+
}
|
|
593
|
+
|
|
594
|
+
// 2. If the chain ended at a cross-package boundary, parse the original
|
|
595
|
+
// definer from the unresolved reference's `name` (e.g. for the gtk-4.0
|
|
596
|
+
// project, `Widget.bind_property.inheritedFrom.name` is
|
|
597
|
+
// "GObject.InitiallyUnowned.bind_property"). Strip the trailing member
|
|
598
|
+
// name to get the qualified defining class.
|
|
599
|
+
if (unresolvedBoundaryName) {
|
|
600
|
+
const lastDot = unresolvedBoundaryName.lastIndexOf(".");
|
|
601
|
+
if (lastDot > 0) return unresolvedBoundaryName.slice(0, lastDot);
|
|
602
|
+
}
|
|
603
|
+
|
|
604
|
+
// 3. The chain resolved fully within this project. Walk the target's
|
|
605
|
+
// parent chain to the containing class/interface so accessor signatures
|
|
606
|
+
// don't yield "Class.property" as the source.
|
|
607
|
+
if (target) {
|
|
608
|
+
let owner: TypeDocReflection | undefined = target.parent;
|
|
609
|
+
while (owner && !owner.kindOf(ReflectionKind.ClassOrInterface)) {
|
|
610
|
+
owner = owner.parent;
|
|
611
|
+
}
|
|
612
|
+
const fullName = owner?.getFullName();
|
|
563
613
|
if (fullName) return fullName;
|
|
614
|
+
if (target.parent) {
|
|
615
|
+
const parentName = target.parent.getFullName();
|
|
616
|
+
if (parentName) return parentName;
|
|
617
|
+
}
|
|
564
618
|
}
|
|
565
619
|
|
|
566
|
-
//
|
|
620
|
+
// Final fallback: parse the immediate `inheritedFrom.name`.
|
|
567
621
|
const name = child.inheritedFrom.name;
|
|
568
|
-
const
|
|
569
|
-
return
|
|
622
|
+
const lastDot = name.lastIndexOf(".");
|
|
623
|
+
return lastDot > 0 ? name.slice(0, lastDot) : name;
|
|
570
624
|
}
|
|
571
625
|
|
|
572
626
|
/**
|