X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;ds=sidebyside;f=bundles%2Forg.simantics.scl.compiler%2Fsrc%2Forg%2Fsimantics%2Fscl%2Fcompiler%2Fmarkdown%2Fhtml%2FSCLDocumentationExtensionNodeHandler.java;h=d9e65e28c39208b575234aae41e3a94000702912;hb=1dfeb7d5c49b1391cd9d877e1eddab18995cb151;hp=d971f7d0faf8735fe1bb8377432e1de0fa34ff1b;hpb=3303fe4a3b363e88662ac75a4f7e873ddb3ab352;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/markdown/html/SCLDocumentationExtensionNodeHandler.java b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/markdown/html/SCLDocumentationExtensionNodeHandler.java index d971f7d0f..d9e65e28c 100644 --- a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/markdown/html/SCLDocumentationExtensionNodeHandler.java +++ b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/markdown/html/SCLDocumentationExtensionNodeHandler.java @@ -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; @@ -22,6 +23,8 @@ import org.simantics.scl.compiler.types.TPred; import org.simantics.scl.compiler.types.TVar; import org.simantics.scl.compiler.types.Types; import org.simantics.scl.compiler.types.util.TypeUnparsingContext; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import gnu.trove.map.hash.THashMap; import gnu.trove.procedure.TObjectProcedure; @@ -29,6 +32,7 @@ import gnu.trove.set.hash.THashSet; public class SCLDocumentationExtensionNodeHandler implements ExtensionNodeHandler { + private static final Logger LOGGER = LoggerFactory.getLogger(SCLDocumentationExtensionNodeHandler.class); final ModuleRepository moduleRepository; final String documentationName; @@ -55,7 +59,7 @@ public class SCLDocumentationExtensionNodeHandler implements ExtensionNodeHandle if(name.isEmpty()) continue; if(!documentedValues.add(name)) - System.err.println("Value '" + name + "' has already been documented in " + documentationName + "."); + LOGGER.warn("Value '" + name + "' has already been documented in " + documentationName + "."); generateValueDocumentation(container, name); } return container; @@ -68,7 +72,7 @@ public class SCLDocumentationExtensionNodeHandler implements ExtensionNodeHandle if(name.isEmpty()) continue; if(!documentedClasses.add(name)) - System.err.println("Class '" + name + "' has already been documented in " + documentationName + "."); + LOGGER.warn("Class '" + name + "' has already been documented in " + documentationName + "."); generateClassDocumentation(container, name); } return container; @@ -81,7 +85,7 @@ public class SCLDocumentationExtensionNodeHandler implements ExtensionNodeHandle if(name.isEmpty()) continue; if(!documentedTypeConstructors.add(name)) - System.err.println("Type constructor '" + name + "' has already been documented in " + documentationName + "."); + LOGGER.warn("Type constructor '" + name + "' has already been documented in " + documentationName + "."); generateDataDocumentation(container, name); } return container; @@ -121,7 +125,7 @@ public class SCLDocumentationExtensionNodeHandler implements ExtensionNodeHandle if(relatedModule == null) { relatedModule = moduleRepository.getModule(documentationName); if(!relatedModule.didSucceed()) - System.err.println("Couldn't load the module " + documentationName); + LOGGER.warn("Couldn't load the module " + documentationName); } if(relatedModule.didSucceed()) return relatedModule.getResult(); @@ -135,7 +139,7 @@ public class SCLDocumentationExtensionNodeHandler implements ExtensionNodeHandle fm = moduleRepository.getModule(moduleName); moduleCache.put(moduleName, fm); if(!fm.didSucceed()) - System.err.println("Couldn't load the module " + moduleName); + LOGGER.warn("Couldn't load the module " + moduleName); } if(fm.didSucceed()) return fm.getResult(); @@ -164,12 +168,12 @@ public class SCLDocumentationExtensionNodeHandler implements ExtensionNodeHandle if(value == null) { StringBuilder error = new StringBuilder(); error.append("Didn't find the value '" + name + "'."); - System.err.println(error); + LOGGER.error(error.toString()); container.addChild(new CodeBlockNode(error)); return; } if(value.isPrivate()) - System.err.println("Documentation " + documentationName + " refers to a private value " + name + "."); + LOGGER.warn("Documentation " + documentationName + " refers to a private value " + name + "."); StringBuilder signature = new StringBuilder(); signature.append("
")); } @@ -220,7 +224,7 @@ public class SCLDocumentationExtensionNodeHandler implements ExtensionNodeHandle if(typeClass == null) { StringBuilder error = new StringBuilder(); error.append("Didn't find the type class '" + name + "'."); - System.err.println(error); + LOGGER.error(error.toString()); container.addChild(new CodeBlockNode(error)); return; } @@ -254,11 +258,11 @@ public class SCLDocumentationExtensionNodeHandler implements ExtensionNodeHandle container.addChild(parser.parseDocument(typeClass.documentation)); } else - System.out.println(name); + LOGGER.info(name); for(String methodName : typeClass.methodNames) { if(!documentedValues.add(methodName)) - System.err.println("Method '" + methodName + "' has already been documented in " + documentationName + "."); + LOGGER.warn("Method '" + methodName + "' has already been documented in " + documentationName + "."); generateValueDocumentation(container, module, methodName, new TypeUnparsingContext(tuc)); } container.addChild(new HtmlNode("")); @@ -279,11 +283,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 +295,12 @@ public class SCLDocumentationExtensionNodeHandler implements ExtensionNodeHandle StringBuilder signature = new StringBuilder(); signature.append("
"); 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 +309,19 @@ public class SCLDocumentationExtensionNodeHandler implements ExtensionNodeHandle signature.append("
"); 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); + LOGGER.info(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)) + LOGGER.warn("Method '" + constructor.name.name + "' has already been documented in " + documentationName + "."); + generateValueDocumentation(container, module, constructor.name.name, new TypeUnparsingContext(tuc)); + } } container.addChild(new HtmlNode("
")); }