import org.opendaylight.mdsal.binding.javav2.generator.util.JavaIdentifier;
import org.opendaylight.mdsal.binding.javav2.generator.util.JavaIdentifierNormalizer;
import org.opendaylight.mdsal.binding.javav2.generator.util.Types;
+import org.opendaylight.mdsal.binding.javav2.generator.util.YangSnippetCleaner;
import org.opendaylight.mdsal.binding.javav2.generator.util.generated.type.builder.GeneratedTOBuilderImpl;
import org.opendaylight.mdsal.binding.javav2.generator.yang.types.TypeProviderImpl;
import org.opendaylight.mdsal.binding.javav2.model.api.AccessModifier;
sb.append(NEW_LINE);
sb.append("<pre>");
sb.append(NEW_LINE);
- sb.append(encodeAngleBrackets(yangTemplateForNode.render(schemaNode, module).body()));
+ String formedYang = YangSnippetCleaner.clean(yangTemplateForNode.render(schemaNode, module).body());
+ sb.append(encodeAngleBrackets(formedYang));
sb.append("</pre>");
sb.append(NEW_LINE);
sb.append("The schema path to identify an instance is");
sb.append(NEW_LINE);
sb.append("<pre>");
sb.append(NEW_LINE);
- sb.append(encodeAngleBrackets(yangTemplateForModule.render(module).body()));
+ String formedYang = YangSnippetCleaner.clean(yangTemplateForModule.render(module).body());
+ sb.append(encodeAngleBrackets(formedYang));
sb.append("</pre>");
}
}
}
@if(module.getRevision() != null) {
- revision @{SimpleDateFormatUtil.getRevisionFormat().format(module.getRevision())} {
- @for(effectiveStatement <- module.asInstanceOf[EffectiveStatement[_, _]].effectiveSubstatements()){
- @if(effectiveStatement.getDeclared().isInstanceOf[RevisionStatement]){
- description "@{effectiveStatement.asInstanceOf[DocumentedNode].getDescription()}";
+ @for(effectiveStatement <- module.asInstanceOf[EffectiveStatement[_, _]].effectiveSubstatements()){
+ @if(effectiveStatement.getDeclared().isInstanceOf[RevisionStatement]){
+ @if(effectiveStatement.asInstanceOf[DocumentedNode].getDescription() == null || effectiveStatement.asInstanceOf[DocumentedNode].getDescription().isEmpty()){
+ revision @{SimpleDateFormatUtil.getRevisionFormat().format(module.getRevision())};
+ } else {
+ revision @{SimpleDateFormatUtil.getRevisionFormat().format(module.getRevision())} {
+ description "@{effectiveStatement.asInstanceOf[DocumentedNode].getDescription()}";
+ }
}
}
}
assertEquals(7, test_i[0]);
}
+ @Test
+ public void generateTypesDescriptionsTest() throws Exception {
+ final BindingGenerator bg = new BindingGeneratorImpl(true);
+ final SchemaContext context = YangParserTestUtils.parseYangSources("/base/with_import/");
+ assertNotNull(context);
+
+ final List<Type> generateTypes = bg.generateTypes(context, context.getModules());
+ assertNotNull(generateTypes);
+ assertTrue(!generateTypes.isEmpty());
+
+ for (final Type type : generateTypes) {
+ if (type.getName().equals("TestData")) {
+ final String description = ((GeneratedType) type).getDescription().get();
+ description
+ .contains(" import test-import { prefix \"imported-test\"; revision-date 2017-04-21; }\n\n");
+ description.contains(" revision 2017-02-06;\n\n");
+ description.contains(" typedef my-type {\n type int8;\n }");
+ description.contains(" container *my-cont {\n }\n");
+ }
+ }
+ }
+
private void testActualType(final GeneratedType t, final int[] test_i) {
MethodSignature methodSignature = null;
switch (t.getName()) {
--- /dev/null
+module test-import {
+
+ yang-version 1;
+ namespace "urn:test:simple:test:import";
+ prefix "test-import";
+
+ revision 2017-04-21;
+
+ container *my-import-%cont {
+ }
+}
\ No newline at end of file
--- /dev/null
+module test {
+
+ yang-version 1;
+ namespace "urn:test:simple:test";
+ prefix "test";
+
+ import test-import { prefix "imported-test"; revision-date 2017-04-21; }
+
+ revision 2017-02-06;
+
+ typedef my-type {
+ type int8;
+ }
+
+ container *my-cont {
+ }
+}
\ No newline at end of file