PY-24854 Allow Quick Documentation invocation when caret is placed inside docstring

This commit is contained in:
Ekaterina Tuzova
2017-09-01 13:30:04 +03:00
parent 048e421e55
commit 99c0e6c3f4
4 changed files with 19 additions and 0 deletions
@@ -566,6 +566,10 @@ public class PythonDocumentationProvider extends AbstractDocumentationProvider i
}
}
}
if (PyTokenTypes.DOCSTRING == elementType) {
final PyDocStringOwner docstringOwner = PsiTreeUtil.getParentOfType(contextElement, PyDocStringOwner.class);
if (docstringOwner != null) return docstringOwner;
}
}
return super.getCustomDocumentationElement(editor, file, contextElement);
}
+1
View File
@@ -0,0 +1 @@
<html><body><code>def <b>foo</b>()<br>Inferred&nbsp;type:&nbsp;()&nbsp;-&gt;&nbsp;None<br><br>Doc&nbsp;of&nbsp;foo.</code></body></html>
+6
View File
@@ -0,0 +1,6 @@
# directly in function
def foo():
"<the_doc>Doc of <the_ref>foo."
pass
foo()
@@ -300,6 +300,14 @@ public class PyQuickDocTest extends LightMarkedTestCase {
checkByHTML(myProvider.generateDoc(element, originalElement));
}
public void testDocstring() {
Map<String, PsiElement> marks = loadTest();
final PsiElement originalElement = marks.get("<the_ref>");
final PsiElement element = myProvider.getCustomDocumentationElement(myFixture.getEditor(), myFile, originalElement);
checkByHTML(myProvider.generateDoc(element, originalElement));
}
public void testReferenceToMethodQualifiedWithInstance() {
checkHTMLOnly();
}