1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802
|
From: Jochen Sprickerhof <jspricke@debian.org>
Date: Wed, 22 Jun 2022 21:19:12 +0200
Subject: Drop (Resource)Doclet.java (does not compile with JDK 17)
---
src/tools/org/h2/build/Build.java | 33 --
src/tools/org/h2/build/doclet/Doclet.java | 588 ----------------------
src/tools/org/h2/build/doclet/ResourceDoclet.java | 132 -----
3 files changed, 753 deletions(-)
delete mode 100644 src/tools/org/h2/build/doclet/Doclet.java
delete mode 100644 src/tools/org/h2/build/doclet/ResourceDoclet.java
diff --git a/src/tools/org/h2/build/Build.java b/src/tools/org/h2/build/Build.java
index 66bbc24..d09c9ac 100644
--- a/src/tools/org/h2/build/Build.java
+++ b/src/tools/org/h2/build/Build.java
@@ -694,17 +694,6 @@ public void jarJaqu() {
*/
@Description(summary = "Create the API Javadocs (incl. JDBC API and tools).")
public void javadoc() {
- compileTools();
- delete("docs");
- mkdir("docs/javadoc");
- javadoc("-sourcepath", "src/main", "org.h2.jdbc", "org.h2.jdbcx",
- "org.h2.tools", "org.h2.api", "org.h2.engine", "org.h2.fulltext",
- "-classpath",
- "ext/lucene-core-3.6.2.jar" +
- File.pathSeparator + "ext/jts-core-1.15.0.jar",
- "-docletpath", "bin" + File.pathSeparator + "temp",
- "-doclet", "org.h2.build.doclet.Doclet");
- copy("docs/javadoc", files("src/docsrc/javadoc"), "src/docsrc/javadoc");
}
/**
@@ -748,22 +737,6 @@ public void javadocImpl() {
System.setProperty("h2.interfacesOnly", "false");
System.setProperty("h2.javadocDestDir", "docs/javadocImpl");
- javadoc("-sourcepath", "src/main" +
- File.pathSeparator + "src/test" +
- File.pathSeparator + "src/tools",
- "-classpath", javaToolsJar +
- File.pathSeparator + "ext/slf4j-api-1.6.0.jar" +
- File.pathSeparator + "ext/servlet-api-3.1.0.jar" +
- File.pathSeparator + "ext/lucene-core-3.6.2.jar" +
- File.pathSeparator + "ext/org.osgi.core-4.2.0.jar" +
- File.pathSeparator + "ext/org.osgi.enterprise-4.2.0.jar" +
- File.pathSeparator + "ext/jts-core-1.15.0.jar",
- "-subpackages", "org.h2",
- "-exclude", "org.h2.test.jaqu:org.h2.jaqu",
- "-package",
- "-docletpath", "bin" + File.pathSeparator + "temp",
- "-doclet", "org.h2.build.doclet.Doclet");
- copy("docs/javadocImpl", files("src/docsrc/javadoc"), "src/docsrc/javadoc");
}
private static void manifest(String title, String mainClassName) {
@@ -971,12 +944,6 @@ public void offline() {
private void resources(boolean clientOnly, boolean basicOnly) {
if (!clientOnly) {
java("org.h2.build.doc.GenerateHelp", null);
- javadoc("-sourcepath", "src/main", "org.h2.tools", "org.h2.jmx",
- "-classpath",
- "ext/lucene-core-3.6.2.jar" +
- File.pathSeparator + "ext/jts-core-1.15.0.jar",
- "-docletpath", "bin" + File.pathSeparator + "temp",
- "-doclet", "org.h2.build.doclet.ResourceDoclet");
}
FileList files = files("src/main").
exclude("*.MF").
diff --git a/src/tools/org/h2/build/doclet/Doclet.java b/src/tools/org/h2/build/doclet/Doclet.java
deleted file mode 100644
index 5d43a26..0000000
--- a/src/tools/org/h2/build/doclet/Doclet.java
+++ /dev/null
@@ -1,588 +0,0 @@
-/*
- * Copyright 2004-2018 H2 Group. Multiple-Licensed under the MPL 2.0,
- * and the EPL 1.0 (http://h2database.com/html/license.html).
- * Initial Developer: H2 Group
- */
-package org.h2.build.doclet;
-
-import java.io.BufferedWriter;
-import java.io.File;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Comparator;
-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;
-import com.sun.javadoc.ParamTag;
-import com.sun.javadoc.Parameter;
-import com.sun.javadoc.RootDoc;
-import com.sun.javadoc.Tag;
-import com.sun.javadoc.ThrowsTag;
-import com.sun.javadoc.Type;
-
-/**
- * This class is a custom doclet implementation to generate the
- * Javadoc for this product.
- */
-public class Doclet {
-
- private static final boolean INTERFACES_ONLY = Boolean
- .getBoolean("h2.interfacesOnly");
- private String destDir = System.getProperty("h2.javadocDestDir",
- "docs/javadoc");
- private int errorCount;
- private final HashSet<String> errors = new HashSet<>();
-
- /**
- * This method is called by the javadoc framework and is required for all
- * doclets.
- *
- * @param root the root
- * @return true if successful
- */
- public static boolean start(RootDoc root) throws IOException {
- return new Doclet().startDoc(root);
- }
-
- private boolean startDoc(RootDoc root) throws IOException {
- ClassDoc[] classes = root.classes();
- String[][] options = root.options();
- for (String[] op : options) {
- if (op[0].equals("destdir")) {
- destDir = op[1];
- }
- }
- for (ClassDoc clazz : classes) {
- processClass(clazz);
- }
- if (errorCount > 0) {
- throw new IOException("FAILED: " + errorCount + " errors found");
- }
- return true;
- }
-
- private static String getClass(ClassDoc clazz) {
- String name = clazz.name();
- if (clazz.qualifiedName().indexOf(".jdbc.") > 0 && name.startsWith("Jdbc")) {
- return name.substring(4);
- }
- return name;
- }
-
- private void processClass(ClassDoc clazz) throws IOException {
- String packageName = clazz.containingPackage().name();
- String dir = destDir + "/" + packageName.replace('.', '/');
- (new File(dir)).mkdirs();
- String fileName = dir + "/" + clazz.name() + ".html";
- String className = getClass(clazz);
- FileWriter out = new FileWriter(fileName);
- PrintWriter writer = new PrintWriter(new BufferedWriter(out));
- writer.println("<!DOCTYPE html PUBLIC \"-//W3C//DTD " +
- "XHTML 1.0 Strict//EN\" " +
- "\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">");
- String language = "en";
- writer.println("<html xmlns=\"http://www.w3.org/1999/xhtml\" " +
- "lang=\"" + language + "\" xml:lang=\"" + language + "\">");
- writer.println("<head>" +
- "<meta http-equiv=\"Content-Type\" " +
- "content=\"text/html;charset=utf-8\" /><title>");
- writer.println(className);
- writer.println("</title>" +
- "<link rel=\"stylesheet\" type=\"text/css\" " +
- "href=\"../../../stylesheet.css\" />");
- writer.println("<script type=\"text/javascript\" " +
- "src=\"../../../animate.js\"></script>");
- writer.println("</head><body onload=\"openLink();\">");
- writer.println("<table class=\"content\">" +
- "<tr class=\"content\">" +
- "<td class=\"content\">" +
- "<div class=\"contentDiv\">");
- writer.println("<h1>" + className + "</h1>");
- writer.println(formatText(clazz.commentText()) + "<br /><br />");
-
- // methods
- ConstructorDoc[] constructors = clazz.constructors();
- MethodDoc[] methods = clazz.methods();
- 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>() {
- @Override
- public int compare(ExecutableMemberDoc a, ExecutableMemberDoc b) {
- // sort static method before non-static methods
- if (a.isStatic() != b.isStatic()) {
- return a.isStatic() ? -1 : 1;
- }
- 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<>();
- boolean hasMethods = false;
- int id = 0;
- for (int i = 0; i < constructorsMethods.length; i++) {
- ExecutableMemberDoc method = constructorsMethods[i];
- String name = method.name();
- if (skipMethod(method)) {
- continue;
- }
- if (!hasMethods) {
- writer.println("<table class=\"block\">" +
- "<tr onclick=\"return allDetails()\">" +
- "<th colspan=\"2\">Methods</th></tr>");
- hasMethods = true;
- }
- String type = getTypeName(method.isStatic(), false,
- getReturnType(method));
- writer.println("<tr id=\"__" + id + "\" onclick=\"return on(" +
- id + ")\">");
- writer.println("<td class=\"return\">" + type +
- "</td><td class=\"method\">");
- Parameter[] params = method.parameters();
- StringBuilder buff = new StringBuilder();
- StringBuilder buffSignature = new StringBuilder(name);
- buff.append('(');
- for (int j = 0; j < params.length; j++) {
- if (j > 0) {
- buff.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(StringUtils.replaceAll(typeName, "[]", "-"));
- buff.append(' ');
- buff.append(param.name());
- }
- buff.append(')');
- if (isDeprecated(method)) {
- name = "<span class=\"deprecated\">" + name + "</span>";
- }
- String signature = buffSignature.toString();
- while (signatures.size() < i) {
- signatures.add(null);
- }
- signatures.add(i, signature);
- 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("+
- id +")\" class=\"detail\" id=\"_"+id+"\">");
- writer.println("<td class=\"return\">" +
- type + "</td><td>");
- writeMethodDetails(writer, clazz, method, signature);
- writer.println("</td></tr>");
- id++;
- }
- if (hasMethods) {
- writer.println("</table>");
- }
-
- // field overview
- FieldDoc[] fields = clazz.fields();
- if (clazz.interfaces().length > 0) {
- fields = clazz.interfaces()[0].fields();
- }
- Arrays.sort(fields, new Comparator<FieldDoc>() {
- @Override
- public int compare(FieldDoc a, FieldDoc b) {
- return a.name().compareTo(b.name());
- }
- });
- int fieldId = 0;
- for (FieldDoc field : fields) {
- if (skipField(clazz, field)) {
- continue;
- }
- String name = field.name();
- String text = field.commentText();
- if (text == null || text.trim().length() == 0) {
- addError("Undocumented field (" +
- getLink(clazz, field.position().line()) + ") " + name);
- }
- if (text != null && text.startsWith("INTERNAL")) {
- continue;
- }
- if (fieldId == 0) {
- writer.println("<br /><table><tr><th colspan=\"2\">Fields</th></tr>");
- }
- String type = getTypeName(true, false, field.type());
- writer.println("<tr><td class=\"return\">" + type +
- "</td><td class=\"method\">");
- String constant = field.constantValueExpression();
-
- // add a link (a name) if there is a <code> tag
- String link = getFieldLink(text, constant, clazz, name);
- writer.print("<a href=\"#" + link + "\">" + name + "</a>");
- if (constant == null) {
- writer.println();
- } else {
- writer.println(" = " + constant);
- }
- writer.println("</td></tr>");
- fieldId++;
- }
- if (fieldId > 0) {
- writer.println("</table>");
- }
-
- // field details
- Arrays.sort(fields, new Comparator<FieldDoc>() {
- @Override
- public int compare(FieldDoc a, FieldDoc b) {
- String ca = a.constantValueExpression();
- if (ca == null) {
- ca = a.name();
- }
- String cb = b.constantValueExpression();
- if (cb == null) {
- cb = b.name();
- }
- return ca.compareTo(cb);
- }
- });
- for (FieldDoc field : fields) {
- writeFieldDetails(writer, clazz, field);
- }
-
- writer.println("</div></td></tr></table></body></html>");
- writer.close();
- out.close();
- }
-
- private void writeFieldDetails(PrintWriter writer, ClassDoc clazz,
- FieldDoc field) {
- if (skipField(clazz, field)) {
- return;
- }
- String text = field.commentText();
- if (text.startsWith("INTERNAL")) {
- return;
- }
- String name = field.name();
- String constant = field.constantValueExpression();
- String link = getFieldLink(text, constant, clazz, name);
- writer.println("<h4 id=\"" + link + "\"><span class=\"methodName\">" +
- name);
- if (constant == null) {
- writer.println();
- } else {
- writer.println(" = " + constant);
- }
- writer.println("</span></h4>");
- writer.println("<div class=\"item\">" + formatText(text) + "</div>");
- writer.println("<hr />");
- }
-
- private void writeMethodDetails(PrintWriter writer, ClassDoc clazz,
- ExecutableMemberDoc method, String signature) {
- String name = method.name();
- if (skipMethod(method)) {
- return;
- }
- Parameter[] params = method.parameters();
- StatementBuilder buff = new StatementBuilder();
- buff.append('(');
- int i = 0;
- for (Parameter p : params) {
- boolean isVarArgs = method.isVarArgs() && i++ == params.length - 1;
- buff.appendExceptFirst(", ");
- buff.append(getTypeName(false, isVarArgs, p.type()));
- buff.append(' ');
- buff.append(p.name());
- }
- buff.append(')');
- ClassDoc[] exceptions = method.thrownExceptions();
- if (exceptions.length > 0) {
- buff.append(" throws ");
- buff.resetCount();
- for (ClassDoc ex : exceptions) {
- buff.appendExceptFirst(", ");
- buff.append(ex.typeName());
- }
- }
- if (isDeprecated(method)) {
- name = "<span class=\"deprecated\">" + name + "</span>";
- }
- 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();
- ThrowsTag[] throwsTags = method.throwsTags();
- boolean hasThrowsTag = throwsTags != null && throwsTags.length > 0;
- if (paramTags.length != params.length) {
- if (hasComment && !method.commentText().startsWith("[")) {
- // [Not supported] and such are not problematic
- addError("Undocumented parameter(s) (" +
- getLink(clazz, method.position().line()) + ") " +
- name + " documented: " + paramTags.length +
- " params: "+ params.length);
- }
- }
- for (int j = 0; j < paramTags.length; j++) {
- String paramName = paramTags[j].parameterName();
- String comment = paramTags[j].parameterComment();
- if (comment.trim().length() == 0) {
- addError("Undocumented parameter (" +
- getLink(clazz, method.position().line()) + ") " +
- name + " " + paramName);
- }
- String p = paramName + " - " + comment;
- if (j == 0) {
- writer.println("<div class=\"itemTitle\">Parameters:</div>");
- }
- 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();
- if (returnComment.trim().length() == 0) {
- addError("Undocumented return value (" +
- getLink(clazz, method.position().line()) + ") " + name);
- }
- writer.println("<div class=\"item\">" + returnComment + "</div>");
- } 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 ("
- + getLink(clazz, method.position().line()) + ") "
- + name + " " + getReturnType(method));
- }
- }
- if (hasThrowsTag) {
- writer.println("<div class=\"itemTitle\">Throws:</div>");
- for (ThrowsTag tag : throwsTags) {
- String p = tag.exceptionName();
- String c = tag.exceptionComment();
- if (c.length() > 0) {
- p += " - " + c;
- }
- writer.println("<div class=\"item\">" + p + "</div>");
- }
- }
- }
-
- private static String getLink(ClassDoc clazz, int line) {
- String c = clazz.name();
- int x = c.lastIndexOf('.');
- if (x >= 0) {
- c = c.substring(0, x);
- }
- return c + ".java:" + line;
- }
-
- private String getFieldLink(String text, String constant, ClassDoc clazz,
- String name) {
- String link = constant != null ? constant : name.toLowerCase();
- int linkStart = text.indexOf("<code>");
- if (linkStart >= 0) {
- int linkEnd = text.indexOf("</code>", linkStart);
- link = text.substring(linkStart + "<code>".length(), linkEnd);
- if (constant != null && !constant.equals(link)) {
- System.out.println("Wrong code tag? " + clazz.name() + "." +
- name +
- " code: " + link + " constant: " + constant);
- errorCount++;
- }
- }
- if (link.startsWith("\"")) {
- link = name;
- } else if (Character.isDigit(link.charAt(0))) {
- link = "c" + link;
- }
- return link;
- }
-
- private static String formatText(String text) {
- if (text == null) {
- return text;
- }
- text = StringUtils.replaceAll(text, "\n </pre>", "</pre>");
- return text;
- }
-
- private static boolean skipField(ClassDoc clazz, FieldDoc field) {
- if (field.isPrivate() || field.containingClass() != clazz) {
- return true;
- }
- return false;
- }
-
- private boolean skipMethod(ExecutableMemberDoc method) {
- ClassDoc clazz = method.containingClass();
- boolean isAbstract = method instanceof MethodDoc
- && ((MethodDoc) method).isAbstract();
- boolean isInterface = clazz.isInterface()
- || (clazz.isAbstract() && isAbstract);
- if (INTERFACES_ONLY && !isInterface) {
- return true;
- }
- String name = method.name();
- 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;
- }
- String firstSentence = getFirstSentence(method.firstSentenceTags());
- String raw = method.getRawCommentText();
- if (firstSentence != null && firstSentence.startsWith("INTERNAL")) {
- return true;
- }
- if ((firstSentence == null || firstSentence.trim().length() == 0)
- && raw.indexOf("{@inheritDoc}") < 0) {
- if (!doesOverride(method)) {
- boolean setterOrGetter = name.startsWith("set")
- && method.parameters().length == 1;
- setterOrGetter |= name.startsWith("get")
- && method.parameters().length == 0;
- Type returnType = getReturnType(method);
- setterOrGetter |= name.startsWith("is")
- && method.parameters().length == 0
- && returnType != null
- && returnType.toString().equals("boolean");
- boolean enumValueMethod = name.equals("values") || name.equals("valueOf");
- if (!setterOrGetter && !enumValueMethod) {
- addError("Undocumented method " + " ("
- + getLink(clazz, method.position().line()) + ") "
- + clazz + "." + name + " " + raw);
- return true;
- }
- }
- }
- return false;
- }
-
- private static 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);
- errorCount++;
- }
- }
-
- 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);
- }
-
- private boolean foundMethod(ClassDoc clazz, boolean include,
- String methodName, int parameterCount) {
- if (include) {
- for (MethodDoc m : clazz.methods()) {
- if (m.name().equals(methodName)
- && m.parameters().length == parameterCount) {
- return true;
- }
- }
- }
- for (ClassDoc doc : clazz.interfaces()) {
- if (foundMethod(doc, true, methodName, parameterCount)) {
- return true;
- }
- }
- clazz = clazz.superclass();
- return clazz != null
- && foundMethod(clazz, true, methodName, parameterCount);
- }
-
- private static String getFirstSentence(Tag[] tags) {
- String firstSentence = null;
- if (tags.length > 0) {
- Tag first = tags[0];
- firstSentence = first.text();
- }
- return firstSentence;
- }
-
- 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
- s = s.substring(0, s.length() - 2) + "...";
- }
- if (isStatic) {
- s = "static " + s;
- }
- return s;
- }
-
- private static boolean isDeprecated(ExecutableMemberDoc method) {
- for (Tag t : method.tags()) {
- if (t.kind().equals("@deprecated")) {
- return true;
- }
- }
- return false;
- }
-
- /**
- * Get the language version this doclet supports.
- *
- * @return the language version
- */
- public static LanguageVersion languageVersion() {
- // otherwise, isVarArgs always returns false
- // (which sounds like a bug but is a feature :-)
- return LanguageVersion.JAVA_1_5;
- }
-
-}
diff --git a/src/tools/org/h2/build/doclet/ResourceDoclet.java b/src/tools/org/h2/build/doclet/ResourceDoclet.java
deleted file mode 100644
index 0a36cb5..0000000
--- a/src/tools/org/h2/build/doclet/ResourceDoclet.java
+++ /dev/null
@@ -1,132 +0,0 @@
-/*
- * Copyright 2004-2018 H2 Group. Multiple-Licensed under the MPL 2.0,
- * and the EPL 1.0 (http://h2database.com/html/license.html).
- * Initial Developer: H2 Group
- */
-package org.h2.build.doclet;
-
-import java.io.IOException;
-import org.h2.build.doc.XMLParser;
-import org.h2.build.indexer.HtmlConverter;
-import org.h2.util.SortedProperties;
-import com.sun.javadoc.ClassDoc;
-import com.sun.javadoc.Doc;
-import com.sun.javadoc.MethodDoc;
-import com.sun.javadoc.RootDoc;
-import com.sun.javadoc.Tag;
-
-/**
- * This custom doclet generates resources from javadoc comments.
- * Only comments that contain 'at resource' are included.
- * Only class level and method level comments are supported.
- */
-public class ResourceDoclet {
-
- private String destFile = System.getProperty("h2.javadocResourceFile",
- "src/main/org/h2/res/javadoc.properties");
-
- private final SortedProperties resources = new SortedProperties();
-
- /**
- * This method is called by the javadoc framework and is required for all
- * doclets.
- *
- * @param root the root
- * @return true if successful
- */
- public static boolean start(RootDoc root) throws IOException {
- return new ResourceDoclet().startDoc(root);
- }
-
- private boolean startDoc(RootDoc root) throws IOException {
- ClassDoc[] classes = root.classes();
- String[][] options = root.options();
- for (String[] op : options) {
- if (op[0].equals("dest")) {
- destFile = op[1];
- }
- }
- for (ClassDoc clazz : classes) {
- processClass(clazz);
- }
- resources.store(destFile);
- return true;
- }
-
- private void processClass(ClassDoc clazz) {
- String packageName = clazz.containingPackage().name();
- String className = clazz.name();
- addResource(packageName + "." + className, clazz);
-
- for (MethodDoc method : clazz.methods()) {
- String name = method.name();
- addResource(packageName + "." + className + "." + name, method);
- }
- }
-
-
- private void addResource(String key, Doc doc) {
- if (!isResource(doc)) {
- return;
- }
- String xhtml = doc.commentText();
- XMLParser p = new XMLParser(xhtml);
- StringBuilder buff = new StringBuilder();
- int column = 0;
- int firstColumnSize = 0;
- boolean inColumn = false;
- while (p.hasNext()) {
- String s;
- switch (p.next()) {
- case XMLParser.END_ELEMENT:
- s = p.getName();
- if ("p".equals(s) || "tr".equals(s) || "br".equals(s)) {
- buff.append('\n');
- }
- break;
- case XMLParser.START_ELEMENT:
- s = p.getName();
- if ("table".equals(s)) {
- buff.append('\n');
- } else if ("tr".equals(s)) {
- column = 0;
- } else if ("td".equals(s)) {
- inColumn = true;
- column++;
- if (column == 2) {
- buff.append('\t');
- }
- }
- break;
- case XMLParser.CHARACTERS:
- s = HtmlConverter.convertHtmlToString(p.getText().trim());
- if (inColumn && column == 1) {
- firstColumnSize = Math.max(s.length(), firstColumnSize);
- }
- buff.append(s);
- break;
- }
- }
- for (int i = 0; i < buff.length(); i++) {
- if (buff.charAt(i) == '\t') {
- buff.deleteCharAt(i);
- int length = i - buff.lastIndexOf("\n", i - 1);
- for (int k = length; k < firstColumnSize + 3; k++) {
- buff.insert(i, ' ');
- }
- }
- }
- String text = buff.toString().trim();
- resources.setProperty(key, text);
- }
-
- private static boolean isResource(Doc doc) {
- for (Tag t : doc.tags()) {
- if (t.kind().equals("@h2.resource")) {
- return true;
- }
- }
- return false;
- }
-
-}
|