+ private def dispatch CharSequence tree(DataSchemaNode node,YangInstanceIdentifier path) '''
+ «node.nodeName»
+ '''
+
+ private def dispatch CharSequence tree(ListSchemaNode node,YangInstanceIdentifier path) '''
+ «val newPath = path.append(node)»
+ «localLink(newPath,node.nodeName)»
+ «node.childNodes.treeSet(newPath)»
+ '''
+
+ private def dispatch CharSequence tree(ContainerSchemaNode node,YangInstanceIdentifier path) '''
+ «val newPath = path.append(node)»
+ «localLink(newPath,node.nodeName)»
+ «node.childNodes.treeSet(newPath)»
+ '''
+
+ def CharSequence childNodes(Module module) '''
+ «val childNodes = module.childNodes»
+ «IF !childNodes.nullOrEmpty»
+ <h2>Child nodes</h2>
+
+ «childNodes.printChildren(3,YangInstanceIdentifier.builder().toInstance())»
+ «ENDIF»
+ '''
+
+ def CharSequence printSchemaNodeInfo(DataSchemaNode node) {
+ return '''
+ <ul>
+ «node.printBaseInfo»
+ «IF node instanceof DataNodeContainer»
+ «val dataNode = node as DataNodeContainer»
+ <ul>
+ «FOR usesNode : dataNode.uses»
+ «usesNode.printUses»
+ «ENDFOR»
+ </ul>
+ <ul>
+ «val Set<TypeDefinition<?>> typeDefinitions = dataNode.typeDefinitions»
+ «FOR typeDef : typeDefinitions»
+ «typeDef.restrictions»
+ «ENDFOR»
+ </ul>
+ <ul>
+ «FOR grouping : dataNode.groupings»
+ «grouping.printGrouping»
+ «ENDFOR»
+ </ul>
+ <ul>
+ «FOR child : dataNode.childNodes»
+ «child.printSchemaNodeInfo»
+ «ENDFOR»
+ </ul>
+ «ENDIF»
+ </ul>
+ '''
+ }
+
+ def String typeAnchorLink(SchemaPath path, CharSequence text) {
+ if(path !== null) {
+ val lastElement = Iterables.getLast(path.pathFromRoot)
+ val ns = lastElement.namespace
+ if (ns == this.currentModule.namespace) {
+ return '''<a href="#«path.schemaPathToId»">«text»</a>'''
+ } else {
+ return '''(«ns»)«text»'''
+ //to enable external (import) links
+ //return '''<a href="«module».html#«path.schemaPathToId»">«prefix»:«text»</a>'''
+ }
+ }
+ }
+
+ def CharSequence printBaseInfo(SchemaNode node) {
+ if(node instanceof LeafSchemaNode) {
+ val LeafSchemaNode leafNode = (node as LeafSchemaNode)
+ return '''
+ «printInfo(node, "leaf")»
+ «listItem("type", typeAnchorLink(leafNode.type?.path, leafNode.type.QName.localName))»
+ «listItem("units", leafNode.units)»
+ «listItem("default", leafNode.^default)»
+ </ul>
+ '''
+ } else if(node instanceof LeafListSchemaNode) {
+ val LeafListSchemaNode leafListNode = (node as LeafListSchemaNode)
+ return '''
+ «printInfo(node, "leaf-list")»
+ «listItem("type", leafListNode.type?.QName.localName)»
+ </ul>
+ '''
+ } else if(node instanceof ListSchemaNode) {
+ val ListSchemaNode listNode = (node as ListSchemaNode)
+ return '''
+ «printInfo(node, "list")»
+ «FOR keyDef : listNode.keyDefinition»
+ «listItem("key definition", keyDef.localName)»
+ «ENDFOR»
+ </ul>
+ '''
+ } else if(node instanceof ChoiceNode) {
+ val ChoiceNode choiceNode = (node as ChoiceNode)
+ return '''
+ «printInfo(node, "choice")»
+ «listItem("default case", choiceNode.defaultCase)»
+ «FOR caseNode : choiceNode.cases»
+ «caseNode.printSchemaNodeInfo»
+ «ENDFOR»
+ </ul>
+ '''
+ } else if(node instanceof ChoiceCaseNode) {
+ return '''
+ «printInfo(node, "case")»
+ </ul>
+ '''
+ } else if(node instanceof ContainerSchemaNode) {
+ return '''
+ «printInfo(node, "container")»
+ </ul>
+ '''
+ } else if(node instanceof AnyXmlSchemaNode) {
+ return '''
+ «printInfo(node, "anyxml")»
+ </ul>
+ '''
+ }
+ }
+
+ def CharSequence printInfo(SchemaNode node, String nodeType) {
+ return '''
+ «IF node instanceof AugmentationTarget»
+ «IF node !== null»
+ <strong>
+ <li id="«node.path.schemaPathToId»">
+ «nodeType»: «node.QName.localName»
+ </li>
+ </strong>
+ «ENDIF»
+ «ELSE»
+ «strong(listItem(nodeType, node.QName.localName))»
+ «ENDIF»
+ <ul>
+ «listItem("description", node.description)»
+ «listItem("reference", node.reference)»
+ «IF node instanceof DataSchemaNode»
+ «listItem("when condition", (node as DataSchemaNode).constraints.whenCondition?.toString)»
+ «listItem("min elements", (node as DataSchemaNode).constraints.minElements?.toString)»
+ «listItem("max elements", (node as DataSchemaNode).constraints.maxElements?.toString)»
+ «ENDIF»
+ '''
+ }
+
+ def CharSequence printUses(UsesNode usesNode) {
+ return '''
+ «strong(listItem("uses", typeAnchorLink(usesNode.groupingPath, usesNode.groupingPath.pathTowardsRoot.iterator.next.localName)))»
+ <ul>
+ <li>refines:
+ <ul>
+ «FOR sp : usesNode.refines.keySet»
+ «listItem("node name", usesNode.refines.get(sp).QName.localName)»
+ «ENDFOR»
+ </ul>
+ </li>
+ «FOR augment : usesNode.augmentations»
+ «typeAnchorLink(augment.targetPath,schemaPathToString(currentModule, augment.targetPath, ctx, augment))»