Tests and cosmetics for quickdoc.

This commit is contained in:
Dmitry Cheryasov
2010-09-13 17:07:08 +03:00
parent 6b3b834829
commit 07ecba288c
8 changed files with 49 additions and 2 deletions
@@ -49,10 +49,10 @@ public class PythonDocumentationProvider extends QuickDocumentationProvider {
PyClass cls = func.getContainingClass();
if (cls != null) {
String cls_name = cls.getName();
cat.append("class ").append(cls_name).append("\n ");
cat.append("class ").append(cls_name).append("\n");
// It would be nice to have class import info here, but we don't know the ctrl+hovered reference and context
}
return describeDecorators(func, LSame2, ", ", LSame1).add(describeFunction(func, LSame2, LSame1)).toString();
return $(cat.toString()).add(describeDecorators(func, LSame2, ", ", LSame1)).add(describeFunction(func, LSame2, LSame1)).toString();
}
else if (element instanceof PyClass) {
PyClass cls = (PyClass)element;
@@ -0,0 +1 @@
class A(object)
@@ -0,0 +1,9 @@
class A(object):
"Doc of A"
pass
class B(A):
"Doc of B"
pass
<the_ref>A
@@ -0,0 +1,2 @@
def foo(arg)
Inferred return type: int
@@ -0,0 +1,4 @@
def foo(arg):
return 1
<the_ref>foo
@@ -0,0 +1,3 @@
class A
def f(self)
Inferred return type: int
@@ -0,0 +1,7 @@
class A(object):
"doc of A"
def f(self):
return 1
A().<the_ref>f
@@ -67,6 +67,14 @@ public class PyQuickDocTest extends LightMarkedTestCase {
checkByHTML(myProvider.generateDoc(doc_owner, original_elt));
}
private void checkHover() throws Exception {
Map<String, PsiElement> marks = loadTest();
final PsiElement original_elt = marks.get("<the_ref>");
PsiElement ref_elt = original_elt.getParent(); // ident -> expr
final PyDocStringOwner doc_owner = (PyDocStringOwner)((PyReferenceExpression)ref_elt).getReference().resolve();
checkByHTML(myProvider.getQuickNavigateInfo(doc_owner));
}
public void testDirectFunc() throws Exception {
checkRefDocPair();
}
@@ -159,4 +167,17 @@ public class PyQuickDocTest extends LightMarkedTestCase {
public void testPropOldDeleter() throws Exception {
checkHTMLOnly();
}
public void testHoverOverClass() throws Exception {
checkHover();
}
public void testHoverOverFunction() throws Exception {
checkHover();
}
public void testHoverOverMethod() throws Exception {
checkHover();
}
}