提交 9b9efb99 authored 作者: Thomas Mueller's avatar Thomas Mueller

docs

上级 6a0beab2
......@@ -124,7 +124,7 @@ public class Update extends Prepared {
// don't work if update is multi-row and 'inversed' the condition!
// probably need multi-row triggers with 'deleted' and 'inserted'
// at the same time. anyway good for sql compatibility
// TODO update in-place (but if the position changes,
// TODO update in-place (but if the key changes,
// we need to update all indexes) before row triggers
// the cached row is already updated - we need the old values
......
......@@ -98,7 +98,7 @@ function writeTree() {
if(node.link==null) {
document.write(node.text);
} else {
document.write("<a name='"+node.text+"' href=\""+node.link+"\" >"+node.text+"</a>");
document.write("<a id='"+node.text+"' href=\""+node.link+"\" >"+node.text+"</a>");
}
document.write("<br />");
}
......
......@@ -105,6 +105,7 @@ public class FileLock {
* Create a new file locking object.
*
* @param traceSystem the trace system to use
* @param fileName the file name
* @param sleep the number of milliseconds to sleep
*/
public FileLock(TraceSystem traceSystem, String fileName, int sleep) {
......
......@@ -201,26 +201,6 @@ public class SimpleResultSet implements ResultSet, ResultSetMetaData {
this.source = source;
}
/**
* Constructor a new result set that is later populated with addRow.
*
* @return the new object
*/
public static SimpleResultSet newInstance() {
return new SimpleResultSet();
}
/**
* Constructor a new result set if the rows should be retrieved using
* the specified row source object.
*
* @param source the row source
* @return the new object
*/
public static SimpleResultSet newInstance(SimpleRowSource source) {
return new SimpleResultSet(source);
}
/**
* Adds a column to the result set.
*
......
......@@ -22,11 +22,13 @@ public class IntArray {
* Create an int array with the default initial capacity.
*/
public IntArray() {
data = new int[10];
this(10);
}
/**
* Create an int array with specified initial capacity.
*
* @param capacity the initial capacity
*/
public IntArray(int capacity) {
data = new int[capacity];
......@@ -34,6 +36,8 @@ public class IntArray {
/**
* Create an int array with the given values and size.
*
* @param data the int array
*/
public IntArray(int[] data) {
this.data = data;
......
......@@ -33,7 +33,7 @@ public class GenerateHelp {
String in = "src/docsrc/help/help.csv";
String out = "src/main/org/h2/res/help.csv";
ResultSet rs = Csv.getInstance().read(in, null, null);
SimpleResultSet rs2 = SimpleResultSet.newInstance();
SimpleResultSet rs2 = new SimpleResultSet();
ResultSetMetaData meta = rs.getMetaData();
int columnCount = meta.getColumnCount() - 1;
for (int i = 0; i < columnCount; i++) {
......
......@@ -77,7 +77,7 @@ public class LinkChecker {
if (!link.startsWith("http") && !link.endsWith("h2.pdf")
&& link.indexOf("_ja.") < 0) {
if (targets.get(link) == null) {
errors.add(links.get(link) + ": link missing " + link);
errors.add(links.get(link) + ": Link missing " + link);
}
}
}
......@@ -87,7 +87,7 @@ public class LinkChecker {
}
}
for (String name : targets.keySet()) {
if (targets.get(name).equals("name")) {
if (targets.get(name).equals("id")) {
boolean ignore = false;
for (String to : IGNORE_MISSING_LINKS_TO) {
if (name.indexOf(to) >= 0) {
......@@ -138,13 +138,56 @@ public class LinkChecker {
if (idx < 0) {
break;
}
int start = idx + 4;
int start = idx + " id=\"".length();
int end = html.indexOf("\"", start);
if (end < 0) {
error(fileName, "Expected \" after id= " + html.substring(idx, idx + 100));
}
String ref = html.substring(start, end);
if (!ref.startsWith("_")) {
targets.put(path + "#" + ref, "id");
}
}
idx = -1;
while (true) {
idx = html.indexOf(" href=\"", idx + 1);
if (idx < 0) {
break;
}
int start = html.indexOf("\"", idx);
if (start < 0) {
error(fileName, "Expected \" after href= at " + html.substring(idx, idx + 100));
}
int end = html.indexOf("\"", start + 1);
if (end < 0) {
error(fileName, "expected \" after id= " + html.substring(idx, idx + 100));
error(fileName, "Expected \" after href= at " + html.substring(idx, idx + 100));
}
String ref = html.substring(start + 1, end);
targets.put(path + "#" + ref, "id");
if (ref.startsWith("http:") || ref.startsWith("https:")) {
// ok
} else if (ref.startsWith("javascript:")) {
ref = null;
// ok
} else if (ref.length() == 0) {
ref = null;
// ok
} else if (ref.startsWith("#")) {
ref = path + ref;
} else {
String p = parent;
while (ref.startsWith(".")) {
if (ref.startsWith("./")) {
ref = ref.substring(2);
} else if (ref.startsWith("../")) {
ref = ref.substring(3);
p = p.substring(0, p.lastIndexOf('/'));
}
}
ref = p + "/" + ref;
}
if (ref != null) {
links.put(ref, path);
}
}
idx = -1;
while (true) {
......@@ -154,48 +197,24 @@ public class LinkChecker {
}
int equals = html.indexOf("=", idx);
if (equals < 0) {
error(fileName, "expected = after <a at " + html.substring(idx, idx + 100));
error(fileName, "Expected = after <a at " + html.substring(idx, idx + 100));
}
String type = html.substring(idx + 2, equals).trim();
int start = html.indexOf("\"", idx);
if (start < 0) {
error(fileName, "expected \" after <a at " + html.substring(idx, idx + 100));
error(fileName, "Expected \" after <a at " + html.substring(idx, idx + 100));
}
int end = html.indexOf("\"", start + 1);
if (end < 0) {
error(fileName, "expected \" after <a at " + html.substring(idx, idx + 100));
error(fileName, "Expected \" after <a at " + html.substring(idx, idx + 100));
}
String ref = html.substring(start + 1, end);
if (type.equals("href")) {
if (ref.startsWith("http:") || ref.startsWith("https:")) {
// ok
} else if (ref.startsWith("javascript:")) {
ref = null;
// ok
} else if (ref.length() == 0) {
ref = null;
// ok
} else if (ref.startsWith("#")) {
ref = path + ref;
} else {
String p = parent;
while (ref.startsWith(".")) {
if (ref.startsWith("./")) {
ref = ref.substring(2);
} else if (ref.startsWith("../")) {
ref = ref.substring(3);
p = p.substring(0, p.lastIndexOf('/'));
}
}
ref = p + "/" + ref;
}
if (ref != null) {
links.put(ref, path);
}
} else if (type.equals("name")) {
targets.put(path + "#" + ref, "name");
// already checked
} else if (type.equals("id")) {
targets.put(path + "#" + ref, "id");
} else {
error(fileName, "unsupported <a ?: " + html.substring(idx, idx + 100));
error(fileName, "Unsupported <a ?: " + html.substring(idx, idx + 100));
}
}
}
......
......@@ -612,4 +612,5 @@ locals multianewarray icmpne fneg faload ifeq decompiler zeroes forgot
modern slight boost characteristics significantly gae vfs centrally ten
approach risky getters suxxess gmb delegate delegating delegates collisions
linkage superfluous disallow scoop moebius inputs copilot dmoebius leod jenkov
jakob poker docware peter unstable measurable scramble reissued recreation
\ No newline at end of file
jakob poker docware peter unstable measurable scramble reissued recreation
scrambling distinguish official
\ No newline at end of file
......@@ -18,6 +18,8 @@ import java.util.HashSet;
import org.h2.util.StatementBuilder;
import org.h2.util.StringUtils;
import com.sun.javadoc.ClassDoc;
import com.sun.javadoc.ConstructorDoc;
import com.sun.javadoc.ExecutableMemberDoc;
import com.sun.javadoc.FieldDoc;
import com.sun.javadoc.LanguageVersion;
import com.sun.javadoc.MethodDoc;
......@@ -98,9 +100,13 @@ public class Doclet {
writer.println(formatText(clazz.commentText()) + "<br /><br />");
// methods
ConstructorDoc[] constructors = clazz.constructors();
MethodDoc[] methods = clazz.methods();
Arrays.sort(methods, new Comparator<MethodDoc>() {
public int compare(MethodDoc a, MethodDoc b) {
ExecutableMemberDoc[] constructorsMethods = new ExecutableMemberDoc[constructors.length + methods.length];
System.arraycopy(constructors, 0, constructorsMethods, 0, constructors.length);
System.arraycopy(methods, 0, constructorsMethods, constructors.length, methods.length);
Arrays.sort(constructorsMethods, new Comparator<ExecutableMemberDoc>() {
public int compare(ExecutableMemberDoc a, ExecutableMemberDoc b) {
// sort static method before non-static methods
if (a.isStatic() != b.isStatic()) {
return a.isStatic() ? -1 : 1;
......@@ -108,11 +114,22 @@ public class Doclet {
return a.name().compareTo(b.name());
}
});
//
//
// Arrays.sort(methods, new Comparator<MethodDoc>() {
// public int compare(MethodDoc a, MethodDoc b) {
// // sort static method before non-static methods
// if (a.isStatic() != b.isStatic()) {
// return a.isStatic() ? -1 : 1;
// }
// return a.name().compareTo(b.name());
// }
// });
ArrayList<String> signatures = new ArrayList<String>();
boolean hasMethods = false;
int id = 0;
for (int i = 0; i < methods.length; i++) {
MethodDoc method = methods[i];
for (int i = 0; i < constructorsMethods.length; i++) {
ExecutableMemberDoc method = constructorsMethods[i];
String name = method.name();
if (skipMethod(method)) {
continue;
......@@ -121,28 +138,26 @@ public class Doclet {
writer.println("<table class=\"block\"><tr onclick=\"return allDetails()\"><th colspan=\"2\">Methods</th></tr>");
hasMethods = true;
}
String type = getTypeName(method.isStatic(), false, method.returnType());
writer.println("<tr id=\"tm"+id+"\" onclick=\"return on('m"+ id +"')\"><td class=\"return\">" + type + "</td><td class=\"method\">");
String type = getTypeName(method.isStatic(), false, getReturnType(method));
writer.println("<tr id=\"__"+id+"\" onclick=\"return on("+ id +")\"><td class=\"return\">" + type + "</td><td class=\"method\">");
Parameter[] params = method.parameters();
StringBuilder buff = new StringBuilder();
StringBuilder buffSignature = new StringBuilder(name);
buffSignature.append('(');
buff.append('(');
for (int j = 0; j < params.length; j++) {
if (j > 0) {
buff.append(", ");
buffSignature.append(',');
}
buffSignature.append('_');
Parameter param = params[j];
boolean isVarArgs = method.isVarArgs() && j == params.length - 1;
String typeName = getTypeName(false, isVarArgs, param.type());
buff.append(typeName);
buffSignature.append(typeName);
buffSignature.append(StringUtils.replaceAll(typeName, "[]", "-"));
buff.append(' ');
buff.append(param.name());
}
buff.append(')');
buffSignature.append(')');
if (isDeprecated(method)) {
name = "<span class=\"deprecated\">" + name + "</span>";
}
......@@ -151,15 +166,14 @@ public class Doclet {
signatures.add(null);
}
signatures.add(i, signature);
writer.println("<a href=\"#" + signature + "\">" + name + "</a>" + buff.toString());
writer.println("<a id=\"" + signature + "\" href=\"#" + signature + "\">" + name + "</a>" + buff.toString());
String firstSentence = getFirstSentence(method.firstSentenceTags());
if (firstSentence != null) {
writer.println("<div class=\"methodText\">" + formatText(firstSentence) + "</div>");
}
writer.println("</td></tr>");
writer.println("<tr onclick=\"return off('m"+ id +"')\" class=\"detail\" id=\"m"+id+"\">");
writer.println("<tr onclick=\"return off("+ id +")\" class=\"detail\" id=\"_"+id+"\">");
writer.println("<td class=\"return\">" + type + "</td><td>");
writer.println("<a name=\"" + signature + "\"></a>");
writeMethodDetails(writer, clazz, method, signature);
writer.println("</td></tr>");
id++;
......@@ -244,8 +258,7 @@ public class Doclet {
String name = field.name();
String constant = field.constantValueExpression();
String link = getFieldLink(text, constant, clazz, name);
writer.println("<a name=\"" + link + "\"></a>");
writer.println("<h4><span class=\"methodName\">" + name);
writer.println("<h4 id=\"" + link + "\"><span class=\"methodName\">" + name);
if (constant == null) {
writer.println();
} else {
......@@ -256,7 +269,7 @@ public class Doclet {
writer.println("<hr />");
}
private void writeMethodDetails(PrintWriter writer, ClassDoc clazz, MethodDoc method, String signature) {
private void writeMethodDetails(PrintWriter writer, ClassDoc clazz, ExecutableMemberDoc method, String signature) {
String name = method.name();
if (skipMethod(method)) {
return;
......@@ -285,7 +298,7 @@ public class Doclet {
if (isDeprecated(method)) {
name = "<span class=\"deprecated\">" + name + "</span>";
}
writer.println("<a href=\"#" + signature + "\">" + name + "</a>" + buff.toString());
writer.println("<a id=\"" + signature + "\" href=\"#" + signature + "\">" + name + "</a>" + buff.toString());
boolean hasComment = method.commentText() != null && method.commentText().trim().length() != 0;
writer.println("<div class=\"methodText\">" + formatText(method.commentText()) + "</div>");
ParamTag[] paramTags = method.paramTags();
......@@ -313,6 +326,7 @@ public class Doclet {
writer.println("<div class=\"item\">" + p + "</div>");
}
Tag[] returnTags = method.tags("return");
Type returnType = getReturnType(method);
if (returnTags != null && returnTags.length > 0) {
writer.println("<div class=\"itemTitle\">Returns:</div>");
String returnComment = returnTags[0].text();
......@@ -321,12 +335,12 @@ public class Doclet {
clazz.name() + ".java:" + method.position().line() + ") " + name);
}
writer.println("<div class=\"item\">" + returnComment + "</div>");
} else if (!method.returnType().toString().equals("void")) {
} else if (returnType != null && !returnType.toString().equals("void")) {
if (hasComment && !method.commentText().startsWith("[") && !hasThrowsTag) {
// [Not supported] and such are not problematic
// also not problematic are methods that always throw an exception
addError("Undocumented return value (" +
clazz.name() + ".java:" + method.position().line() + ") " + name + " " + method.returnType());
clazz.name() + ".java:" + method.position().line() + ") " + name + " " + getReturnType(method));
}
}
if (hasThrowsTag) {
......@@ -354,7 +368,9 @@ public class Doclet {
errorCount++;
}
}
if (Character.isDigit(link.charAt(0))) {
if (link.startsWith("\"")) {
link = name;
} else if (Character.isDigit(link.charAt(0))) {
link = "c" + link;
}
return link;
......@@ -375,9 +391,10 @@ public class Doclet {
return false;
}
private boolean skipMethod(MethodDoc method) {
private boolean skipMethod(ExecutableMemberDoc method) {
ClassDoc clazz = method.containingClass();
boolean isInterface = clazz.isInterface() || (clazz.isAbstract() && method.isAbstract());
boolean isAbstract = method instanceof MethodDoc && ((MethodDoc) method).isAbstract();
boolean isInterface = clazz.isInterface() || (clazz.isAbstract() && isAbstract);
if (INTERFACES_ONLY && !isInterface) {
return true;
}
......@@ -385,6 +402,9 @@ public class Doclet {
if (method.isPrivate() || name.equals("finalize")) {
return true;
}
if (method.isConstructor() && method.getRawCommentText().trim().length() == 0) {
return true;
}
if (method.getRawCommentText().trim().startsWith("@deprecated INTERNAL")) {
return true;
}
......@@ -397,7 +417,8 @@ public class Doclet {
if (!doesOverride(method)) {
boolean setterOrGetter = name.startsWith("set") && method.parameters().length == 1;
setterOrGetter |= name.startsWith("get") && method.parameters().length == 0;
setterOrGetter |= name.startsWith("is") && method.parameters().length == 0 && method.returnType().toString().equals("boolean");
Type returnType = getReturnType(method);
setterOrGetter |= name.startsWith("is") && method.parameters().length == 0 && returnType != null && returnType.toString().equals("boolean");
if (!setterOrGetter) {
addError("Undocumented method " + " (" + clazz.name() + ".java:" + method.position().line() +") " + clazz + "." + name + " " + raw);
return true;
......@@ -407,6 +428,14 @@ public class Doclet {
return false;
}
private Type getReturnType(ExecutableMemberDoc method) {
if (method instanceof MethodDoc) {
MethodDoc m = (MethodDoc) method;
return m.returnType();
}
return null;
}
private void addError(String s) {
if (errors.add(s)) {
System.out.println(s);
......@@ -414,7 +443,10 @@ public class Doclet {
}
}
private boolean doesOverride(MethodDoc method) {
private boolean doesOverride(ExecutableMemberDoc method) {
if (method.isConstructor()) {
return true;
}
ClassDoc clazz = method.containingClass();
int parameterCount = method.parameters().length;
return foundMethod(clazz, false, method.name(), parameterCount);
......@@ -447,6 +479,9 @@ public class Doclet {
}
private static String getTypeName(boolean isStatic, boolean isVarArgs, Type type) {
if (type == null) {
return "";
}
String s = type.typeName() + type.dimension();
if (isVarArgs) {
// remove the last "[]" and add "..." instead
......@@ -458,7 +493,7 @@ public class Doclet {
return s;
}
private static boolean isDeprecated(MethodDoc method) {
private static boolean isDeprecated(ExecutableMemberDoc method) {
for (Tag t : method.tags()) {
if (t.kind().equals("@deprecated")) {
return true;
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论