mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
PY-31033 Render parameter default values in Quick Documentation
At the moment we render them "as is" only escaping their text similarly to how it's done for TypeScript, not trimming it to the first line as in case of target expression initializers.
This commit is contained in:
@@ -283,6 +283,12 @@ public class PythonDocumentationProvider extends AbstractDocumentationProvider i
|
||||
result.append(": ");
|
||||
result.append(formatTypeWithLinks(paramType, function, context));
|
||||
}
|
||||
final String defaultValue = parameter.getDefaultValueText();
|
||||
if (defaultValue != null) {
|
||||
// According to PEP 8 equal sign should be surrounded by spaces if annotation is present
|
||||
result.append(showType ? " = " : "=");
|
||||
result.append(escaped(defaultValue));
|
||||
}
|
||||
first = false;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
<html><body><div class='definition'><pre><a href="psi_element://#typename#DefaultValues.C">DefaultValues.C</a><br>def <b>method</b>(self=42,
|
||||
foo: List[<a href="psi_element://#typename#int">int</a>] = [1,
|
||||
2],
|
||||
bar: <a href="psi_element://#typename#str">str</a> = "<br/>") -> None</pre></div></body></html>
|
||||
@@ -0,0 +1,5 @@
|
||||
class C:
|
||||
def met<the_ref>hod(self=42, foo=[1,
|
||||
2],
|
||||
bar="<br/>"):
|
||||
pass
|
||||
@@ -1,3 +1,3 @@
|
||||
def ones(shape: Union[<a href="psi_element://#typename#int">int</a>, Iterable[<a href="psi_element://#typename#int">int</a>]], dtype: Optional[<a href="psi_element://#typename#object">object</a>], order: Optional[<a href="psi_element://#typename#str">str</a>]) -> <a href="psi_element://#typename#ndarray">ndarray</a>
|
||||
def ones(shape: Union[<a href="psi_element://#typename#int">int</a>, Iterable[<a href="psi_element://#typename#int">int</a>]], dtype: Optional[<a href="psi_element://#typename#object">object</a>] = None, order: Optional[<a href="psi_element://#typename#str">str</a>] = 'C') -> <a href="psi_element://#typename#ndarray">ndarray</a>
|
||||
**Test docstring**
|
||||
Return a new array of given shape and type, filled with ones.
|
||||
@@ -1,2 +1,2 @@
|
||||
<html><body><div class='definition'><pre><a href="psi_element://#module#OptionalParameterType">OptionalParameterType</a><br>def <b>open</b>(encoding: Optional[<a href="psi_element://#typename#str">str</a>],
|
||||
errors: Optional[<a href="psi_element://#typename#str">str</a>]) -> None</pre></div></body></html>
|
||||
<html><body><div class='definition'><pre><a href="psi_element://#module#OptionalParameterType">OptionalParameterType</a><br>def <b>open</b>(encoding: Optional[<a href="psi_element://#typename#str">str</a>] = None,
|
||||
errors: Optional[<a href="psi_element://#typename#str">str</a>] = None) -> None</pre></div></body></html>
|
||||
@@ -69,6 +69,7 @@ public class PyQuickDocTest extends LightMarkedTestCase {
|
||||
private void checkHTMLOnly() {
|
||||
final Map<String, PsiElement> marks = loadTest();
|
||||
final PsiElement originalElement = marks.get("<the_ref>");
|
||||
assertNotNull("<the_ref> marker is missing in test data", originalElement);
|
||||
final DocumentationManager manager = DocumentationManager.getInstance(myFixture.getProject());
|
||||
final PsiElement target = manager.findTargetElement(myFixture.getEditor(),
|
||||
originalElement.getTextOffset(),
|
||||
@@ -566,6 +567,11 @@ public class PyQuickDocTest extends LightMarkedTestCase {
|
||||
checkHTMLOnly();
|
||||
}
|
||||
|
||||
// PY-31033
|
||||
public void testDefaultValues() {
|
||||
checkHTMLOnly();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getTestDataPath() {
|
||||
return super.getTestDataPath() + "/quickdoc/";
|
||||
|
||||
Reference in New Issue
Block a user