use of com.jetbrains.python.documentation.docstrings.SectionBasedDocString.Section in project intellij-community by JetBrains.
the class PySectionBasedDocStringTest method testTypeReferences.
public void testTypeReferences() {
final GoogleCodeStyleDocString docString = findAndParseGoogleStyleDocString();
assertEmpty(docString.getSummary());
assertSize(2, docString.getSections());
final Section paramSection = docString.getSections().get(0);
assertSize(1, paramSection.getFields());
final SectionField param1 = paramSection.getFields().get(0);
assertEquals("a1", param1.getName());
assertEquals(":class:`MyClass`", param1.getType());
assertEquals("used to call :def:`my_function` and access :attr:`my_attr`", param1.getDescription());
final Section raisesSection = docString.getSections().get(1);
assertSize(1, raisesSection.getFields());
final SectionField exception1 = raisesSection.getFields().get(0);
assertEmpty(exception1.getName());
assertEquals(":class:`MyException`", exception1.getType());
assertEquals("thrown in case of any error", exception1.getDescription());
}
use of com.jetbrains.python.documentation.docstrings.SectionBasedDocString.Section in project intellij-community by JetBrains.
the class PySectionBasedDocStringTest method testGoogleNoColonAfterParameter.
public void testGoogleNoColonAfterParameter() {
final GoogleCodeStyleDocString docString = findAndParseGoogleStyleDocString();
assertSize(1, docString.getSections());
final Section paramSection = docString.getSections().get(0);
assertSize(2, paramSection.getFields());
final SectionField x = paramSection.getFields().get(0);
assertEquals("x", x.getName());
assertEmpty(x.getType());
assertEmpty(x.getDescription());
final SectionField y = paramSection.getFields().get(1);
assertEquals("y", y.getName());
assertEquals("int", y.getType());
assertEmpty(y.getDescription());
}
use of com.jetbrains.python.documentation.docstrings.SectionBasedDocString.Section in project intellij-community by JetBrains.
the class PySectionBasedDocStringTest method checkSimpleDocstringStructure.
private static void checkSimpleDocstringStructure(@NotNull SectionBasedDocString docString) {
assertEquals("Summary", docString.getSummary());
final List<Section> sections = docString.getSections();
assertSize(3, sections);
assertEquals("parameters", sections.get(0).getNormalizedTitle());
final List<SectionField> paramFields = sections.get(0).getFields();
assertSize(2, paramFields);
final SectionField param1 = paramFields.get(0);
assertEquals("x", param1.getName());
assertEquals("int", param1.getType());
assertEquals("first parameter", param1.getDescription());
final SectionField param2 = paramFields.get(1);
assertEquals("y", param2.getName());
assertEmpty(param2.getType());
assertEquals("second parameter\n" + "with longer description", param2.getDescription());
assertEquals("raises", sections.get(1).getNormalizedTitle());
final List<SectionField> exceptionFields = sections.get(1).getFields();
assertSize(1, exceptionFields);
final SectionField exception1 = exceptionFields.get(0);
assertEmpty(exception1.getName());
assertEquals("Exception", exception1.getType());
assertEquals("if anything bad happens", exception1.getDescription());
assertEquals("returns", sections.get(2).getNormalizedTitle());
final List<SectionField> returnFields = sections.get(2).getFields();
assertSize(1, returnFields);
final SectionField return1 = returnFields.get(0);
assertEmpty(return1.getName());
assertEquals("None", return1.getType());
assertEquals("always", return1.getDescription());
}
use of com.jetbrains.python.documentation.docstrings.SectionBasedDocString.Section in project intellij-community by JetBrains.
the class PySectionBasedDocStringTest method testNumpyCombinedParamDeclarations.
// PY-16908
public void testNumpyCombinedParamDeclarations() {
final NumpyDocString docString = findAndParseNumpyStyleDocString();
assertSize(1, docString.getSections());
final Section paramSection = docString.getSections().get(0);
assertSize(1, paramSection.getFields());
final SectionField firstField = paramSection.getFields().get(0);
assertSameElements(firstField.getNames(), "x", "y", "args", "kwargs");
assertEquals(firstField.getType(), "Any");
assertEquals(firstField.getDescription(), "description");
}
use of com.jetbrains.python.documentation.docstrings.SectionBasedDocString.Section in project intellij-community by JetBrains.
the class PySectionBasedDocStringTest method testSectionStartAfterQuotes.
public void testSectionStartAfterQuotes() {
final GoogleCodeStyleDocString docString = findAndParseGoogleStyleDocString();
assertEmpty(docString.getSummary());
assertSize(2, docString.getSections());
final Section examplesSection = docString.getSections().get(0);
assertEquals("examples", examplesSection.getNormalizedTitle());
assertSize(1, examplesSection.getFields());
final SectionField example1 = examplesSection.getFields().get(0);
assertEmpty(example1.getName());
assertEmpty(example1.getType());
assertEquals("Useless call\n" + "func() == func()", example1.getDescription());
final Section notesSection = docString.getSections().get(1);
assertEquals("notes", notesSection.getNormalizedTitle());
assertSize(1, notesSection.getFields());
final SectionField note1 = notesSection.getFields().get(0);
assertEmpty(note1.getName());
assertEmpty(note1.getType());
assertEquals("some\n" + "notes", note1.getDescription());
}
Aggregations