sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
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 GMT
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 @@
     </plugins>
   </build>
 
+
+  <!-- ===========================================================
+           Sun's tools dependency   (from Maven FAQ)
+       =========================================================== -->
+  <profiles>
+    <profile>
+      <id>default-tools.jar</id>
+      <activation>
+        <property>
+          <name>java.vendor</name>
+          <value>Sun Microsystems Inc.</value>
+        </property>
+      </activation>
+      <dependencies>
+        <dependency>
+          <groupId>com.sun</groupId>
+          <artifactId>tools</artifactId>
+          <version>${java.version}</version>
+          <scope>system</scope>
+          <systemPath>${java.home}/../lib/tools.jar</systemPath>
+        </dependency>
+      </dependencies>
+    </profile>
+
+    <!-- Following is a copy of the above profile with only the Java vendor name changed.
+         This copy will not be needed anymore if http://jira.codehaus.org/browse/MNG-3328
+         get fixed. -->
+    <profile>
+      <id>jdk7-tools.jar</id>
+      <activation>
+        <property>
+          <name>java.vendor</name>
+          <value>Oracle Corporation</value>
+        </property>
+      </activation>
+      <dependencies>
+        <dependency>
+          <groupId>com.sun</groupId>
+          <artifactId>tools</artifactId>
+          <version>${java.version}</version>
+          <scope>system</scope>
+          <systemPath>${java.home}/../lib/tools.jar</systemPath>
+        </dependency>
+      </dependencies>
+    </profile>
+  </profiles>
+
 </project>

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 <code>@module</code> 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<String,Taglet> 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 <a href="http://www.apache.org/dev/repository-faq.html">ASF Jar Repositories</a>
+     * for more information.
+     */
+    private static final String MAVEN_REPOSITORY_BASE_URL = "http://repository.apache.org/snapshots/";
+
+    /**
+     * The SIS module in which the <code>@module</code> taglet has been found.
+     */
+    private String module;
+
+    /**
+     * Constructs a default <code>@module</code> 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 <code>@module</code> can not be used in overview.
+     *
+     * @return Always {@code false}.
+     */
+    @Override
+    public boolean inOverview() {
+        return false;
+    }
+
+    /**
+     * Returns {@code true} since <code>@module</code> can be used in package
documentation.
+     *
+     * @return Always {@code true}.
+     */
+    @Override
+    public boolean inPackage() {
+        return true;
+    }
+
+    /**
+     * Returns {@code true} since <code>@module</code> 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 <code>@module</code> can not be used in constructor
+     *
+     * @return Always {@code false}.
+     */
+    @Override
+    public boolean inConstructor() {
+        return false;
+    }
+
+    /**
+     * Returns {@code false} since <code>@module</code> can not be used in method
documentation.
+     *
+     * @return Always {@code false}.
+     */
+    @Override
+    public boolean inMethod() {
+        return false;
+    }
+
+    /**
+     * Returns {@code false} since <code>@module</code> can not be used in field
documentation.
+     *
+     * @return Always {@code false}.
+     */
+    @Override
+    public boolean inField() {
+        return false;
+    }
+
+    /**
+     * Returns {@code false} since <code>@module</code> is not an inline tag.
+     *
+     * @return Always {@code false}.
+     */
+    @Override
+    public boolean isInlineTag() {
+        return false;
+    }
+
+    /**
+     * Given the <code>Tag</code> 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<dt><b>Module:</b></dt>");
+        for (int i=0; i<tags.length; i++) {
+            final Tag tag = tags[i];
+            File file = tag.position().file();
+            module = file.getName();
+            while (file != null) {
+                file = file.getParentFile();
+                if (file.getName().equals("src")) {
+                    file = file.getParentFile();
+                    if (file != null) {
+                        module = file.getName();
+                    }
+                    break;
+                }
+            }
+            buffer.append('\n').append(i==0 ? "<dd>" : "<br>")
+                  .append("<table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">"
+
+                          "<tr>\n<td align=\"left\">");
+            /*
+             * Appends the module link.
+             */
+            openMavenReportLink(buffer);
+            buffer.append("index.html\">").append(module).append("</a>");
+            /*
+             * Appends the "(download binary)" link.
+             */
+            buffer.append("\n<font size=\"-2\">(<a href=\"").append(MAVEN_REPOSITORY_BASE_URL)
+                  .append("org/apache/sis/").append(module).append('/').append(VERSION).append('/')
+                  .append("\">download</a>)</font>");
+            /*
+             * Appends the "View source code for this class" link.
+             */
+            buffer.append("\n</td><td align=\"right\">\n");
+            final Doc holder = tag.holder();
+            if (holder instanceof ClassDoc) {
+                ClassDoc outer, doc = (ClassDoc) holder;
+                while ((outer = doc.containingClass()) != null) {
+                    doc = outer;
+                }
+                buffer.append(" &nbsp;&nbsp; ");
+                openMavenReportLink(buffer);
+                buffer.append("xref/").append(doc.qualifiedName())
+                      .append(".html\">View source code for this class</a>");
+            }
+            buffer.append("\n</td></tr></table>");
+        }
+        return buffer.append("</dd>\n").toString();
+    }
+
+    /**
+     * Opens a {@code <A HREF>} 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("<a href=\"").append(MAVEN_REPORTS_BASE_URL).append('/').append(module).append('/');
+    }
+}

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

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

Added: sis/trunk/sis-build-helper/src/main/java/org/apache/sis/internal/taglet/Note.java
URL: http://svn.apache.org/viewvc/sis/trunk/sis-build-helper/src/main/java/org/apache/sis/internal/taglet/Note.java?rev=1389415&view=auto
==============================================================================
--- sis/trunk/sis-build-helper/src/main/java/org/apache/sis/internal/taglet/Note.java (added)
+++ sis/trunk/sis-build-helper/src/main/java/org/apache/sis/internal/taglet/Note.java Mon
Sep 24 14:53:43 2012
@@ -0,0 +1,159 @@
+/*
+ * 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.Tag;
+import com.sun.tools.doclets.Taglet;
+
+
+/**
+ * The <code>@note</code> 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<String,Taglet> tagletMap) {
+       final Note tag = new Note();
+       tagletMap.put(tag.getName(), tag);
+    }
+
+    /**
+     * Constructs a default <code>@note</code> 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 <code>@note</code> can be used in overview.
+     *
+     * @return Always {@code false}.
+     */
+    @Override
+    public boolean inOverview() {
+        return true;
+    }
+
+    /**
+     * Returns {@code true} since <code>@note</code> can be used in package documentation.
+     *
+     * @return Always {@code true}.
+     */
+    @Override
+    public boolean inPackage() {
+        return true;
+    }
+
+    /**
+     * Returns {@code true} since <code>@note</code> can be used in type documentation
+     * (classes or interfaces).
+     *
+     * @return Always {@code true}.
+     */
+    @Override
+    public boolean inType() {
+        return true;
+    }
+
+    /**
+     * Returns {@code true} since <code>@note</code> can be used in constructor
+     *
+     * @return Always {@code true}.
+     */
+    @Override
+    public boolean inConstructor() {
+        return true;
+    }
+
+    /**
+     * Returns {@code true} since <code>@note</code> can be used in method documentation.
+     *
+     * @return Always {@code true}.
+     */
+    @Override
+    public boolean inMethod() {
+        return true;
+    }
+
+    /**
+     * Returns {@code true} since <code>@note</code> can be used in field documentation.
+     *
+     * @return Always {@code true}.
+     */
+    @Override
+    public boolean inField() {
+        return true;
+    }
+
+    /**
+     * Returns {@code true} since <code>@note</code> is an inline tag.
+     *
+     * @return Always {@code true}.
+     */
+    @Override
+    public boolean isInlineTag() {
+        return true;
+    }
+
+    /**
+     * Given the <code>Tag</code> 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("<blockquote><font size=-1><b>Note:</b>\n");
+        buffer.append(tag.text());
+        return buffer.append("</font></blockquote>").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<tags.length; i++) {
+            buffer.append(toString(tags[i]));
+        }
+        return buffer.toString();
+    }
+}

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

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

Added: sis/trunk/sis-build-helper/src/main/java/org/apache/sis/internal/taglet/Preformat.java
URL: http://svn.apache.org/viewvc/sis/trunk/sis-build-helper/src/main/java/org/apache/sis/internal/taglet/Preformat.java?rev=1389415&view=auto
==============================================================================
--- sis/trunk/sis-build-helper/src/main/java/org/apache/sis/internal/taglet/Preformat.java
(added)
+++ sis/trunk/sis-build-helper/src/main/java/org/apache/sis/internal/taglet/Preformat.java
Mon Sep 24 14:53:43 2012
@@ -0,0 +1,328 @@
+/*
+ * 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.*;
+import com.sun.javadoc.Tag;
+import com.sun.tools.doclets.Taglet;
+import com.sun.tools.doclets.formats.html.ConfigurationImpl;
+
+
+/**
+ * The <code>@preformat</code> 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[] {
+        "&", "&amp;",
+        "<", "&lt;",
+        ">", "&gt;",
+        "↑", "&uarr;"
+    };
+
+    /**
+     * Register this taglet.
+     *
+     * @param tagletMap the map to register this tag to.
+     */
+    public static void register(final Map<String,Taglet> tagletMap) {
+       final Preformat tag = new Preformat();
+       tagletMap.put(tag.getName(), tag);
+    }
+
+    /**
+     * Constructs a default <code>@preformat</code> 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 <code>@preformat</code> can not be used in
overview.
+     *
+     * @return Always {@code false}.
+     */
+    @Override
+    public boolean inOverview() {
+        return false;
+    }
+
+    /**
+     * Returns {@code true} since <code>@preformat</code> can be used in package
documentation.
+     *
+     * @return Always {@code true}.
+     */
+    @Override
+    public boolean inPackage() {
+        return true;
+    }
+
+    /**
+     * Returns {@code true} since <code>@preformat</code> can be used in type
documentation
+     * (classes or interfaces).
+     *
+     * @return Always {@code true}.
+     */
+    @Override
+    public boolean inType() {
+        return true;
+    }
+
+    /**
+     * Returns {@code true} since <code>@preformat</code> can be used in constructor
+     *
+     * @return Always {@code true}.
+     */
+    @Override
+    public boolean inConstructor() {
+        return true;
+    }
+
+    /**
+     * Returns {@code true} since <code>@preformat</code> can be used in method
documentation.
+     *
+     * @return Always {@code true}.
+     */
+    @Override
+    public boolean inMethod() {
+        return true;
+    }
+
+    /**
+     * Returns {@code true} since <code>@preformat</code> can be used in field
documentation.
+     *
+     * @return Always {@code true}.
+     */
+    @Override
+    public boolean inField() {
+        return true;
+    }
+
+    /**
+     * Returns {@code true} since <code>@preformat</code> 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; i<tags.length; i++) {
+            buffer.append(toString(tags[i]));
+        }
+        return buffer.toString();
+    }
+
+    /**
+     * Given the <code>Tag</code> 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 = "<unspecified>";
+        /*
+         * Extracts the first word, which is expected to be the format name.
+         */
+        for (int i=0; i<text.length(); i++) {
+            if (Character.isWhitespace(text.charAt(i))) {
+                format = text.substring(0, i);
+                text = trim(text.substring(i));
+                break;
+            }
+        }
+        final boolean java  = format.equals("java");
+        final boolean math  = format.equals("math");
+        final boolean wkt   = format.equals("wkt");
+        final boolean xml   = format.equals("xml");
+        final boolean sql   = format.equals("sql");
+        final boolean shell = format.equals("shell");
+        if (!java && !math && !wkt && !xml && !sql &&
!shell && !format.equals("text")) {
+            ConfigurationImpl.getInstance().root.printWarning(tag.position(), "Unknown format:
" + format);
+        }
+        /*
+         * Counts the minimal amount of spaces in the margin.
+         */
+        int margin = 0;
+        StringTokenizer tk = new StringTokenizer(text, "\r\n");
+all:    while (tk.hasMoreTokens()) {
+            final String line = tk.nextToken();
+            int stop = line.length();
+            if (margin != 0 && margin < stop) {
+                stop = margin;
+            }
+            for (int i=0; i<stop; i++) {
+                if (!Character.isSpaceChar(line.charAt(i))) {
+                    if (margin == 0 || i < margin) {
+                        margin = i;
+                    }
+                    if (i == 0) {
+                        break all;
+                    }
+                    break;
+                }
+            }
+        }
+        /*
+         * Nows inserts each line.
+         */
+        final StringBuilder buffer = new StringBuilder("<blockquote><pre>");
+        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<SPECIAL_CHARS.length;) {
+                    line = line.replace(SPECIAL_CHARS[i++], SPECIAL_CHARS[i++]);
+                }
+                if (java) {
+                    colorJava(line, buffer);
+                    continue;
+                }
+            }
+            buffer.append(line);
+        }
+        return buffer.append("</pre></blockquote>").toString();
+    }
+
+    /**
+     * Lists of Java keywords.
+     */
+    private static final Set<String> KEYWORDS =
+            Collections.unmodifiableSet(new HashSet<String>(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<length; i++) {
+            final char c = line.charAt(i);
+            if (quote == 0) {
+                if (Character.isJavaIdentifierStart(c)) {
+                    int j = i;
+                    while (++j < length && Character.isJavaIdentifierPart(line.charAt(j)));
+                    final String word = line.substring(i, j);
+                    final boolean keyword = KEYWORDS.contains(word);
+                    i = j-1;
+                    boolean function = false;
+                    if (!keyword || word.equals("this") || word.equals("super")) {
+                        while (j < length) {
+                            final char t = line.charAt(j++);
+                            if (!Character.isWhitespace(t)) {
+                                function = (t == '(');
+                                break;
+                            }
+                        }
+                    }
+                    if (function) buffer.append("<b>");
+                    if (keyword)  buffer.append("<font color=\"green\">");
+                    if (true)     buffer.append(word);
+                    if (keyword)  buffer.append("</font>");
+                    if (function) buffer.append("</b>");
+                    continue;
+                }
+                switch (c) {
+                    case '/': {
+                        if (i+1 < length && line.charAt(i+1) == '/') {
+                            buffer.append("<i><font color=\"gray\">").append(line.substring(i)).append("</font></i>");
+                            return;
+                        }
+                        break;
+                    }
+                    case '\'': // fall through
+                    case '"': {
+                        quote = c;
+                        buffer.append("<font color=\"orangered\">").append(c);
+                        continue;
+                    }
+                }
+            } else if (c == quote) {
+                quote = 0;
+                buffer.append(c).append("</font>");
+                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 <code>@section</code> 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<String,Taglet> tagletMap) {
+       final Section tag = new Section();
+       tagletMap.put(tag.getName(), tag);
+    }
+
+    /**
+     * Constructs a default <code>@section</code> 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 <code>@section</code> can not be used in overview.
+     *
+     * @return Always {@code false}.
+     */
+    @Override
+    public boolean inOverview() {
+        return false;
+    }
+
+    /**
+     * Returns {@code true} since <code>@section</code> can be used in package
documentation.
+     *
+     * @return Always {@code true}.
+     */
+    @Override
+    public boolean inPackage() {
+        return true;
+    }
+
+    /**
+     * Returns {@code true} since <code>@section</code> can be used in type documentation
+     * (classes or interfaces).
+     *
+     * @return Always {@code true}.
+     */
+    @Override
+    public boolean inType() {
+        return true;
+    }
+
+    /**
+     * Returns {@code true} since <code>@section</code> can be used in constructor
+     *
+     * @return Always {@code true}.
+     */
+    @Override
+    public boolean inConstructor() {
+        return true;
+    }
+
+    /**
+     * Returns {@code true} since <code>@section</code> can be used in method
documentation.
+     *
+     * @return Always {@code true}.
+     */
+    @Override
+    public boolean inMethod() {
+        return true;
+    }
+
+    /**
+     * Returns {@code true} since <code>@section</code> can be used in field
documentation.
+     *
+     * @return Always {@code true}.
+     */
+    @Override
+    public boolean inField() {
+        return true;
+    }
+
+    /**
+     * Returns {@code true} since <code>@section</code> is an inline tag.
+     *
+     * @return Always {@code true}.
+     */
+    @Override
+    public boolean isInlineTag() {
+        return true;
+    }
+
+    /**
+     * Given the <code>Tag</code> 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("<p>");
+        if (!small) {
+            buffer.append("<br>");
+        }
+        buffer.append("\n<b><u>");
+        if (!small) {
+            buffer.append("<font size=+1>");
+        }
+        buffer.append(tag.text());
+        if (!small) {
+            buffer.append("</font>");
+        }
+        return buffer.append("</u></b><br>").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<tags.length; i++) {
+            buffer.append(toString(tags[i]));
+        }
+        return buffer.toString();
+    }
+}

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

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

Added: sis/trunk/sis-build-helper/src/main/java/org/apache/sis/internal/taglet/package-info.java
URL: http://svn.apache.org/viewvc/sis/trunk/sis-build-helper/src/main/java/org/apache/sis/internal/taglet/package-info.java?rev=1389415&view=auto
==============================================================================
--- sis/trunk/sis-build-helper/src/main/java/org/apache/sis/internal/taglet/package-info.java
(added)
+++ sis/trunk/sis-build-helper/src/main/java/org/apache/sis/internal/taglet/package-info.java
Mon Sep 24 14:53:43 2012
@@ -0,0 +1,26 @@
+/*
+ * 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.
+ */
+
+
+/**
+ * Javadoc taglets for processing custom tags in SIS source code comments.
+ *
+ * @author  Martin Desruisseaux (IRD, Geomatys)
+ * @since   0.3 (derived from geotk-2.2)
+ * @version 0.3
+ */
+package org.apache.sis.internal.taglet;

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

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

Added: sis/trunk/sis-build-helper/src/main/java/org/apache/sis/resources/package-info.txt
URL: http://svn.apache.org/viewvc/sis/trunk/sis-build-helper/src/main/java/org/apache/sis/resources/package-info.txt?rev=1389415&view=auto
==============================================================================
--- sis/trunk/sis-build-helper/src/main/java/org/apache/sis/resources/package-info.txt (added)
+++ sis/trunk/sis-build-helper/src/main/java/org/apache/sis/resources/package-info.txt Mon
Sep 24 14:53:43 2012
@@ -0,0 +1,2 @@
+This directory has no "package-info.java" file
+because it is defined in the sis-utility module.

Propchange: sis/trunk/sis-build-helper/src/main/java/org/apache/sis/resources/package-info.txt
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: sis/trunk/sis-build-helper/src/main/java/org/apache/sis/resources/package-info.txt
------------------------------------------------------------------------------
    svn:mime-type = text/plain



Mime
View raw message