use of com.jetbrains.python.documentation.docstrings.SectionBasedDocString.SectionField in project intellij-community by JetBrains.
the class PySectionBasedDocStringTest method testGoogleEmptyParamTypeInParenthesis.
public void testGoogleEmptyParamTypeInParenthesis() {
final GoogleCodeStyleDocString docString = findAndParseGoogleStyleDocString();
assertSize(1, docString.getSections());
final Section paramSection = docString.getSections().get(0);
assertEquals("parameters", paramSection.getNormalizedTitle());
assertSize(1, paramSection.getFields());
final SectionField param1 = paramSection.getFields().get(0);
assertEquals("x", param1.getName());
assertEmpty(param1.getDescription());
assertEmpty(param1.getType());
assertNotNull(param1.getTypeAsSubstring());
assertEquals(26, param1.getTypeAsSubstring().getStartOffset());
assertEquals(26, param1.getTypeAsSubstring().getEndOffset());
}
use of com.jetbrains.python.documentation.docstrings.SectionBasedDocString.SectionField in project intellij-community by JetBrains.
the class PySectionBasedDocStringTest method testNamedReturnsAndYields.
public void testNamedReturnsAndYields() {
final GoogleCodeStyleDocString docString = findAndParseGoogleStyleDocString();
assertEmpty(docString.getSummary());
assertSize(2, docString.getSections());
final Section returnSection = docString.getSections().get(0);
assertSize(2, returnSection.getFields());
final SectionField return1 = returnSection.getFields().get(0);
assertEquals("status_code", return1.getName());
assertEquals("int", return1.getType());
assertEquals("HTTP status code", return1.getDescription());
final SectionField return2 = returnSection.getFields().get(1);
assertEquals("template", return2.getName());
assertEquals("str", return2.getType());
assertEquals("path to template in template roots", return2.getDescription());
final Section yieldSection = docString.getSections().get(1);
assertSize(1, yieldSection.getFields());
final SectionField yield1 = yieldSection.getFields().get(0);
assertEquals("progress", yield1.getName());
assertEquals("float", yield1.getType());
assertEquals("floating point value in range [0, 1) indicating progress\n" + "of the task", yield1.getDescription());
}
use of com.jetbrains.python.documentation.docstrings.SectionBasedDocString.SectionField 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.SectionField 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.SectionField 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());
}
Aggregations