From commits-return-535-apmail-sis-commits-archive=sis.apache.org@sis.apache.org Mon Sep 24 14:54:30 2012 Return-Path: X-Original-To: apmail-sis-commits-archive@www.apache.org Delivered-To: apmail-sis-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 693DBDBBD for ; Mon, 24 Sep 2012 14:54:30 +0000 (UTC) Received: (qmail 46019 invoked by uid 500); 24 Sep 2012 14:54:30 -0000 Delivered-To: apmail-sis-commits-archive@sis.apache.org Received: (qmail 45946 invoked by uid 500); 24 Sep 2012 14:54:30 -0000 Mailing-List: contact commits-help@sis.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: sis-dev@sis.apache.org Delivered-To: mailing list commits@sis.apache.org Received: (qmail 45772 invoked by uid 99); 24 Sep 2012 14:54:29 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 24 Sep 2012 14:54:29 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 24 Sep 2012 14:54:27 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 803DB23888E3 for ; Mon, 24 Sep 2012 14:53:44 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: svn commit: r1389415 - in /sis/trunk/sis-build-helper: ./ src/main/java/org/apache/sis/internal/ src/main/java/org/apache/sis/internal/taglet/ src/main/java/org/apache/sis/resources/ Date: Mon, 24 Sep 2012 14:53:44 -0000 To: commits@sis.apache.org From: desruisseaux@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20120924145344.803DB23888E3@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: desruisseaux Date: Mon Sep 24 14:53:43 2012 New Revision: 1389415 URL: http://svn.apache.org/viewvc?rev=1389415&view=rev Log: Added custom taglets. Added: sis/trunk/sis-build-helper/src/main/java/org/apache/sis/internal/ sis/trunk/sis-build-helper/src/main/java/org/apache/sis/internal/taglet/ sis/trunk/sis-build-helper/src/main/java/org/apache/sis/internal/taglet/Module.java (with props) sis/trunk/sis-build-helper/src/main/java/org/apache/sis/internal/taglet/Note.java (with props) sis/trunk/sis-build-helper/src/main/java/org/apache/sis/internal/taglet/Preformat.java (with props) sis/trunk/sis-build-helper/src/main/java/org/apache/sis/internal/taglet/Section.java (with props) sis/trunk/sis-build-helper/src/main/java/org/apache/sis/internal/taglet/package-info.java (with props) sis/trunk/sis-build-helper/src/main/java/org/apache/sis/resources/package-info.txt (with props) Modified: sis/trunk/sis-build-helper/pom.xml Modified: sis/trunk/sis-build-helper/pom.xml URL: http://svn.apache.org/viewvc/sis/trunk/sis-build-helper/pom.xml?rev=1389415&r1=1389414&r2=1389415&view=diff ============================================================================== --- sis/trunk/sis-build-helper/pom.xml (original) +++ sis/trunk/sis-build-helper/pom.xml Mon Sep 24 14:53:43 2012 @@ -112,4 +112,51 @@ + + + + + default-tools.jar + + + java.vendor + Sun Microsystems Inc. + + + + + com.sun + tools + ${java.version} + system + ${java.home}/../lib/tools.jar + + + + + + + jdk7-tools.jar + + + java.vendor + Oracle Corporation + + + + + com.sun + tools + ${java.version} + system + ${java.home}/../lib/tools.jar + + + + + Added: sis/trunk/sis-build-helper/src/main/java/org/apache/sis/internal/taglet/Module.java URL: http://svn.apache.org/viewvc/sis/trunk/sis-build-helper/src/main/java/org/apache/sis/internal/taglet/Module.java?rev=1389415&view=auto ============================================================================== --- sis/trunk/sis-build-helper/src/main/java/org/apache/sis/internal/taglet/Module.java (added) +++ sis/trunk/sis-build-helper/src/main/java/org/apache/sis/internal/taglet/Module.java Mon Sep 24 14:53:43 2012 @@ -0,0 +1,237 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.sis.internal.taglet; + +import java.io.File; +import java.util.Map; +import com.sun.javadoc.Tag; +import com.sun.javadoc.Doc; +import com.sun.javadoc.ClassDoc; +import com.sun.tools.doclets.Taglet; + + +/** + * The @module tag. This tag expects no argument. + * + * @author Martin Desruisseaux (IRD, Geomatys) + * @since 0.3 (derived from geotk-2.2) + * @version 0.3 + */ +public final class Module implements Taglet { + /** + * SIS version to be referenced by this taglet. + */ + private static final String VERSION = "0.3-incubating-SNAPSHOT"; + + /** + * Register this taglet. + * + * @param tagletMap the map to register this tag to. + */ + public static void register(final Map tagletMap) { + final Module tag = new Module(); + tagletMap.put(tag.getName(), tag); + } + + /** + * The base URL for Maven reports. + */ + private static final String MAVEN_REPORTS_BASE_URL = "http://incubator.apache.org/sis/"; + + /** + * The base URL for Maven repository. + * See ASF Jar Repositories + * for more information. + */ + private static final String MAVEN_REPOSITORY_BASE_URL = "http://repository.apache.org/snapshots/"; + + /** + * The SIS module in which the @module taglet has been found. + */ + private String module; + + /** + * Constructs a default @module taglet. + */ + private Module() { + super(); + } + + /** + * Returns the name of this custom tag. + * + * @return The tag name. + */ + @Override + public String getName() { + return "module"; + } + + /** + * Returns {@code false} since @module can not be used in overview. + * + * @return Always {@code false}. + */ + @Override + public boolean inOverview() { + return false; + } + + /** + * Returns {@code true} since @module can be used in package documentation. + * + * @return Always {@code true}. + */ + @Override + public boolean inPackage() { + return true; + } + + /** + * Returns {@code true} since @module can be used in type documentation + * (classes or interfaces). This is actually its main target. + * + * @return Always {@code true}. + */ + @Override + public boolean inType() { + return true; + } + + /** + * Returns {@code false} since @module can not be used in constructor + * + * @return Always {@code false}. + */ + @Override + public boolean inConstructor() { + return false; + } + + /** + * Returns {@code false} since @module can not be used in method documentation. + * + * @return Always {@code false}. + */ + @Override + public boolean inMethod() { + return false; + } + + /** + * Returns {@code false} since @module can not be used in field documentation. + * + * @return Always {@code false}. + */ + @Override + public boolean inField() { + return false; + } + + /** + * Returns {@code false} since @module is not an inline tag. + * + * @return Always {@code false}. + */ + @Override + public boolean isInlineTag() { + return false; + } + + /** + * Given the Tag representation of this custom tag, return its string representation. + * The default implementation invokes the array variant of this method. + * + * @param tag The tag to format. + * @return A string representation of the given tag. + */ + @Override + public String toString(final Tag tag) { + return toString(new Tag[] {tag}); + } + + /** + * Given an array of {@code Tag}s representing this custom tag, return its string + * representation. + * + * @param tags The tags to format. + * @return A string representation of the given tags. + */ + @Override + public String toString(final Tag[] tags) { + if (tags==null || tags.length==0) { + return ""; + } + final StringBuilder buffer = new StringBuilder("\n
Module:
"); + for (int i=0; i" : "
") + .append("" + + "\n
"); + /* + * Appends the module link. + */ + openMavenReportLink(buffer); + buffer.append("index.html\">").append(module).append(""); + /* + * Appends the "(download binary)" link. + */ + buffer.append("\n(download)"); + /* + * Appends the "View source code for this class" link. + */ + buffer.append("\n\n"); + final Doc holder = tag.holder(); + if (holder instanceof ClassDoc) { + ClassDoc outer, doc = (ClassDoc) holder; + while ((outer = doc.containingClass()) != null) { + doc = outer; + } + buffer.append("    "); + openMavenReportLink(buffer); + buffer.append("xref/").append(doc.qualifiedName()) + .append(".html\">View source code for this class"); + } + buffer.append("\n
"); + } + return buffer.append("\n").toString(); + } + + /** + * Opens a {@code } element toward the Maven report directory. + * A trailing slash is included. + * + * @param buffer The buffer in which to write. + */ + private void openMavenReportLink(final StringBuilder buffer) { + buffer.append("@note tag for inserting a note in a javadoc comment. + * + * @author Martin Desruisseaux (Geomatys) + * @since 0.3 (derived from geotk-3.00) + * @version 0.3 + */ +public final class Note implements Taglet { + /** + * Register this taglet. + * + * @param tagletMap the map to register this tag to. + */ + public static void register(final Map tagletMap) { + final Note tag = new Note(); + tagletMap.put(tag.getName(), tag); + } + + /** + * Constructs a default @note taglet. + */ + private Note() { + super(); + } + + /** + * Returns the name of this custom tag. + * + * @return The tag name. + */ + @Override + public String getName() { + return "note"; + } + + /** + * Returns {@code true} since @note can be used in overview. + * + * @return Always {@code false}. + */ + @Override + public boolean inOverview() { + return true; + } + + /** + * Returns {@code true} since @note can be used in package documentation. + * + * @return Always {@code true}. + */ + @Override + public boolean inPackage() { + return true; + } + + /** + * Returns {@code true} since @note can be used in type documentation + * (classes or interfaces). + * + * @return Always {@code true}. + */ + @Override + public boolean inType() { + return true; + } + + /** + * Returns {@code true} since @note can be used in constructor + * + * @return Always {@code true}. + */ + @Override + public boolean inConstructor() { + return true; + } + + /** + * Returns {@code true} since @note can be used in method documentation. + * + * @return Always {@code true}. + */ + @Override + public boolean inMethod() { + return true; + } + + /** + * Returns {@code true} since @note can be used in field documentation. + * + * @return Always {@code true}. + */ + @Override + public boolean inField() { + return true; + } + + /** + * Returns {@code true} since @note is an inline tag. + * + * @return Always {@code true}. + */ + @Override + public boolean isInlineTag() { + return true; + } + + /** + * Given the Tag representation of this custom tag, return its string representation. + * + * @param tag The tag to format. + * @return A string representation of the given tag. + */ + @Override + public String toString(final Tag tag) { + final StringBuilder buffer = new StringBuilder("
Note:\n"); + buffer.append(tag.text()); + return buffer.append("
").toString(); + } + + /** + * Given an array of {@code Tag}s representing this custom tag, return its string + * representation. This method should not be called since arrays of inline tags do + * not exist. However we define it as a matter of principle. + * + * @param tags The tags to format. + * @return A string representation of the given tags. + */ + @Override + public String toString(final Tag[] tags) { + final StringBuilder buffer = new StringBuilder(); + for (int i=0; i@preformat tag for inserting a pre-formatted code in a javadoc comment. + * The first word after the tag must be the format name ("java", "math", "wkt" or "text"). + * The remaining is the text to format. + * + * @author Martin Desruisseaux (Geomatys) + * @since 0.3 (derived from geotk-3.00) + * @version 0.3 + */ +public final class Preformat implements Taglet { + /** + * Special characters to replace by HTML entities. + */ + private static final String[] SPECIAL_CHARS = new String[] { + "&", "&", + "<", "<", + ">", ">", + "↑", "↑" + }; + + /** + * Register this taglet. + * + * @param tagletMap the map to register this tag to. + */ + public static void register(final Map tagletMap) { + final Preformat tag = new Preformat(); + tagletMap.put(tag.getName(), tag); + } + + /** + * Constructs a default @preformat taglet. + */ + private Preformat() { + super(); + } + + /** + * Returns the name of this custom tag. + * + * @return The tag name. + */ + @Override + public String getName() { + return "preformat"; + } + + /** + * Returns {@code false} since @preformat can not be used in overview. + * + * @return Always {@code false}. + */ + @Override + public boolean inOverview() { + return false; + } + + /** + * Returns {@code true} since @preformat can be used in package documentation. + * + * @return Always {@code true}. + */ + @Override + public boolean inPackage() { + return true; + } + + /** + * Returns {@code true} since @preformat can be used in type documentation + * (classes or interfaces). + * + * @return Always {@code true}. + */ + @Override + public boolean inType() { + return true; + } + + /** + * Returns {@code true} since @preformat can be used in constructor + * + * @return Always {@code true}. + */ + @Override + public boolean inConstructor() { + return true; + } + + /** + * Returns {@code true} since @preformat can be used in method documentation. + * + * @return Always {@code true}. + */ + @Override + public boolean inMethod() { + return true; + } + + /** + * Returns {@code true} since @preformat can be used in field documentation. + * + * @return Always {@code true}. + */ + @Override + public boolean inField() { + return true; + } + + /** + * Returns {@code true} since @preformat is an inline tag. + * + * @return Always {@code true}. + */ + @Override + public boolean isInlineTag() { + return true; + } + + /** + * Given an array of {@code Tag}s representing this custom tag, return its string + * representation. This method should not be called since arrays of inline tags do + * not exist. However we define it as a matter of principle. + * + * @param tags The tags to format. + * @return A string representation of the given tags. + */ + @Override + public String toString(final Tag[] tags) { + final StringBuilder buffer = new StringBuilder(); + for (int i=0; iTag representation of this custom tag, return its string representation. + * + * @param tag The tag to format. + * @return A string representation of the given tag. + */ + @Override + public String toString(final Tag tag) { + String text = tag.text().trim().replace("\r\n", "\n").replace('\r', '\n'); + String format = ""; + /* + * Extracts the first word, which is expected to be the format name. + */ + for (int i=0; i
");
+        tk = new StringTokenizer(text, "\r\n", true);
+        while (tk.hasMoreTokens()) {
+            String line = tk.nextToken();
+            if (!line.startsWith("\n")) {
+                if (margin < line.length()) {
+                    line = line.substring(margin);
+                }
+                for (int i=0; i").toString();
+    }
+
+    /**
+     * Lists of Java keywords.
+     */
+    private static final Set KEYWORDS =
+            Collections.unmodifiableSet(new HashSet(Arrays.asList(
+        "abstract", "continue", "for",        "new",        "switch",
+        "assert",   "default",  "goto",       "package",    "synchronized",
+        "boolean",  "do",       "if",         "private",    "this",
+        "break",    "double",   "implements", "protected",  "throw",
+        "byte",     "else",     "import",     "public",     "throws",
+        "case",     "enum",     "instanceof", "return",     "transient",
+        "catch",    "extends",  "int",        "short",      "try",
+        "char",     "final",    "interface",  "static",     "void",
+        "class",    "finally",  "long",       "strictfp",   "volatile",
+        "const",    "float",    "native",     "super",      "while",
+        /* literals: */ "true", "false", "null"
+    )));
+
+    /**
+     * Adds syntactic coloration for the given line.
+     */
+    private static void colorJava(final String line, final StringBuilder buffer) {
+        char quote = 0; // The kind of quoting in progress (" or ').
+        final int length = line.length();
+        for (int i=0; i");
+                    if (keyword)  buffer.append("");
+                    if (true)     buffer.append(word);
+                    if (keyword)  buffer.append("");
+                    if (function) buffer.append("");
+                    continue;
+                }
+                switch (c) {
+                    case '/': {
+                        if (i+1 < length && line.charAt(i+1) == '/') {
+                            buffer.append("").append(line.substring(i)).append("");
+                            return;
+                        }
+                        break;
+                    }
+                    case '\'': // fall through
+                    case '"': {
+                        quote = c;
+                        buffer.append("").append(c);
+                        continue;
+                    }
+                }
+            } else if (c == quote) {
+                quote = 0;
+                buffer.append(c).append("");
+                continue;
+            }
+            buffer.append(c);
+        }
+    }
+
+    /**
+     * Removes the leading and trailing linefeeds (but not other kind of spaces).
+     */
+    private static String trim(final String line) {
+        int high = line.length();
+        while (high != 0) {
+            final char c = line.charAt(high - 1);
+            if (c != '\r' && c != '\n') break;
+            high--;
+        }
+        int low = 0;
+        while (low != high) {
+            final char c = line.charAt(low);
+            if (c != '\r' && c != '\n') break;
+            low++;
+        }
+        return line.substring(low, high);
+    }
+}

Propchange: sis/trunk/sis-build-helper/src/main/java/org/apache/sis/internal/taglet/Preformat.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: sis/trunk/sis-build-helper/src/main/java/org/apache/sis/internal/taglet/Preformat.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: sis/trunk/sis-build-helper/src/main/java/org/apache/sis/internal/taglet/Section.java
URL: http://svn.apache.org/viewvc/sis/trunk/sis-build-helper/src/main/java/org/apache/sis/internal/taglet/Section.java?rev=1389415&view=auto
==============================================================================
--- sis/trunk/sis-build-helper/src/main/java/org/apache/sis/internal/taglet/Section.java (added)
+++ sis/trunk/sis-build-helper/src/main/java/org/apache/sis/internal/taglet/Section.java Mon Sep 24 14:53:43 2012
@@ -0,0 +1,172 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sis.internal.taglet;
+
+import java.util.Map;
+import com.sun.javadoc.Doc;
+import com.sun.javadoc.Tag;
+import com.sun.tools.doclets.Taglet;
+
+
+/**
+ * The @section tag for inserting a new section in a javadoc comment.
+ *
+ * @author  Martin Desruisseaux (Geomatys)
+ * @since   0.3 (derived from geotk-3.00)
+ * @version 0.3
+ */
+public final class Section implements Taglet {
+    /**
+     * Register this taglet.
+     *
+     * @param tagletMap the map to register this tag to.
+     */
+    public static void register(final Map tagletMap) {
+       final Section tag = new Section();
+       tagletMap.put(tag.getName(), tag);
+    }
+
+    /**
+     * Constructs a default @section taglet.
+     */
+    private Section() {
+        super();
+    }
+
+    /**
+     * Returns the name of this custom tag.
+     *
+     * @return The tag name.
+     */
+    @Override
+    public String getName() {
+        return "section";
+    }
+
+    /**
+     * Returns {@code false} since @section can not be used in overview.
+     *
+     * @return Always {@code false}.
+     */
+    @Override
+    public boolean inOverview() {
+        return false;
+    }
+
+    /**
+     * Returns {@code true} since @section can be used in package documentation.
+     *
+     * @return Always {@code true}.
+     */
+    @Override
+    public boolean inPackage() {
+        return true;
+    }
+
+    /**
+     * Returns {@code true} since @section can be used in type documentation
+     * (classes or interfaces).
+     *
+     * @return Always {@code true}.
+     */
+    @Override
+    public boolean inType() {
+        return true;
+    }
+
+    /**
+     * Returns {@code true} since @section can be used in constructor
+     *
+     * @return Always {@code true}.
+     */
+    @Override
+    public boolean inConstructor() {
+        return true;
+    }
+
+    /**
+     * Returns {@code true} since @section can be used in method documentation.
+     *
+     * @return Always {@code true}.
+     */
+    @Override
+    public boolean inMethod() {
+        return true;
+    }
+
+    /**
+     * Returns {@code true} since @section can be used in field documentation.
+     *
+     * @return Always {@code true}.
+     */
+    @Override
+    public boolean inField() {
+        return true;
+    }
+
+    /**
+     * Returns {@code true} since @section is an inline tag.
+     *
+     * @return Always {@code true}.
+     */
+    @Override
+    public boolean isInlineTag() {
+        return true;
+    }
+
+    /**
+     * Given the Tag representation of this custom tag, return its string representation.
+     *
+     * @param tag The tag to format.
+     * @return A string representation of the given tag.
+     */
+    @Override
+    public String toString(final Tag tag) {
+        final Doc holder = tag.holder();
+        final boolean small = holder == null || holder.isField() || holder.isMethod() || holder.isConstructor();
+        final StringBuilder buffer = new StringBuilder("

"); + if (!small) { + buffer.append("
"); + } + buffer.append("\n"); + if (!small) { + buffer.append(""); + } + buffer.append(tag.text()); + if (!small) { + buffer.append(""); + } + return buffer.append("
").toString(); + } + + /** + * Given an array of {@code Tag}s representing this custom tag, return its string + * representation. This method should not be called since arrays of inline tags do + * not exist. However we define it as a matter of principle. + * + * @param tags The tags to format. + * @return A string representation of the given tags. + */ + @Override + public String toString(final Tag[] tags) { + final StringBuilder buffer = new StringBuilder(); + for (int i=0; i