fixed PY-8025 Enable rest, epytext and doctest highlighting in strings literal assigned to __doc__

This commit is contained in:
Ekaterina Tuzova
2013-02-20 15:47:57 +04:00
parent 4713082a57
commit 2d801a8dba
3 changed files with 15 additions and 1 deletions

View File

@@ -30,7 +30,7 @@ public class DocStringAnnotator extends PyAnnotator {
@Override
public void visitPyAssignmentStatement(PyAssignmentStatement node) {
PyExpression left = node.getLeftHandSideExpression();
if (left != null && "__doc__".equals(left.getText())) {
if (left != null && "__doc__".equals(left.getName())) {
PyExpression right = node.getAssignedValue();
if (right instanceof PyStringLiteralExpression) {
Annotation ann = getHolder().createInfoAnnotation(right, null);

View File

@@ -0,0 +1,10 @@
__doc__= <info descr="null">"""<info descr="null">:param</info> v: """</info>
def <info descr="null">foo</info>(<info descr="null">a</info>, <info descr="null">v</info>):
"""
<info descr="null">:param</info> a:
<info descr="null">:param</info> v:
"""
pass
foo.<info descr="null">__doc__</info>= <info descr="null">"""<info descr="null">:param</info> v: """</info>

View File

@@ -170,6 +170,10 @@ public class PythonHighlightingTest extends PyTestCase {
doTest(LanguageLevel.PYTHON32, true, false);
}
public void testDocstring() { // PY-8025
doTest(false, true);
}
public void testYieldInNestedFunction() {
// highlight func declaration first, lest we get an "Extra fragment highlighted" error.
EditorColorsManager manager = EditorColorsManager.getInstance();