");
char firstChar = name.charAt(0);
if(!Character.isAlphabetic(firstChar) && firstChar != '_')
name = "(" + name + ")";
signature.append(HtmlEscape.escape(name)).append(" :: ");
String typeStr = Types.removeForAll(value.getType(), new ArrayList()).toString(tuc);
signature.append(HtmlEscape.escape(typeStr));
String moduleName = module.getName();
if(!moduleName.equals(documentationName)) {
signature.append(" (").append(moduleName).append(")");
}
signature.append("
");
container.addChild(new HtmlNode(signature));
if(value.documentation != null) {
MarkdownParser parser = new MarkdownParser();
container.addChild(parser.parseDocument(value.documentation));
}
else
System.out.println(name);
container.addChild(new HtmlNode("
"));
}
private void generateValueDocumentation(Node container, Module module, String name) {
generateValueDocumentation(container, module, name, new TypeUnparsingContext());
}
private void generateClassDocumentation(Node container, String name) {
int p = name.lastIndexOf('/');
Module module;
if(p >= 0) {
module = getModule(name.substring(0, p));
name = name.substring(p+1);
}
else
module = getRelatedModule();
if(module != null)
generateClassDocumentation(container, module, name);
}
private void generateClassDocumentation(Node container, Module module, String name) {
TypeClass typeClass = module.getTypeClass(name);
if(typeClass == null) {
StringBuilder error = new StringBuilder();
error.append("Didn't find the type class '" + name + "'.");
System.err.println(error);
container.addChild(new CodeBlockNode(error));
return;
}
TypeUnparsingContext tuc = new TypeUnparsingContext();
StringBuilder signature = new StringBuilder();
signature.append("");
signature.append("class ");
if(typeClass.context.length > 0) {
signature.append('(');
boolean first = true;
for(TPred cx : typeClass.context) {
if(first)
first = false;
else
signature.append(", ");
cx.toString(tuc, signature);
}
signature.append(") => ");
}
signature.append(name);
for(TVar p : typeClass.parameters) {
signature.append(' ');
p.toName(tuc, signature);
}
signature.append("
");
container.addChild(new HtmlNode(signature));
if(typeClass.documentation != null) {
MarkdownParser parser = new MarkdownParser();
container.addChild(parser.parseDocument(typeClass.documentation));
}
else
System.out.println(name);
for(String methodName : typeClass.methodNames) {
if(!documentedValues.add(methodName))
System.err.println("Method '" + methodName + "' has already been documented in " + documentationName + ".");
generateValueDocumentation(container, module, methodName, new TypeUnparsingContext(tuc));
}
container.addChild(new HtmlNode("
"));
}
private void generateDataDocumentation(Node container, String name) {
int p = name.lastIndexOf('/');
Module module;
if(p >= 0) {
module = getModule(name.substring(0, p));
name = name.substring(p+1);
}
else
module = getRelatedModule();
if(module != null)
generateDataDocumentation(container, module, name);
}
private void generateDataDocumentation(Node container, Module module, String name) {
TypeConstructor typeConstructor = module.getTypeConstructor(name);
if(typeConstructor == null) {
StringBuilder error = new StringBuilder();
error.append("Didn't find the type constructor '" + name + "'.");
System.err.println(error);
container.addChild(new CodeBlockNode(error));
return;
}
TypeUnparsingContext tuc = new TypeUnparsingContext();
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);
}
String moduleName = module.getName();
if(!moduleName.equals(documentationName)) {
signature.append(" (").append(moduleName).append(")");
}
signature.append("
");
container.addChild(new HtmlNode(signature));
if(typeConstructor.documentation != null) {
MarkdownParser parser = new MarkdownParser();
container.addChild(parser.parseDocument(typeConstructor.documentation));
}
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));
}
container.addChild(new HtmlNode("
"));
}
}