mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
PY-29717 Wrap both prolog and body in <div class="definition"> block
This commit is contained in:
@@ -69,9 +69,9 @@ import static com.jetbrains.python.documentation.DocumentationBuilderKit.*;
|
||||
public class PyDocumentationBuilder {
|
||||
private final PsiElement myElement;
|
||||
private final PsiElement myOriginalElement;
|
||||
private ChainIterable<String> myResult;
|
||||
private final ChainIterable<String> myProlog; // sequence for reassignment info, etc
|
||||
private final ChainIterable<String> myBody; // sequence for doc string
|
||||
private final ChainIterable<String> myContent;
|
||||
private final ChainIterable<String> mySections;
|
||||
private final ChainIterable<String> myEpilog; // sequence for doc "copied from" notices and such
|
||||
|
||||
@@ -82,15 +82,11 @@ public class PyDocumentationBuilder {
|
||||
public PyDocumentationBuilder(PsiElement element, PsiElement originalElement) {
|
||||
myElement = element;
|
||||
myOriginalElement = originalElement;
|
||||
myResult = new ChainIterable<>();
|
||||
myProlog = new ChainIterable<>();
|
||||
myBody = new ChainIterable<>();
|
||||
myContent = new ChainIterable<>();
|
||||
mySections = new ChainIterable<>();
|
||||
myEpilog = new ChainIterable<>();
|
||||
|
||||
|
||||
myResult.add(myProlog).add(myBody).add(mySections).add(myEpilog); // pre-assemble; then add stuff to individual cats as needed
|
||||
myResult = wrapInTag("html", wrapInTag("body", myResult));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -144,11 +140,24 @@ public class PyDocumentationBuilder {
|
||||
myEpilog.addItem("<a href=\"").addItem(url).addItem("\">").addItem(url).addItem("</a>");
|
||||
}
|
||||
|
||||
if (myBody.isEmpty() && myEpilog.isEmpty()) {
|
||||
if (myBody.isEmpty() && myContent.isEmpty() && myEpilog.isEmpty()) {
|
||||
return null; // got nothing substantial to say!
|
||||
}
|
||||
else {
|
||||
return myResult.toString();
|
||||
ChainIterable<String> result = new ChainIterable<>();
|
||||
if (!myProlog.isEmpty() || !myBody.isEmpty()) {
|
||||
result.addItem(DocumentationMarkup.DEFINITION_START)
|
||||
.add(myProlog)
|
||||
.add(myBody)
|
||||
.addItem(DocumentationMarkup.DEFINITION_END);
|
||||
}
|
||||
if (!myContent.isEmpty()) {
|
||||
result.addItem(DocumentationMarkup.CONTENT_START)
|
||||
.add(myContent)
|
||||
.addItem(DocumentationMarkup.CONTENT_END);
|
||||
}
|
||||
result.add(mySections).add(myEpilog); // pre-assemble; then add stuff to individual cats as needed
|
||||
return wrapInTag("html", wrapInTag("body", result)).toString();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -297,7 +306,6 @@ public class PyDocumentationBuilder {
|
||||
content = formatDocString(myElement, docStringExpression.getStringValue());
|
||||
}
|
||||
final TypeEvalContext context = TypeEvalContext.userInitiated(elementDefinition.getProject(), elementDefinition.getContainingFile());
|
||||
myBody.addItem(DocumentationMarkup.DEFINITION_START);
|
||||
|
||||
if (elementDefinition instanceof PyClass) {
|
||||
pyClass = (PyClass)elementDefinition;
|
||||
@@ -340,11 +348,8 @@ public class PyDocumentationBuilder {
|
||||
myBody.add(PythonDocumentationProvider.describeTarget(target, context));
|
||||
}
|
||||
|
||||
myBody.addItem(DocumentationMarkup.DEFINITION_END);
|
||||
if (content != null && !content.isEmpty()) {
|
||||
myBody.addItem(DocumentationMarkup.CONTENT_START);
|
||||
myBody.add(content);
|
||||
myBody.addItem(DocumentationMarkup.CONTENT_END);
|
||||
myContent.add(content);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1 +1 @@
|
||||
<html><body>Class attribute <b><code>the_attr</code></b> of class <a href="psi_element://#class#"><code>C</code></a><br><div class='definition'><pre>the_attr: <a href="psi_element://#typename#str">str</a></pre></div><div class='content'>The documentation for the attribute. </div></body></html>
|
||||
<html><body><div class='definition'><pre>Class attribute <b><code>the_attr</code></b> of class <a href="psi_element://#class#"><code>C</code></a><br>the_attr: <a href="psi_element://#typename#str">str</a></pre></div><div class='content'>The documentation for the attribute. </div></body></html>
|
||||
@@ -1 +1 @@
|
||||
<html><body>Instance attribute <b><code>foo</code></b> of class <a href="psi_element://#class#"><code>C</code></a><br><div class='definition'><pre>foo: <a href="psi_element://#typename#str">str</a></pre></div><div class='content'>The docstring for the attribute foo. </div></body></html>
|
||||
<html><body><div class='definition'><pre>Instance attribute <b><code>foo</code></b> of class <a href="psi_element://#class#"><code>C</code></a><br>foo: <a href="psi_element://#typename#str">str</a></pre></div><div class='content'>The docstring for the attribute foo. </div></body></html>
|
||||
@@ -1 +1 @@
|
||||
<html><body>Module <b>Module</b><div class='definition'><pre></pre></div><div class='content'><br>Module's doc.</div></body></html>
|
||||
<html><body><div class='definition'><pre>Module <b>Module</b></pre></div><div class='content'><br>Module's doc.</div></body></html>
|
||||
@@ -1 +1 @@
|
||||
<html><body>Parameter name: <a href="psi_element://#param#">str</a><br>The name to convert to a label. This must be a string which could be used as a Python identifier. Strings which do not take this form will result in unpredictable behavior.</body></html>
|
||||
<html><body><div class='definition'><pre>Parameter name: <a href="psi_element://#param#">str</a></pre></div><br>The name to convert to a label. This must be a string which could be used as a Python identifier. Strings which do not take this form will result in unpredictable behavior.</body></html>
|
||||
@@ -1 +1 @@
|
||||
<html><body>property <b><code>x</code></b> of class <a href="psi_element://#class#">A</a>(<a href="psi_element://#typename#object">object</a>)<br><i>Copied from getter:</i><br>Does things to X<br><br><div class='definition'><pre>@<i>x.deleter</i><br>def <b>x</b>(self: <a href="psi_element://#typename#A">A</a>, v: Any) -> None</pre></div><div class='content'>Deletes X</div><small><br><br>Deleter of property</small><br></body></html>
|
||||
<html><body><div class='definition'><pre>property <b><code>x</code></b> of class <a href="psi_element://#class#">A</a>(<a href="psi_element://#typename#object">object</a>)<br><i>Copied from getter:</i><br>Does things to X<br><br>@<i>x.deleter</i><br>def <b>x</b>(self: <a href="psi_element://#typename#A">A</a>, v: Any) -> None</pre></div><div class='content'>Deletes X</div><small><br><br>Deleter of property</small><br></body></html>
|
||||
@@ -1 +1 @@
|
||||
<html><body>property <b><code>x</code></b> of class <a href="psi_element://#class#">A</a>(<a href="psi_element://#typename#object">object</a>)<code><br><br><div class='definition'><pre>@<i>property</i><br>def <b>x</b>(self: <a href="psi_element://#typename#A">A</a>) -> <a href="psi_element://#typename#int">int</a></pre></div><div class='content'>Does things to X</div></code><small><br><br>Getter of property</small><br></body></html>
|
||||
<html><body><div class='definition'><pre>property <b><code>x</code></b> of class <a href="psi_element://#class#">A</a>(<a href="psi_element://#typename#object">object</a>)<br><br>@<i>property</i><br>def <b>x</b>(self: <a href="psi_element://#typename#A">A</a>) -> <a href="psi_element://#typename#int">int</a></pre></div><div class='content'>Does things to X</div><small><br><br>Getter of property</small><br></body></html>
|
||||
@@ -1 +1 @@
|
||||
<html><body>property <b><code>x</code></b> of class <a href="psi_element://#class#">A</a>(<a href="psi_element://#typename#object">object</a>)<br><i>Copied from getter:</i><br>Does things to X<br><br><div class='definition'><pre>@<i>x.setter</i><br>def <b>x</b>(self: <a href="psi_element://#typename#A">A</a>, v: Any) -> None</pre></div><div class='content'>Sets X</div><small><br><br>Setter of property</small><br></body></html>
|
||||
<html><body><div class='definition'><pre>property <b><code>x</code></b> of class <a href="psi_element://#class#">A</a>(<a href="psi_element://#typename#object">object</a>)<br><i>Copied from getter:</i><br>Does things to X<br><br>@<i>x.setter</i><br>def <b>x</b>(self: <a href="psi_element://#typename#A">A</a>, v: Any) -> None</pre></div><div class='content'>Sets X</div><small><br><br>Setter of property</small><br></body></html>
|
||||
@@ -1 +1 @@
|
||||
<html><body>property <b><code>x</code></b> of class <a href="psi_element://#class#">A</a>(<a href="psi_element://#typename#object">object</a>)<br><br><div class='definition'><pre>def <b>__getX</b>(self: <a href="psi_element://#typename#A">A</a>) -> Any</pre></div><div class='content'>Doc of getter</div><small><br><br>Deleter of property</small><br></body></html>
|
||||
<html><body><div class='definition'><pre>property <b><code>x</code></b> of class <a href="psi_element://#class#">A</a>(<a href="psi_element://#typename#object">object</a>)<br><br>def <b>__getX</b>(self: <a href="psi_element://#typename#A">A</a>) -> Any</pre></div><div class='content'>Doc of getter</div><small><br><br>Deleter of property</small><br></body></html>
|
||||
@@ -1 +1 @@
|
||||
<html><body>property <b><code>x</code></b> of class <a href="psi_element://#class#">A</a>(<a href="psi_element://#typename#object">object</a>)<br><br><div class='definition'><pre>def <b>__getX</b>(self: <a href="psi_element://#typename#A">A</a>) -> Any</pre></div><div class='content'>Doc of getter</div><small><br><br>Getter of property</small><br></body></html>
|
||||
<html><body><div class='definition'><pre>property <b><code>x</code></b> of class <a href="psi_element://#class#">A</a>(<a href="psi_element://#typename#object">object</a>)<br><br>def <b>__getX</b>(self: <a href="psi_element://#typename#A">A</a>) -> Any</pre></div><div class='content'>Doc of getter</div><small><br><br>Getter of property</small><br></body></html>
|
||||
@@ -1 +1 @@
|
||||
<html><body>property <b><code>x</code></b> of class <a href="psi_element://#class#">A</a>(<a href="psi_element://#typename#object">object</a>)<br><br><div class='definition'><pre>def <b>__getX</b>(self: <a href="psi_element://#typename#A">A</a>, x: Any) -> None</pre></div><div class='content'>Doc of getter</div><small><br><br>Setter of property</small><br></body></html>
|
||||
<html><body><div class='definition'><pre>property <b><code>x</code></b> of class <a href="psi_element://#class#">A</a>(<a href="psi_element://#typename#object">object</a>)<br><br>def <b>__getX</b>(self: <a href="psi_element://#typename#A">A</a>, x: Any) -> None</pre></div><div class='content'>Doc of getter</div><small><br><br>Setter of property</small><br></body></html>
|
||||
Reference in New Issue
Block a user