From 5e4ccfd4e88d075a9aa21ce066582dcc981703a2 Mon Sep 17 00:00:00 2001 From: Daniel Chao Date: Tue, 28 May 2024 13:42:57 -0700 Subject: [PATCH] Omit showing stdlib as dependency in pkldoc (#503) The stdlib is an implicit dependency for every package. Showing this as a dependency is unnecessary noise. --- pkl-doc/src/main/kotlin/org/pkl/doc/PageGenerator.kt | 6 ++++-- pkl-doc/src/main/kotlin/org/pkl/doc/RuntimeDataGenerator.kt | 5 +++++ .../DocGeneratorTest/output/com.package1/1.2.3/index.html | 2 +- .../DocGeneratorTest/output/com.package2/4.5.6/index.html | 2 -- .../output/localhost(3a)0/birds/0.5.0/index.html | 2 +- .../output/localhost(3a)0/fruit/1.1.0/index.html | 2 -- 6 files changed, 11 insertions(+), 8 deletions(-) diff --git a/pkl-doc/src/main/kotlin/org/pkl/doc/PageGenerator.kt b/pkl-doc/src/main/kotlin/org/pkl/doc/PageGenerator.kt index 15b0d578..98f12062 100644 --- a/pkl-doc/src/main/kotlin/org/pkl/doc/PageGenerator.kt +++ b/pkl-doc/src/main/kotlin/org/pkl/doc/PageGenerator.kt @@ -518,10 +518,12 @@ internal abstract class PageGenerator( } } - if (docPackage.docPackageInfo.dependencies.isNotEmpty()) { + // Every package implicitly depends on `pkl`; omit to reduce noise. + val dependencies = docPackage.docPackageInfo.dependencies.filter { it.name != "pkl" } + if (dependencies.isNotEmpty()) { result[MemberInfoKey("Dependencies")] = { var first = true - for (dep in docPackage.docPackageInfo.dependencies) { + for (dep in dependencies) { if (first) first = false else +", " a { href = diff --git a/pkl-doc/src/main/kotlin/org/pkl/doc/RuntimeDataGenerator.kt b/pkl-doc/src/main/kotlin/org/pkl/doc/RuntimeDataGenerator.kt index 90af5166..54f588ec 100644 --- a/pkl-doc/src/main/kotlin/org/pkl/doc/RuntimeDataGenerator.kt +++ b/pkl-doc/src/main/kotlin/org/pkl/doc/RuntimeDataGenerator.kt @@ -45,6 +45,9 @@ internal class RuntimeDataGenerator( for (pkg in packages) { packageVersions.add(pkg.ref.pkg, pkg.ref.version) for (dependency in pkg.dependencies) { + if (dependency.isStdlib()) continue + // Every package implicitly depends on the stdlib. Showing this dependency adds unwanted + // noise. packageUsages.add(dependency.ref, pkg.ref) } for (module in pkg.modules) { @@ -240,3 +243,5 @@ internal class RuntimeDataGenerator( put(key, newValue) } } + +private fun DependencyData.isStdlib(): Boolean = ref.pkg == "pkl" diff --git a/pkl-doc/src/test/files/DocGeneratorTest/output/com.package1/1.2.3/index.html b/pkl-doc/src/test/files/DocGeneratorTest/output/com.package1/1.2.3/index.html index ac6e3d0a..0d4c7910 100644 --- a/pkl-doc/src/test/files/DocGeneratorTest/output/com.package1/1.2.3/index.html +++ b/pkl-doc/src/test/files/DocGeneratorTest/output/com.package1/1.2.3/index.html @@ -39,7 +39,7 @@
Issue tracker:
https://issues.apple.com/package1/
Dependencies:
-
com.package2:4.5.6, com.externalpackage:7.8.9, pkl:0.24.0
+
com.package2:4.5.6, com.externalpackage:7.8.9
diff --git a/pkl-doc/src/test/files/DocGeneratorTest/output/com.package2/4.5.6/index.html b/pkl-doc/src/test/files/DocGeneratorTest/output/com.package2/4.5.6/index.html index 04f00f81..eb733423 100644 --- a/pkl-doc/src/test/files/DocGeneratorTest/output/com.package2/4.5.6/index.html +++ b/pkl-doc/src/test/files/DocGeneratorTest/output/com.package2/4.5.6/index.html @@ -35,8 +35,6 @@
https://sources.apple.com/package2/
Issue tracker:
https://issues.apple.com/package2/
-
Dependencies:
-
pkl:0.24.0
diff --git a/pkl-doc/src/test/files/DocGeneratorTest/output/localhost(3a)0/birds/0.5.0/index.html b/pkl-doc/src/test/files/DocGeneratorTest/output/localhost(3a)0/birds/0.5.0/index.html index 7ab44551..33ed09bd 100644 --- a/pkl-doc/src/test/files/DocGeneratorTest/output/localhost(3a)0/birds/0.5.0/index.html +++ b/pkl-doc/src/test/files/DocGeneratorTest/output/localhost(3a)0/birds/0.5.0/index.html @@ -37,7 +37,7 @@
Issue tracker:
https://example.com/birds/issues
Dependencies:
-
fruit:1.0.5, pkl:0.24.0
+
fruit:1.0.5
Checksum:
bfaf5281613d170a740505cc87561041f4e0cad1f0e6938bf94f7609f9a4673d
diff --git a/pkl-doc/src/test/files/DocGeneratorTest/output/localhost(3a)0/fruit/1.1.0/index.html b/pkl-doc/src/test/files/DocGeneratorTest/output/localhost(3a)0/fruit/1.1.0/index.html index f9bd5009..ed46e80c 100644 --- a/pkl-doc/src/test/files/DocGeneratorTest/output/localhost(3a)0/fruit/1.1.0/index.html +++ b/pkl-doc/src/test/files/DocGeneratorTest/output/localhost(3a)0/fruit/1.1.0/index.html @@ -36,8 +36,6 @@
https://example.com/fruit
Issue tracker:
https://example.com/fruit/issues
-
Dependencies:
-
pkl:0.24.0
Checksum:
8d982761d182f2185e4180c82190791d9a60c721cb3393bb2e946fab90131e8c