mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-02-04 23:39:07 +07:00
show empty description for python packages if a remote interpreter is selected (PY-47789)
(cherry picked from commit 0709ca8b077fd34f757a415e63911afa345b90d4) IDEA-CR-71087 GitOrigin-RevId: 452330bbaa830f06ec682141f3be61585ea7f870
This commit is contained in:
committed by
intellij-monorepo-bot
parent
cddccd178f
commit
fb09f01da9
@@ -1240,6 +1240,7 @@ python.toolwindow.packages.search.text.placeholder=Search for more packages
|
||||
python.toolwindow.packages.description.panel.placeholder=Select a package to view documentation
|
||||
python.toolwindow.packages.request.failed=<html><head></head><body><p class="empty_description">Request failed.</p></body></html>
|
||||
python.toolwindow.packages.no.description.placeholder=<html><head></head><body><p class="empty_description">Package author did not provide a description.</p></body></html>
|
||||
python.toolwindow.packages.remote.interpreter.placeholder=<html><head></head><body><p class="empty_description">Local interpreter is required to view package documentation.</p></body></html>
|
||||
python.toolwindow.packages.collecting.packages.task.title=Collecting packages
|
||||
python.toolwindow.packages.rst.parsing.failed=Failed to parse the description
|
||||
|
||||
|
||||
@@ -390,6 +390,9 @@ class PyPackagingToolWindowPanel(service: PyPackagingToolWindowService, toolWind
|
||||
private const val HORIZONTAL_SPLITTER_KEY = "Python.PackagingToolWindow.Horizontal"
|
||||
private const val VERTICAL_SPLITTER_KEY = "Python.PackagingToolWindow.Vertical"
|
||||
|
||||
|
||||
val REMOTE_INTERPRETER_TEXT: String
|
||||
get() = message("python.toolwindow.packages.remote.interpreter.placeholder")
|
||||
val REQUEST_FAILED_TEXT: String
|
||||
get() = message("python.toolwindow.packages.request.failed")
|
||||
val NO_DESCRIPTION: String
|
||||
|
||||
@@ -25,6 +25,7 @@ import com.jetbrains.python.PythonHelper
|
||||
import com.jetbrains.python.packaging.*
|
||||
import com.jetbrains.python.packaging.PyPackageVersionComparator.STR_COMPARATOR
|
||||
import com.jetbrains.python.sdk.PySdkUtil
|
||||
import com.jetbrains.python.sdk.PythonSdkUtil
|
||||
import com.jetbrains.python.sdk.pythonSdk
|
||||
import com.jetbrains.python.statistics.modules
|
||||
import kotlinx.coroutines.*
|
||||
@@ -54,22 +55,28 @@ class PyPackagingToolWindowService(val project: Project) : Disposable {
|
||||
currentJob?.cancel()
|
||||
selectedPackage = pkg
|
||||
currentJob = GlobalScope.launch(Dispatchers.Default) {
|
||||
val response = fetchPackageInfo(selectedPackage!!.name)
|
||||
if (response != null) {
|
||||
val packageDetails = gson.fromJson(response, PyPIPackageUtil.PackageDetails::class.java)
|
||||
selectedInfo = with(packageDetails.info) {
|
||||
val renderedDescription = when {
|
||||
description.isNotEmpty() -> convertToHTML(descriptionContentType, description)
|
||||
summary.isNotEmpty() -> wrapHtml(summary)
|
||||
else -> PyPackagingToolWindowPanel.NO_DESCRIPTION
|
||||
}
|
||||
PackageInfo(projectUrls["Documentation"],
|
||||
renderedDescription,
|
||||
packageDetails.releases.sortedWith(STR_COMPARATOR.reversed()))
|
||||
}
|
||||
if (PythonSdkUtil.isRemote(currentSdk)) {
|
||||
selectedInfo = REMOTE_INTERPRETER_INFO
|
||||
}
|
||||
else {
|
||||
selectedInfo = EMPTY_INFO
|
||||
val response = fetchPackageInfo(selectedPackage!!.name)
|
||||
if (response != null) {
|
||||
val packageDetails = gson.fromJson(response, PyPIPackageUtil.PackageDetails::class.java)
|
||||
|
||||
selectedInfo = with(packageDetails.info) {
|
||||
val renderedDescription = when {
|
||||
description.isNotEmpty() -> convertToHTML(descriptionContentType, description)
|
||||
summary.isNotEmpty() -> wrapHtml(summary)
|
||||
else -> PyPackagingToolWindowPanel.NO_DESCRIPTION
|
||||
}
|
||||
PackageInfo(projectUrls["Documentation"],
|
||||
renderedDescription,
|
||||
packageDetails.releases.sortedWith(STR_COMPARATOR.reversed()))
|
||||
}
|
||||
}
|
||||
else {
|
||||
selectedInfo = EMPTY_INFO
|
||||
}
|
||||
}
|
||||
|
||||
if (isActive) {
|
||||
@@ -247,5 +254,6 @@ class PyPackagingToolWindowService(val project: Project) : Disposable {
|
||||
|
||||
companion object {
|
||||
private val EMPTY_INFO = PackageInfo(null, PyPackagingToolWindowPanel.REQUEST_FAILED_TEXT, emptyList())
|
||||
private val REMOTE_INTERPRETER_INFO = PackageInfo(null, PyPackagingToolWindowPanel.REMOTE_INTERPRETER_TEXT, emptyList())
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user