]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/markdown/html/SCLDocumentationExtensionNodeHandler.java
Merged changes from feature/scl to master.
[simantics/platform.git] / bundles / org.simantics.scl.compiler / src / org / simantics / scl / compiler / markdown / html / SCLDocumentationExtensionNodeHandler.java
index d971f7d0faf8735fe1bb8377432e1de0fa34ff1b..bec138283039b19b42582922c70cf9aec23a717f 100644 (file)
@@ -7,6 +7,7 @@ import org.simantics.scl.compiler.common.datatypes.Constructor;
 import org.simantics.scl.compiler.elaboration.modules.SCLValue;
 import org.simantics.scl.compiler.elaboration.modules.TypeClass;
 import org.simantics.scl.compiler.elaboration.modules.TypeConstructor;
+import org.simantics.scl.compiler.elaboration.modules.TypeDescriptor;
 import org.simantics.scl.compiler.environment.filter.AcceptAllNamespaceFilter;
 import org.simantics.scl.compiler.errors.Failable;
 import org.simantics.scl.compiler.markdown.internal.ExtensionNodeHandler;
@@ -279,11 +280,10 @@ public class SCLDocumentationExtensionNodeHandler implements ExtensionNodeHandle
     }
     
     private void generateDataDocumentation(Node container, Module module, String name) {
-        TypeConstructor typeConstructor = module.getTypeConstructor(name);
-        if(typeConstructor == null) {
+        TypeDescriptor typeDescriptor = module.getTypeDescriptor(name);
+        if(typeDescriptor == null) {
             StringBuilder error = new StringBuilder();
-            error.append("Didn't find the type constructor '" + name + "'.");
-            System.err.println(error);
+            error.append("Didn't find the type " + name + ".");
             container.addChild(new CodeBlockNode(error));
             return;
         }
@@ -292,10 +292,12 @@ public class SCLDocumentationExtensionNodeHandler implements ExtensionNodeHandle
         StringBuilder signature = new StringBuilder();
         signature.append("<div class=\"code-doc-box\"><div class=\"code\">");
         signature.append("data ");
-        signature.append(typeConstructor.name.name);
-        for(TVar p : typeConstructor.parameters) {
-            signature.append(' ');
-            p.toName(tuc, signature);
+        signature.append(typeDescriptor.name.name);
+        if(typeDescriptor instanceof TypeConstructor) {
+            for(TVar p : ((TypeConstructor)typeDescriptor).parameters) {
+                signature.append(' ');
+                p.toName(tuc, signature);
+            }
         }
         String moduleName = module.getName();
         if(!moduleName.equals(documentationName)) {
@@ -304,17 +306,19 @@ public class SCLDocumentationExtensionNodeHandler implements ExtensionNodeHandle
         signature.append("</div><div class=\"doc\">");
         container.addChild(new HtmlNode(signature));
         
-        if(typeConstructor.documentation != null) {
+        if(typeDescriptor.getDocumentation() != null) {
             MarkdownParser parser = new MarkdownParser();
-            container.addChild(parser.parseDocument(typeConstructor.documentation));
+            container.addChild(parser.parseDocument(typeDescriptor.getDocumentation()));
         }
         else
             System.out.println(name);
         
-        for(Constructor constructor : typeConstructor.constructors) {
-            if(!documentedValues.add(constructor.name.name))
-                System.err.println("Method '" + constructor.name.name + "' has already been documented in " + documentationName + ".");
-            generateValueDocumentation(container, module, constructor.name.name, new TypeUnparsingContext(tuc));
+        if(typeDescriptor instanceof TypeConstructor) {
+            for(Constructor constructor : ((TypeConstructor)typeDescriptor).constructors) {
+                if(!documentedValues.add(constructor.name.name))
+                    System.err.println("Method '" + constructor.name.name + "' has already been documented in " + documentationName + ".");
+                generateValueDocumentation(container, module, constructor.name.name, new TypeUnparsingContext(tuc));
+            }
         }
         container.addChild(new HtmlNode("</div></div>"));
     }