Search in sources :

Example 1 with PyDocumentationBuilder

use of com.jetbrains.python.documentation.PyDocumentationBuilder in project intellij-community by JetBrains.

the class PydevDocumentationProvider method createDoc.

@Nullable
public static String createDoc(final PsiElement element, final PsiElement originalElement) {
    final PyReferenceExpression expression = PsiTreeUtil.getNonStrictParentOfType(originalElement, PyReferenceExpression.class);
    // Indicates that we are inside console, not a lookup element!
    if (expression == null) {
        return null;
    }
    PydevConsoleReference consoleRef = PyUtil.as(expression.getReference(), PydevConsoleReference.class);
    if (consoleRef == null) {
        //shouldn't really happen!
        return null;
    }
    PyElement documentationElement = consoleRef.getDocumentationElement();
    if (documentationElement == null) {
        return null;
    }
    return new PyDocumentationBuilder(documentationElement, null).build();
}
Also used : PydevConsoleReference(com.jetbrains.python.console.completion.PydevConsoleReference) PyDocumentationBuilder(com.jetbrains.python.documentation.PyDocumentationBuilder) PyReferenceExpression(com.jetbrains.python.psi.PyReferenceExpression) PyElement(com.jetbrains.python.psi.PyElement) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

PydevConsoleReference (com.jetbrains.python.console.completion.PydevConsoleReference)1 PyDocumentationBuilder (com.jetbrains.python.documentation.PyDocumentationBuilder)1 PyElement (com.jetbrains.python.psi.PyElement)1 PyReferenceExpression (com.jetbrains.python.psi.PyReferenceExpression)1 Nullable (org.jetbrains.annotations.Nullable)1