Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix links to dependencies #524

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"fruities": {
"uri": "package://localhost:0/[email protected]",
"checksums": {
"sha256": "34a15b02346e6acb85da5bd71d8b0738a79008b38a7fc805e5869d9129ad27d2"
"sha256": "8ff80e5ac882650e817f261c8af024bf0db9b07888c9d18c20017457e04ffe06"
}
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
"sha256": "$computedChecksum"
},
"sourceCode": "https://example.com/fruit",
"documentation": "https://example.com/fruit-docs",
"license": "UNLICENSED",
"authors": [
"[email protected]",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
"sha256": "$computedChecksum"
},
"sourceCode": "https://example.com/fruit",
"documentation": "https://example.com/fruit-docs",
"license": "UNLICENSED",
"authors": [
"[email protected]",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ import org.pkl.commons.deleteRecursively
*/
class PackageServer : AutoCloseable {
companion object {
const val BIRDS_SHA = "bfaf5281613d170a740505cc87561041f4e0cad1f0e6938bf94f7609f9a4673d"
const val FRUIT_SHA = "34a15b02346e6acb85da5bd71d8b0738a79008b38a7fc805e5869d9129ad27d2"
const val FRUIT_1_1_SHA = "8d982761d182f2185e4180c82190791d9a60c721cb3393bb2e946fab90131e8c"
const val BIRDS_SHA = "c90e62ac513c93bd5850e21d669dbc70afd267ab7b6c7aff77ab4e0111c5b723"
const val FRUIT_SHA = "8ff80e5ac882650e817f261c8af024bf0db9b07888c9d18c20017457e04ffe06"
const val FRUIT_1_1_SHA = "eaf03e7162bdc23797b92cffc8151b98ac655476e4ec843d2d2280f225bdfddc"

fun populateCacheDir(cacheDir: Path) {
doPopulateCacheDir(cacheDir.resolve("package-2/localhost(3a)$PORT"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ examples {
import("package://localhost:0/[email protected]#/catalog/Ostritch.pkl")
}
["importing while specifying checksum"] {
import("package://localhost:0/[email protected]::sha256:bfaf5281613d170a740505cc87561041f4e0cad1f0e6938bf94f7609f9a4673d#/catalog/Swallow.pkl")
import("package://localhost:0/[email protected]::sha256:c90e62ac513c93bd5850e21d669dbc70afd267ab7b6c7aff77ab4e0111c5b723#/catalog/Swallow.pkl")
}
["reads"] {
read("package://localhost:0/[email protected]#/Bird.pkl")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@ examples {
import("package://localhost:0/[email protected]#/allFruit.pkl").fruitFiles
}
["glob import while specifying checksum"] {
import*("package://localhost:0/[email protected]::sha256:bfaf5281613d170a740505cc87561041f4e0cad1f0e6938bf94f7609f9a4673d#/catalog/*.pkl")
import*("package://localhost:0/[email protected]::sha256:c90e62ac513c93bd5850e21d669dbc70afd267ab7b6c7aff77ab4e0111c5b723#/catalog/*.pkl")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"type": "remote",
"uri": "projectpackage://localhost:0/[email protected]",
"checksums": {
"sha256": "34a15b02346e6acb85da5bd71d8b0738a79008b38a7fc805e5869d9129ad27d2"
"sha256": "8ff80e5ac882650e817f261c8af024bf0db9b07888c9d18c20017457e04ffe06"
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,13 +118,13 @@ examples {
}
["glob import while specifying checksum"] {
new {
["package://localhost:0/[email protected]::sha256:bfaf5281613d170a740505cc87561041f4e0cad1f0e6938bf94f7609f9a4673d#/catalog/Ostritch.pkl"] {
["package://localhost:0/[email protected]::sha256:c90e62ac513c93bd5850e21d669dbc70afd267ab7b6c7aff77ab4e0111c5b723#/catalog/Ostritch.pkl"] {
name = "Ostritch"
favoriteFruit {
name = "Orange"
}
}
["package://localhost:0/[email protected]::sha256:bfaf5281613d170a740505cc87561041f4e0cad1f0e6938bf94f7609f9a4673d#/catalog/Swallow.pkl"] {
["package://localhost:0/[email protected]::sha256:c90e62ac513c93bd5850e21d669dbc70afd267ab7b6c7aff77ab4e0111c5b723#/catalog/Swallow.pkl"] {
name = "Swallow"
favoriteFruit {
name = "Apple"
Expand Down
5 changes: 3 additions & 2 deletions pkl-doc/src/main/kotlin/org/pkl/doc/CliDocGenerator.kt
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class CliDocGenerator(private val options: CliDocGeneratorOptions) : CliCommand(
PklInfo.current()
.packageIndex
.getPackagePage("pkl", Release.current().version().toString())
)
),
)

private fun DependencyMetadata.getPackageDependencies(): List<DocPackageInfo.PackageDependency> {
Expand All @@ -74,7 +74,8 @@ class CliDocGenerator(private val options: CliDocGeneratorOptions) : CliCommand(
}
val packageDependency =
DocPackageInfo.PackageDependency(
name = metadata.name,
name =
"${dependency.packageUri.uri.authority}${dependency.packageUri.uri.path.substringBeforeLast('@')}",
Comment on lines +77 to +78
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This has a bit of a smell to it. Is the definition of name not adrift this way?

uri = dependency.packageUri.uri,
version = metadata.version.toString(),
sourceCode = metadata.sourceCode,
Expand Down
2 changes: 1 addition & 1 deletion pkl-doc/src/main/kotlin/org/pkl/doc/DocPackageInfo.kt
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ data class DocPackageInfo(
version = dependency["version"] as String,
sourceCode = (dependency["sourceCode"] as String?)?.toUri(),
sourceCodeUrlScheme = dependency["sourceCodeUrlScheme"] as String?,
documentation = (dependency["documentation"] as String?)?.toUri()
documentation = (dependency["documentation"] as String?)?.toUri(),
)
},
overview = module["overview"] as String,
Expand Down
2 changes: 1 addition & 1 deletion pkl-doc/src/main/kotlin/org/pkl/doc/DocScope.kt
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ internal sealed class DocScope {

abstract val parent: DocScope?

private val siteScope: SiteScope? by lazy {
val siteScope: SiteScope? by lazy {
var scope = this
while (scope !is SiteScope) {
scope = scope.parent ?: return@lazy null
Expand Down
33 changes: 24 additions & 9 deletions pkl-doc/src/main/kotlin/org/pkl/doc/PageGenerator.kt
Original file line number Diff line number Diff line change
Expand Up @@ -525,15 +525,30 @@ internal abstract class PageGenerator<out S>(
var first = true
for (dep in dependencies) {
if (first) first = false else +", "
a {
href =
dep.documentation?.toString()
?: pageScope.relativeSiteUrl
.resolve("${dep.name}/${dep.version}/index.html")
.toString()
+dep.name
+":"
+dep.version
val text = "${dep.name}:${dep.version}"
if (dep.documentation != null) {
a {
href = dep.documentation.toString()
+text
}
} else {
val localSitePackage =
pageScope.siteScope?.packageScopes?.values?.find {
it.docPackageInfo.name == dep.name
}
if (localSitePackage != null) {
a {
href =
pageScope.relativeSiteUrl
.resolve(
"${localSitePackage.docPackageInfo.name.pathEncoded}/current/index.html"
)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will only show a local link if the package is known to Pkldoc, and it will link to "current" rather than the depended upon version. If the package is not known, and we don't know what its documentation URL is, this will just display plain text.

Note: I considered making this link directly to the version, e.g. "${localSitePackage.docPackageInfo.name.pathEncoded}/${localSitePackage.docPackageInfo.version.pathEncoded}/index.htm

However, we don't know if that version exists in the doc site. The page generator doesn't know about all the versions of each package, and we don't build this index until after the static HTML has been built.

.toString()
+text
}
} else {
+text
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ <h1 id="declaration-title">com.package1<span id="declaration-version">1.2.3</spa
<dt class="">Issue tracker:</dt>
<dd><a href="https://issues.apple.com/package1/">https://issues.apple.com/package1/</a></dd>
<dt class="">Dependencies:</dt>
<dd><a href="../../com.package2/4.5.6/index.html">com.package2:4.5.6</a>, <a href="https://example.com/docs/externalpackage/">com.externalpackage:7.8.9</a></dd>
<dd><a href="../../com.package2/current/index.html">com.package2:4.5.6</a>, <a href="https://example.com/docs/externalpackage/">com.externalpackage:7.8.9</a></dd>
<dt class="runtime-data hidden">Known usages:</dt>
<dd id="known-usages" class="runtime-data hidden"></dd>
<dt class="runtime-data hidden">All versions:</dt>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ <h2 class="member-group-title">Properties<span class="toggle-inherited-members">
<div class="member-modifiers"></div>
</div>
<div class="member-main">
<div class="member-signature"><span class="name-decl">favoriteFruit</span>: <a href="https://example.com/Fruit/index.html" class="name-ref">Fruit</a><a class="member-source-link" href="https://example.com/birds/v0.5.0/blob/Bird.pkl#L123-L456">Source</a></div>
<div class="member-signature"><span class="name-decl">favoriteFruit</span>: <span class="name-ref">Fruit</span><a class="member-source-link" href="https://example.com/birds/v0.5.0/blob/Bird.pkl#L123-L456">Source</a></div>
</div>
</div>
</li>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ <h1 id="declaration-title">localhost:0/birds<span id="declaration-version">0.5.0
<dt class="">Issue tracker:</dt>
<dd><a href="https://example.com/birds/issues">https://example.com/birds/issues</a></dd>
<dt class="">Dependencies:</dt>
<dd><a href="https://example.com/fruit-docs">fruit:1.0.5</a></dd>
<dd><a href="../../../localhost(3a)0/fruit/current/index.html">localhost:0/fruit:1.0.5</a></dd>
<dt class="">Checksum:</dt>
<dd>bfaf5281613d170a740505cc87561041f4e0cad1f0e6938bf94f7609f9a4673d</dd>
<dd>c90e62ac513c93bd5850e21d669dbc70afd267ab7b6c7aff77ab4e0111c5b723</dd>
<dt class="runtime-data hidden">Known usages:</dt>
<dd id="known-usages" class="runtime-data hidden"></dd>
<dt class="runtime-data hidden">All versions:</dt>
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"ref":{"pkg":"localhost:0/birds","pkgUri":"package://localhost:0/[email protected]","version":"0.5.0"},"sourceCode":"https://example.com/birds","sourceCodeUrlScheme":"https://example.com/birds/v0.5.0/blob%{path}#L%{line}-L%{endLine}","dependencies":[{"ref":{"pkg":"fruit","pkgUri":"package://localhost:0/[email protected]","version":"1.0.5"}},{"ref":{"pkg":"pkl","pkgUri":null,"version":"0.24.0"}}],"modules":[{"ref":{"pkg":"localhost:0/birds","pkgUri":"package://localhost:0/[email protected]","version":"0.5.0","module":"catalog"},"moduleClass":{"ref":{"pkg":"localhost:0/birds","pkgUri":"package://localhost:0/[email protected]","version":"0.5.0","module":"catalog","type":"ModuleClass"},"superclasses":[{"pkg":"pkl","pkgUri":null,"version":"0.24.0","module":"base","type":"Module"},{"pkg":"pkl","pkgUri":null,"version":"0.24.0","module":"base","type":"Typed"},{"pkg":"pkl","pkgUri":null,"version":"0.24.0","module":"base","type":"Object"},{"pkg":"pkl","pkgUri":null,"version":"0.24.0","module":"base","type":"Any"}]}},{"ref":{"pkg":"localhost:0/birds","pkgUri":"package://localhost:0/[email protected]","version":"0.5.0","module":"allFruit"},"moduleClass":{"ref":{"pkg":"localhost:0/birds","pkgUri":"package://localhost:0/[email protected]","version":"0.5.0","module":"allFruit","type":"ModuleClass"},"superclasses":[{"pkg":"pkl","pkgUri":null,"version":"0.24.0","module":"base","type":"Module"},{"pkg":"pkl","pkgUri":null,"version":"0.24.0","module":"base","type":"Typed"},{"pkg":"pkl","pkgUri":null,"version":"0.24.0","module":"base","type":"Object"},{"pkg":"pkl","pkgUri":null,"version":"0.24.0","module":"base","type":"Any"}]}},{"ref":{"pkg":"localhost:0/birds","pkgUri":"package://localhost:0/[email protected]","version":"0.5.0","module":"Bird"},"moduleClass":{"ref":{"pkg":"localhost:0/birds","pkgUri":"package://localhost:0/[email protected]","version":"0.5.0","module":"Bird","type":"ModuleClass"},"superclasses":[{"pkg":"pkl","pkgUri":null,"version":"0.24.0","module":"base","type":"Module"},{"pkg":"pkl","pkgUri":null,"version":"0.24.0","module":"base","type":"Typed"},{"pkg":"pkl","pkgUri":null,"version":"0.24.0","module":"base","type":"Object"},{"pkg":"pkl","pkgUri":null,"version":"0.24.0","module":"base","type":"Any"}],"usedTypes":[{"pkg":"fruit","pkgUri":"package://localhost:0/[email protected]","version":"1.0.5","module":"Fruit","type":"ModuleClass"}]}}]}
{"ref":{"pkg":"localhost:0/birds","pkgUri":"package://localhost:0/[email protected]","version":"0.5.0"},"sourceCode":"https://example.com/birds","sourceCodeUrlScheme":"https://example.com/birds/v0.5.0/blob%{path}#L%{line}-L%{endLine}","dependencies":[{"ref":{"pkg":"localhost:0/fruit","pkgUri":"package://localhost:0/[email protected]","version":"1.0.5"}},{"ref":{"pkg":"pkl","pkgUri":null,"version":"0.24.0"}}],"modules":[{"ref":{"pkg":"localhost:0/birds","pkgUri":"package://localhost:0/[email protected]","version":"0.5.0","module":"catalog"},"moduleClass":{"ref":{"pkg":"localhost:0/birds","pkgUri":"package://localhost:0/[email protected]","version":"0.5.0","module":"catalog","type":"ModuleClass"},"superclasses":[{"pkg":"pkl","pkgUri":null,"version":"0.24.0","module":"base","type":"Module"},{"pkg":"pkl","pkgUri":null,"version":"0.24.0","module":"base","type":"Typed"},{"pkg":"pkl","pkgUri":null,"version":"0.24.0","module":"base","type":"Object"},{"pkg":"pkl","pkgUri":null,"version":"0.24.0","module":"base","type":"Any"}]}},{"ref":{"pkg":"localhost:0/birds","pkgUri":"package://localhost:0/[email protected]","version":"0.5.0","module":"allFruit"},"moduleClass":{"ref":{"pkg":"localhost:0/birds","pkgUri":"package://localhost:0/[email protected]","version":"0.5.0","module":"allFruit","type":"ModuleClass"},"superclasses":[{"pkg":"pkl","pkgUri":null,"version":"0.24.0","module":"base","type":"Module"},{"pkg":"pkl","pkgUri":null,"version":"0.24.0","module":"base","type":"Typed"},{"pkg":"pkl","pkgUri":null,"version":"0.24.0","module":"base","type":"Object"},{"pkg":"pkl","pkgUri":null,"version":"0.24.0","module":"base","type":"Any"}]}},{"ref":{"pkg":"localhost:0/birds","pkgUri":"package://localhost:0/[email protected]","version":"0.5.0","module":"Bird"},"moduleClass":{"ref":{"pkg":"localhost:0/birds","pkgUri":"package://localhost:0/[email protected]","version":"0.5.0","module":"Bird","type":"ModuleClass"},"superclasses":[{"pkg":"pkl","pkgUri":null,"version":"0.24.0","module":"base","type":"Module"},{"pkg":"pkl","pkgUri":null,"version":"0.24.0","module":"base","type":"Typed"},{"pkg":"pkl","pkgUri":null,"version":"0.24.0","module":"base","type":"Object"},{"pkg":"pkl","pkgUri":null,"version":"0.24.0","module":"base","type":"Any"}]}}]}
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ <h1 id="declaration-title">localhost:0/fruit<span id="declaration-version">1.1.0
<dt class="">Issue tracker:</dt>
<dd><a href="https://example.com/fruit/issues">https://example.com/fruit/issues</a></dd>
<dt class="">Checksum:</dt>
<dd>8d982761d182f2185e4180c82190791d9a60c721cb3393bb2e946fab90131e8c</dd>
<dd>eaf03e7162bdc23797b92cffc8151b98ac655476e4ec843d2d2280f225bdfddc</dd>
<dt class="runtime-data hidden">Known usages:</dt>
<dd id="known-usages" class="runtime-data hidden"></dd>
<dt class="runtime-data hidden">All versions:</dt>
Expand Down