diff --git a/python/src/com/jetbrains/python/documentation/PythonDocumentationProvider.java b/python/src/com/jetbrains/python/documentation/PythonDocumentationProvider.java index bb32343dda0d..2c3758a0946d 100644 --- a/python/src/com/jetbrains/python/documentation/PythonDocumentationProvider.java +++ b/python/src/com/jetbrains/python/documentation/PythonDocumentationProvider.java @@ -31,9 +31,11 @@ import com.intellij.openapi.ui.Messages; import com.intellij.openapi.util.Computable; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.psi.*; +import com.intellij.psi.tree.IElementType; import com.intellij.psi.util.PsiTreeUtil; import com.intellij.psi.util.QualifiedName; import com.jetbrains.python.PyNames; +import com.jetbrains.python.PyTokenTypes; import com.jetbrains.python.PythonDialectsTokenSetProvider; import com.jetbrains.python.codeInsight.stdlib.PyStdlibDocumentationLinkProvider; import com.jetbrains.python.console.PydevConsoleRunner; @@ -547,9 +549,23 @@ public class PythonDocumentationProvider extends AbstractDocumentationProvider i public PsiElement getCustomDocumentationElement(@NotNull Editor editor, @NotNull PsiFile file, @Nullable PsiElement contextElement) { - if (contextElement != null && - PythonDialectsTokenSetProvider.INSTANCE.getKeywordTokens().contains(contextElement.getNode().getElementType())) { - return contextElement; + if (contextElement != null) { + final IElementType elementType = contextElement.getNode().getElementType(); + if (PythonDialectsTokenSetProvider.INSTANCE.getKeywordTokens().contains(elementType)) { + return contextElement; + } + if (PyTokenTypes.LPAR == elementType || PyTokenTypes.RPAR == elementType) { + final PyCallExpression expression = PsiTreeUtil.getParentOfType(contextElement, PyCallExpression.class); + if (expression != null) { + final PyExpression callee = expression.getCallee(); + if (callee != null) { + final PsiReference reference = callee.getReference(); + if (reference != null) { + return reference.resolve(); + } + } + } + } } return super.getCustomDocumentationElement(editor, file, contextElement); } diff --git a/python/testData/quickdoc/ArgumentList.html b/python/testData/quickdoc/ArgumentList.html new file mode 100644 index 000000000000..e4cfe0fd4e36 --- /dev/null +++ b/python/testData/quickdoc/ArgumentList.html @@ -0,0 +1 @@ +
def foo()
Inferred type: () -> None
Doc of foo.
\ No newline at end of file
diff --git a/python/testData/quickdoc/ArgumentList.py b/python/testData/quickdoc/ArgumentList.py
new file mode 100644
index 000000000000..6aff48527784
--- /dev/null
+++ b/python/testData/quickdoc/ArgumentList.py
@@ -0,0 +1,6 @@
+# directly in function
+def foo():
+ "def len(o: Sized)
Inferred type: (o: Sized) -> int
len(object) -> integer
Return the number of items of a sequence or collection.
def len(o: Sized)
Inferred type: (o: Sized) -> int
len(object) -> integer
Return the number of items of a sequence or collection.
diff --git a/python/testSrc/com/jetbrains/python/PyQuickDocTest.java b/python/testSrc/com/jetbrains/python/PyQuickDocTest.java
index 1e7823e065f5..ce5ae9d67346 100644
--- a/python/testSrc/com/jetbrains/python/PyQuickDocTest.java
+++ b/python/testSrc/com/jetbrains/python/PyQuickDocTest.java
@@ -292,6 +292,14 @@ public class PyQuickDocTest extends LightMarkedTestCase {
checkHTMLOnly();
}
+ public void testArgumentList() {
+ Map