Fix tracking of known usages/subtypes (#1241)

Fixes an issue where known subtype/usage information is not gathered.

Also: change class RuntimeData to not return pairs for better composability.
This commit is contained in:
Daniel Chao
2025-10-16 12:48:35 -07:00
committed by GitHub
parent 91fec70668
commit b8aad85943
56 changed files with 522 additions and 85 deletions

View File

@@ -1 +1,8 @@
{}
{
"knownSubtypes": [
{
"text": "moduleExtend",
"href": "../moduleExtend/index.html"
}
]
}

View File

@@ -1 +1,16 @@
{}
{
"knownSubtypes": [
{
"text": "MyClass2",
"href": "MyClass2.html"
},
{
"text": "MyClass3",
"href": "MyClass3.html"
},
{
"text": "MyClass4",
"href": "MyClass4.html"
}
]
}

View File

@@ -1 +1,12 @@
{}
{
"knownSubtypes": [
{
"text": "MyClass3",
"href": "MyClass3.html"
},
{
"text": "MyClass4",
"href": "MyClass4.html"
}
]
}

View File

@@ -1 +1,8 @@
{}
{
"knownUsages": [
{
"text": "TypeReferences",
"href": "TypeReferences.html"
}
]
}

View File

@@ -1 +1,8 @@
{}
{
"knownUsages": [
{
"text": "TypeReferences",
"href": "TypeReferences.html"
}
]
}

View File

@@ -1 +1,8 @@
{}
{
"knownUsages": [
{
"text": "Person1",
"href": "Person1.html"
}
]
}

View File

@@ -1 +1,8 @@
{}
{
"knownSubtypes": [
{
"text": "moduleMethodCommentInheritance",
"href": "../moduleMethodCommentInheritance/index.html"
}
]
}

View File

@@ -1 +1,8 @@
{}
{
"knownUsages": [
{
"text": "moduleMethodTypeReferences",
"href": "index.html"
}
]
}

View File

@@ -1 +1,8 @@
{}
{
"knownUsages": [
{
"text": "UserDefinedAnnotation1",
"href": "UserDefinedAnnotation1.html"
}
]
}

View File

@@ -1 +1,8 @@
{}
{
"knownSubtypes": [
{
"text": "modulePropertyCommentInheritance",
"href": "../modulePropertyCommentInheritance/index.html"
}
]
}

View File

@@ -1 +1,8 @@
{}
{
"knownUsages": [
{
"text": "modulePropertyTypeReferences",
"href": "index.html"
}
]
}

View File

@@ -1 +1,12 @@
{}
{
"knownUsages": [
{
"text": "Foo",
"href": "../moduleTypes2/Foo.html"
},
{
"text": "moduleTypes2",
"href": "../moduleTypes2/index.html"
}
]
}

View File

@@ -1 +1,8 @@
{}
{
"knownUsages": [
{
"text": "Foo",
"href": "Foo.html"
}
]
}

View File

@@ -1 +1,16 @@
{}
{
"knownUsages": [
{
"text": "TypeReferences",
"href": "../classMethodTypeReferences/TypeReferences.html"
},
{
"text": "moduleMethodTypeReferences",
"href": "../moduleMethodTypeReferences/index.html"
},
{
"text": "modulePropertyTypeReferences",
"href": "../modulePropertyTypeReferences/index.html"
}
]
}

View File

@@ -1 +1,8 @@
{}
{
"knownSubtypes": [
{
"text": "Person2",
"href": "../typeAliasInheritance/Person2.html"
}
]
}

View File

@@ -1 +1,8 @@
{}
{
"knownSubtypes": [
{
"text": "typeAliasInheritance",
"href": "../typeAliasInheritance/index.html"
}
]
}

View File

@@ -1 +1,8 @@
{}
{
"knownUsages": [
{
"text": "com.package1",
"href": "../../com.package1/1.2.3/index.html"
}
]
}

View File

@@ -1 +1,8 @@
{}
{
"knownSubtypes": [
{
"text": "moduleExtend",
"href": "../moduleExtend/index.html"
}
]
}

View File

@@ -1 +1,16 @@
{}
{
"knownSubtypes": [
{
"text": "MyClass2",
"href": "MyClass2.html"
},
{
"text": "MyClass3",
"href": "MyClass3.html"
},
{
"text": "MyClass4",
"href": "MyClass4.html"
}
]
}

View File

@@ -1 +1,12 @@
{}
{
"knownSubtypes": [
{
"text": "MyClass3",
"href": "MyClass3.html"
},
{
"text": "MyClass4",
"href": "MyClass4.html"
}
]
}

View File

@@ -1 +1,8 @@
{}
{
"knownUsages": [
{
"text": "TypeReferences",
"href": "TypeReferences.html"
}
]
}

View File

@@ -1 +1,8 @@
{}
{
"knownUsages": [
{
"text": "TypeReferences",
"href": "TypeReferences.html"
}
]
}

View File

@@ -1 +1,8 @@
{}
{
"knownUsages": [
{
"text": "Person1",
"href": "Person1.html"
}
]
}

View File

@@ -1 +1,8 @@
{}
{
"knownSubtypes": [
{
"text": "moduleMethodCommentInheritance",
"href": "../moduleMethodCommentInheritance/index.html"
}
]
}

View File

@@ -1 +1,8 @@
{}
{
"knownUsages": [
{
"text": "moduleMethodTypeReferences",
"href": "index.html"
}
]
}

View File

@@ -1 +1,8 @@
{}
{
"knownUsages": [
{
"text": "UserDefinedAnnotation1",
"href": "UserDefinedAnnotation1.html"
}
]
}

View File

@@ -1 +1,8 @@
{}
{
"knownSubtypes": [
{
"text": "modulePropertyCommentInheritance",
"href": "../modulePropertyCommentInheritance/index.html"
}
]
}

View File

@@ -1 +1,8 @@
{}
{
"knownUsages": [
{
"text": "modulePropertyTypeReferences",
"href": "index.html"
}
]
}

View File

@@ -1 +1,12 @@
{}
{
"knownUsages": [
{
"text": "Foo",
"href": "../moduleTypes2/Foo.html"
},
{
"text": "moduleTypes2",
"href": "../moduleTypes2/index.html"
}
]
}

View File

@@ -1 +1,8 @@
{}
{
"knownUsages": [
{
"text": "Foo",
"href": "Foo.html"
}
]
}

View File

@@ -1 +1,16 @@
{}
{
"knownUsages": [
{
"text": "TypeReferences",
"href": "../classMethodTypeReferences/TypeReferences.html"
},
{
"text": "moduleMethodTypeReferences",
"href": "../moduleMethodTypeReferences/index.html"
},
{
"text": "modulePropertyTypeReferences",
"href": "../modulePropertyTypeReferences/index.html"
}
]
}

View File

@@ -1 +1,8 @@
{}
{
"knownSubtypes": [
{
"text": "Person2",
"href": "../typeAliasInheritance/Person2.html"
}
]
}

View File

@@ -1 +1,8 @@
{}
{
"knownSubtypes": [
{
"text": "typeAliasInheritance",
"href": "../typeAliasInheritance/index.html"
}
]
}

View File

@@ -1 +1,8 @@
{}
{
"knownUsages": [
{
"text": "com.package1",
"href": "../../com.package1/1.2.3/index.html"
}
]
}

View File

@@ -1 +1,8 @@
{}
{
"knownSubtypes": [
{
"text": "moduleExtend",
"href": "../moduleExtend/index.html"
}
]
}

View File

@@ -1 +1,16 @@
{}
{
"knownSubtypes": [
{
"text": "MyClass2",
"href": "MyClass2.html"
},
{
"text": "MyClass3",
"href": "MyClass3.html"
},
{
"text": "MyClass4",
"href": "MyClass4.html"
}
]
}

View File

@@ -1 +1,12 @@
{}
{
"knownSubtypes": [
{
"text": "MyClass3",
"href": "MyClass3.html"
},
{
"text": "MyClass4",
"href": "MyClass4.html"
}
]
}

View File

@@ -1 +1,8 @@
{}
{
"knownUsages": [
{
"text": "TypeReferences",
"href": "TypeReferences.html"
}
]
}

View File

@@ -1 +1,8 @@
{}
{
"knownUsages": [
{
"text": "TypeReferences",
"href": "TypeReferences.html"
}
]
}

View File

@@ -1 +1,8 @@
{}
{
"knownUsages": [
{
"text": "Person1",
"href": "Person1.html"
}
]
}

View File

@@ -1 +1,8 @@
{}
{
"knownSubtypes": [
{
"text": "moduleMethodCommentInheritance",
"href": "../moduleMethodCommentInheritance/index.html"
}
]
}

View File

@@ -1 +1,8 @@
{}
{
"knownUsages": [
{
"text": "moduleMethodTypeReferences",
"href": "index.html"
}
]
}

View File

@@ -1 +1,8 @@
{}
{
"knownUsages": [
{
"text": "UserDefinedAnnotation1",
"href": "UserDefinedAnnotation1.html"
}
]
}

View File

@@ -1 +1,8 @@
{}
{
"knownSubtypes": [
{
"text": "modulePropertyCommentInheritance",
"href": "../modulePropertyCommentInheritance/index.html"
}
]
}

View File

@@ -1 +1,8 @@
{}
{
"knownUsages": [
{
"text": "modulePropertyTypeReferences",
"href": "index.html"
}
]
}

View File

@@ -1 +1,12 @@
{}
{
"knownUsages": [
{
"text": "Foo",
"href": "../moduleTypes2/Foo.html"
},
{
"text": "moduleTypes2",
"href": "../moduleTypes2/index.html"
}
]
}

View File

@@ -1 +1,8 @@
{}
{
"knownUsages": [
{
"text": "Foo",
"href": "Foo.html"
}
]
}

View File

@@ -1 +1,20 @@
{}
{
"knownUsages": [
{
"text": "TypeReferences",
"href": "../classMethodTypeReferences/TypeReferences.html"
},
{
"text": "TypeReferences",
"href": "../classPropertyTypeReferences/TypeReferences.html"
},
{
"text": "moduleMethodTypeReferences",
"href": "../moduleMethodTypeReferences/index.html"
},
{
"text": "modulePropertyTypeReferences",
"href": "../modulePropertyTypeReferences/index.html"
}
]
}

View File

@@ -1 +1,8 @@
{}
{
"knownSubtypes": [
{
"text": "Person2",
"href": "../typeAliasInheritance/Person2.html"
}
]
}

View File

@@ -1 +1,8 @@
{}
{
"knownSubtypes": [
{
"text": "typeAliasInheritance",
"href": "../typeAliasInheritance/index.html"
}
]
}

View File

@@ -1 +1,8 @@
{}
{
"knownUsages": [
{
"text": "ternalPackage",
"href": "../../../com.package1/1.2.3/ternalPackage/index.html"
}
]
}

View File

@@ -1 +1,8 @@
{}
{
"knownUsages": [
{
"text": "com.package1",
"href": "../../com.package1/1.2.3/index.html"
}
]
}

View File

@@ -147,6 +147,8 @@ class CliDocGeneratorTest {
assertThat(e).hasMessageContaining("at least one", "module")
}
// to re-generate output, delete directory pkl-doc/src/test/files/DocGeneratorTest/output and run
// again
@ParameterizedTest
@MethodSource("generateDocs")
fun test(relativeFilePath: String) {

View File

@@ -41,7 +41,7 @@ class RuntimeDataTest {
ModuleRef(pkg = "foo", pkgUri = null, version = "1.3.0", module = "foo"),
)
val result = current.addKnownUsages(ref, usages, { it.fullName }, descendingVersionComparator)
assertThat(result.first)
assertThat(result)
.isEqualTo(
RuntimeData(
knownUsages = setOf(RuntimeDataLink("foo.foo", "../../../foo/1.3.0/foo/index.html"))
@@ -59,7 +59,7 @@ class RuntimeDataTest {
val usages = setOf(ModuleRef(pkg = "foo", pkgUri = null, version = "1.2.0", module = "foo"))
val result = current.addKnownUsages(ref, usages, { it.fullName }, descendingVersionComparator)
assertThat(result.first)
assertThat(result)
.isEqualTo(
RuntimeData(
knownUsages = setOf(RuntimeDataLink("foo.foo", "../../../foo/1.3.0/foo/index.html"))