You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sis.apache.org by de...@apache.org on 2016/12/11 17:56:17 UTC
svn commit: r1773593 - in /sis/branches/JDK9/core/sis-build-helper: ./
src/main/java/org/apache/sis/internal/doclet/
src/main/java/org/apache/sis/internal/taglet/
Author: desruisseaux
Date: Sun Dec 11 17:56:17 2016
New Revision: 1773593
URL: http://svn.apache.org/viewvc?rev=1773593&view=rev
Log:
Upgrade to the new doclet API. We have one unresolved issue, which is how to get the file where a tag is contained (was allowed in the old API, I didn't found the replacement yet).
Modified:
sis/branches/JDK9/core/sis-build-helper/pom.xml
sis/branches/JDK9/core/sis-build-helper/src/main/java/org/apache/sis/internal/doclet/Doclet.java
sis/branches/JDK9/core/sis-build-helper/src/main/java/org/apache/sis/internal/doclet/package-info.java
sis/branches/JDK9/core/sis-build-helper/src/main/java/org/apache/sis/internal/taglet/Include.java
sis/branches/JDK9/core/sis-build-helper/src/main/java/org/apache/sis/internal/taglet/InlineTaglet.java
sis/branches/JDK9/core/sis-build-helper/src/main/java/org/apache/sis/internal/taglet/Module.java
sis/branches/JDK9/core/sis-build-helper/src/main/java/org/apache/sis/internal/taglet/Preformat.java
sis/branches/JDK9/core/sis-build-helper/src/main/java/org/apache/sis/internal/taglet/package-info.java
Modified: sis/branches/JDK9/core/sis-build-helper/pom.xml
URL: http://svn.apache.org/viewvc/sis/branches/JDK9/core/sis-build-helper/pom.xml?rev=1773593&r1=1773592&r2=1773593&view=diff
==============================================================================
--- sis/branches/JDK9/core/sis-build-helper/pom.xml (original)
+++ sis/branches/JDK9/core/sis-build-helper/pom.xml Sun Dec 11 17:56:17 2016
@@ -132,51 +132,4 @@ Define Maven Mojos and Javadoc taglets f
</dependency>
</dependencies>
-
- <!-- ===========================================================
- 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>jdk8-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>
Modified: sis/branches/JDK9/core/sis-build-helper/src/main/java/org/apache/sis/internal/doclet/Doclet.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK9/core/sis-build-helper/src/main/java/org/apache/sis/internal/doclet/Doclet.java?rev=1773593&r1=1773592&r2=1773593&view=diff
==============================================================================
--- sis/branches/JDK9/core/sis-build-helper/src/main/java/org/apache/sis/internal/doclet/Doclet.java [UTF-8] (original)
+++ sis/branches/JDK9/core/sis-build-helper/src/main/java/org/apache/sis/internal/doclet/Doclet.java [UTF-8] Sun Dec 11 17:56:17 2016
@@ -16,6 +16,10 @@
*/
package org.apache.sis.internal.doclet;
+import java.util.Set;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Locale;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
@@ -29,8 +33,12 @@ import java.io.PrintWriter;
import java.io.StringWriter;
import java.nio.file.FileSystemException;
import java.nio.file.Files;
-import com.sun.javadoc.RootDoc;
-import com.sun.tools.doclets.formats.html.HtmlDoclet;
+import javax.tools.Diagnostic;
+import jdk.javadoc.doclet.Reporter;
+import jdk.javadoc.doclet.Doclet.Option;
+import jdk.javadoc.doclet.DocletEnvironment;
+import jdk.javadoc.doclets.StandardDoclet;
+import org.apache.sis.internal.taglet.InlineTaglet;
/**
@@ -51,10 +59,10 @@ import com.sun.tools.doclets.formats.htm
*
* @author Martin Desruisseaux (Geomatys)
* @since 0.5
- * @version 0.7
+ * @version 0.8
* @module
*/
-public final class Doclet extends HtmlDoclet {
+public final class Doclet extends StandardDoclet {
/**
* The name of the standard stylesheet file generated by Javadoc.
*/
@@ -76,21 +84,73 @@ public final class Doclet extends HtmlDo
private static final String ENCODING = "UTF-8";
/**
- * Invoked by Javadoc for starting the doclet.
+ * The directory where HTML pages will be written.
+ */
+ private String outputDirectory;
+
+ /**
+ * Invoked by the Javadoc tools for instantiating the custom doclet.
+ */
+ public Doclet() {
+ }
+
+ /**
+ * Invoked by the Javadoc tools for initializing the doclet.
*
- * @param root The root document.
- * @return {@code true} on success, or {@code false} on failure.
+ * @param locale the locale to use for formatting HTML content.
+ * @param reporter where to report warnings and errors.
*/
- public static boolean start(final RootDoc root) {
- String outputDirectory = null;
- for (final String[] option : root.options()) {
- if (option.length == 2) {
- if ("-d".equals(option[0])) {
- outputDirectory = option[1];
- }
+ @Override
+ public void init(final Locale locale, final Reporter reporter) {
+ super.init(locale, reporter);
+ InlineTaglet.reporter = reporter;
+ }
+
+ /**
+ * Returns the options supported by the standard doclet.
+ *
+ * @return all the supported options.
+ */
+ public Set<Option> getSupportedOptions() {
+ final Set<Option> options = new LinkedHashSet<>();
+ for (final Option op : super.getSupportedOptions()) {
+ if (op.getNames().contains("-d")) {
+ options.add(new Option() {
+ @Override public int getArgumentCount() {return op.getArgumentCount();}
+ @Override public String getDescription() {return op.getDescription();}
+ @Override public Option.Kind getKind() {return op.getKind();}
+ @Override public List<String> getNames() {return op.getNames();}
+ @Override public String getParameters() {return op.getParameters();}
+ @Override public boolean process(final String option, final List<String> arguments) {
+ outputDirectory = arguments.get(0);
+ return op.process(option, arguments);
+ }
+ });
+ } else {
+ options.add(op);
}
}
- final boolean success = HtmlDoclet.start(root);
+ return options;
+ }
+
+ /**
+ * Returns a name identifying this doclet.
+ *
+ * @return "ApacheSIS".
+ */
+ @Override
+ public String getName() {
+ return "ApacheSIS";
+ }
+
+ /**
+ * Invoked by Javadoc for starting the doclet.
+ *
+ * @param environment the Javadoc environment.
+ * @return {@code true} on success, or {@code false} on failure.
+ */
+ public boolean run(final DocletEnvironment environment) {
+ final boolean success = super.run(environment);
if (success && outputDirectory != null) try {
final File output = new File(outputDirectory);
final File customCSS = customCSS(output);
@@ -106,7 +166,7 @@ public final class Doclet extends HtmlDo
final StringWriter buffer = new StringWriter();
final PrintWriter p = new PrintWriter(buffer);
e.printStackTrace(p);
- root.printError(buffer.toString());
+ InlineTaglet.reporter.print(Diagnostic.Kind.ERROR, buffer.toString());
return false;
}
return success;
@@ -151,9 +211,9 @@ public final class Doclet extends HtmlDo
* Copies the standard CSS file, then copies the custom CSS file.
* If the {@value #RENAMED_CSS} file already exists, it will not be overwritten.
*
- * @param inputFile The custom CSS file to copy in the destination directory.
- * @param outputDirectory The directory where to copy the CSS file.
- * @throws IOException If an error occurred while reading or writing.
+ * @param inputFile the custom CSS file to copy in the destination directory.
+ * @param outputDirectory the directory where to copy the CSS file.
+ * @throws IOException if an error occurred while reading or writing.
*/
private static void copyStylesheet(final File inputFile, final File outputDirectory) throws IOException {
final File stylesheetFile = new File(outputDirectory, STYLESHEET);
@@ -197,9 +257,9 @@ public final class Doclet extends HtmlDo
* directory can be specified with {@code <javadocResourcesDirectory>}, I have been unable to make it work even
* with absolute paths.
*
- * @param inputFile The directory containing resources.
- * @param outputDirectory The directory where to copy the resource files.
- * @throws IOException If an error occurred while reading or writing.
+ * @param inputFile the directory containing resources.
+ * @param outputDirectory the directory where to copy the resource files.
+ * @throws IOException if an error occurred while reading or writing.
*/
private static void copyResources(final File inputDirectory, final File outputDirectory) throws IOException {
final File[] inputFiles = inputDirectory.listFiles((final File dir, final String name) ->
Modified: sis/branches/JDK9/core/sis-build-helper/src/main/java/org/apache/sis/internal/doclet/package-info.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK9/core/sis-build-helper/src/main/java/org/apache/sis/internal/doclet/package-info.java?rev=1773593&r1=1773592&r2=1773593&view=diff
==============================================================================
--- sis/branches/JDK9/core/sis-build-helper/src/main/java/org/apache/sis/internal/doclet/package-info.java [UTF-8] (original)
+++ sis/branches/JDK9/core/sis-build-helper/src/main/java/org/apache/sis/internal/doclet/package-info.java [UTF-8] Sun Dec 11 17:56:17 2016
@@ -21,7 +21,7 @@
*
* @author Martin Desruisseaux (Geomatys)
* @since 0.5
- * @version 0.7
+ * @version 0.8
* @module
*/
package org.apache.sis.internal.doclet;
Modified: sis/branches/JDK9/core/sis-build-helper/src/main/java/org/apache/sis/internal/taglet/Include.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK9/core/sis-build-helper/src/main/java/org/apache/sis/internal/taglet/Include.java?rev=1773593&r1=1773592&r2=1773593&view=diff
==============================================================================
--- sis/branches/JDK9/core/sis-build-helper/src/main/java/org/apache/sis/internal/taglet/Include.java [UTF-8] (original)
+++ sis/branches/JDK9/core/sis-build-helper/src/main/java/org/apache/sis/internal/taglet/Include.java [UTF-8] Sun Dec 11 17:56:17 2016
@@ -17,10 +17,7 @@
package org.apache.sis.internal.taglet;
import java.io.*;
-import java.util.Map;
-import com.sun.javadoc.Tag;
-import com.sun.javadoc.SourcePosition;
-import com.sun.tools.doclets.Taglet;
+import com.sun.source.doctree.DocTree;
/**
@@ -37,7 +34,7 @@ import com.sun.tools.doclets.Taglet;
*
* @author Martin Desruisseaux (Geomatys)
* @since 0.5
- * @version 0.5
+ * @version 0.8
* @module
*/
public final class Include extends InlineTaglet {
@@ -52,26 +49,16 @@ public final class Include extends Inlin
private static final String DOCUMENT_END = "</body>";
/**
- * Register this taglet.
- *
- * @param tagletMap the map to register this tag to.
- */
- public static void register(final Map<String,Taglet> tagletMap) {
- final Include tag = new Include();
- tagletMap.put(tag.getName(), tag);
- }
-
- /**
- * Constructs a default <code>@include</code> taglet.
+ * Constructs an <code>@include</code> taglet.
*/
- private Include() {
+ public Include() {
super();
}
/**
* Returns the name of this custom tag.
*
- * @return The tag name.
+ * @return "include".
*/
@Override
public String getName() {
@@ -79,21 +66,20 @@ public final class Include extends Inlin
}
/**
- * Given the <code>Tag</code> representation of this custom tag, return its string representation.
+ * Given the <code>DocTree</code> representation of this custom tag, return its string representation.
*
- * @param tag The tag to format.
- * @return A string representation of the given tag.
+ * @param tag the tag to format.
+ * @return a string representation of the given tag.
*/
@Override
- public String toString(final Tag tag) {
- final SourcePosition position = tag.position();
- final String reference = tag.text();
+ public String toString(final DocTree tag) {
+ final String reference = text(tag);
final int sep = reference.indexOf('#');
if (sep < 0) {
- printWarning(position, "@include expected a reference like \"filename#anchor\" but got \"" + reference + "\".");
+ printWarning(tag, "@include expected a reference like \"filename#anchor\" but got \"" + reference + "\".");
return reference;
}
- File file = position.file();
+ File file = file(tag);
file = new File(file.getParentFile(), reference.substring(0, sep));
final String anchor = reference.substring(sep + 1);
final StringBuilder buffer = new StringBuilder();
@@ -104,7 +90,7 @@ public final class Include extends Inlin
String line;
int start, end;
do if ((line = in.readLine()) == null) {
- printWarning(position, "Header \"" + anchor + "\" not found in file " + file);
+ printWarning(tag, "Header \"" + anchor + "\" not found in file " + file);
return reference;
}
while ((start = line.indexOf(ANCHOR_START)) < 0 ||
@@ -117,7 +103,7 @@ public final class Include extends Inlin
while (true) {
line = in.readLine();
if (line == null) {
- printWarning(position, "Unexpected end of file in " + file);
+ printWarning(tag, "Unexpected end of file in " + file);
return reference;
}
start = line.indexOf(ANCHOR_START);
@@ -130,7 +116,7 @@ public final class Include extends Inlin
buffer.append(line).append('\n');
}
} catch (IOException e) {
- printError(position, "Error reading " + file + ":\n" + e);
+ printError(tag, "Error reading " + file + ":\n" + e);
}
return buffer.toString();
}
Modified: sis/branches/JDK9/core/sis-build-helper/src/main/java/org/apache/sis/internal/taglet/InlineTaglet.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK9/core/sis-build-helper/src/main/java/org/apache/sis/internal/taglet/InlineTaglet.java?rev=1773593&r1=1773592&r2=1773593&view=diff
==============================================================================
--- sis/branches/JDK9/core/sis-build-helper/src/main/java/org/apache/sis/internal/taglet/InlineTaglet.java [UTF-8] (original)
+++ sis/branches/JDK9/core/sis-build-helper/src/main/java/org/apache/sis/internal/taglet/InlineTaglet.java [UTF-8] Sun Dec 11 17:56:17 2016
@@ -16,12 +16,16 @@
*/
package org.apache.sis.internal.taglet;
-import com.sun.javadoc.Tag;
-import com.sun.javadoc.RootDoc;
-import com.sun.javadoc.SourcePosition;
-import com.sun.tools.doclets.Taglet;
-import com.sun.tools.doclets.internal.toolkit.Configuration;
-import com.sun.tools.doclets.formats.html.ConfigurationImpl;
+import java.io.File;
+import java.util.Set;
+import java.util.EnumSet;
+import java.util.List;
+import javax.tools.Diagnostic;
+import jdk.javadoc.doclet.Reporter;
+import jdk.javadoc.doclet.taglet.Taglet;
+import com.sun.source.doctree.DocTree;
+import com.sun.source.doctree.TextTree;
+import com.sun.source.doctree.UnknownInlineTagTree;
/**
@@ -29,24 +33,15 @@ import com.sun.tools.doclets.formats.htm
*
* @author Martin Desruisseaux (Geomatys)
* @since 0.3
- * @version 0.3
+ * @version 0.8
* @module
*/
-abstract class InlineTaglet implements Taglet {
+public abstract class InlineTaglet implements Taglet {
/**
- * The doclet configuration, created when first needed for reporting warnings.
+ * Where to report warnings, or {@code null} if unknown.
+ * This is initialized by {@link org.apache.sis.internal.doclet.Doclet#init Doclet.init(\u2026)}.
*/
- private static Configuration configuration;
-
- /**
- * Returns the root document, or {@code null} if none.
- */
- private static synchronized RootDoc getRootDoc() {
- if (configuration == null) {
- configuration = new ConfigurationImpl();
- }
- return configuration.root;
- }
+ public static volatile Reporter reporter;
/**
* Constructs a default inline taglet.
@@ -55,89 +50,56 @@ abstract class InlineTaglet implements T
}
/**
- * Returns {@code true} since SIS taglets can be used in overview.
- *
- * @return Default to {@code true}.
- */
- @Override
- public boolean inOverview() {
- return true;
- }
-
- /**
- * Returns {@code true} since SIS taglets can be used in package documentation.
- *
- * @return Default to {@code true}.
- */
- @Override
- public boolean inPackage() {
- return true;
- }
-
- /**
- * Returns {@code true} since SIS taglets can be used in type documentation
- * (classes or interfaces).
+ * Returns the set of locations in which this taglet may be used.
+ * By default the taglet can be used everywhere.
*
- * @return Default to {@code true}.
+ * @return the set of locations in which this taglet may be used.
*/
@Override
- public boolean inType() {
- return true;
+ public Set<Taglet.Location> getAllowedLocations() {
+ return EnumSet.allOf(Taglet.Location.class);
}
/**
- * Returns {@code true} since SIS taglets can be used in constructor
+ * Returns {@code true} since this base class is all about inline tags.
*
- * @return Default to {@code true}.
+ * @return always {@code true}.
*/
@Override
- public boolean inConstructor() {
+ public final boolean isInlineTag() {
return true;
}
/**
- * Returns {@code true} since SIS taglets can be used in method documentation.
- *
- * @return Default to {@code true}.
+ * Returns the text contained in the given inline tag.
*/
- @Override
- public boolean inMethod() {
- return true;
- }
-
- /**
- * Returns {@code true} since SIS taglets can be used in field documentation.
- *
- * @return Default to {@code true}.
- */
- @Override
- public boolean inField() {
- return true;
+ static String text(final DocTree tag) {
+ for (final DocTree node : ((UnknownInlineTagTree) tag).getContent()) {
+ if (node.getKind() == DocTree.Kind.TEXT) {
+ return ((TextTree) node).getBody().trim();
+ }
+ }
+ return "";
}
/**
- * Returns {@code true} since this base class is all about inline tags.
- *
- * @return Always {@code true}.
+ * Returns the file that contains the given tag.
*/
- @Override
- public final boolean isInlineTag() {
- return true;
+ static File file(final DocTree tag) {
+ throw new UnsupportedOperationException("We have not yet found how to get the file where a tag is contained."); // TODO
}
/**
- * 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.
+ * Given a list of {@code DocTree}s representing this custom tag, returns its string representation.
*
- * @param tags The tags to format.
- * @return A string representation of the given tags.
+ * @param tags the tags to format.
+ * @return a string representation of the given tags.
*/
@Override
- public final String toString(final Tag[] tags) {
+ public final String toString(final List<? extends DocTree> tags) {
final StringBuilder buffer = new StringBuilder(64);
- for (int i=0; i<tags.length; i++) {
- buffer.append(toString(tags[i]));
+ for (final DocTree tag : tags) {
+ buffer.append(toString(tag));
}
return buffer.toString();
}
@@ -145,10 +107,10 @@ abstract class InlineTaglet implements T
/**
* Prints a warning message.
*/
- static void printWarning(final SourcePosition position, final String message) {
- final RootDoc root = getRootDoc();
- if (root != null) {
- root.printWarning(position, message);
+ static void printWarning(final DocTree tag, final String message) {
+ final Reporter reporter = InlineTaglet.reporter;
+ if (reporter != null) {
+ reporter.print(Diagnostic.Kind.WARNING, message);
} else {
System.err.println(message);
}
@@ -157,10 +119,10 @@ abstract class InlineTaglet implements T
/**
* Prints an error message.
*/
- static void printError(final SourcePosition position, final String message) {
- final RootDoc root = getRootDoc();
- if (root != null) {
- root.printError(position, message);
+ static void printError(final DocTree tag, final String message) {
+ final Reporter reporter = InlineTaglet.reporter;
+ if (reporter != null) {
+ reporter.print(Diagnostic.Kind.ERROR, message);
} else {
System.err.println(message);
}
Modified: sis/branches/JDK9/core/sis-build-helper/src/main/java/org/apache/sis/internal/taglet/Module.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK9/core/sis-build-helper/src/main/java/org/apache/sis/internal/taglet/Module.java?rev=1773593&r1=1773592&r2=1773593&view=diff
==============================================================================
--- sis/branches/JDK9/core/sis-build-helper/src/main/java/org/apache/sis/internal/taglet/Module.java [UTF-8] (original)
+++ sis/branches/JDK9/core/sis-build-helper/src/main/java/org/apache/sis/internal/taglet/Module.java [UTF-8] Sun Dec 11 17:56:17 2016
@@ -17,9 +17,12 @@
package org.apache.sis.internal.taglet;
import java.io.File;
-import java.util.Map;
-import com.sun.javadoc.Tag;
-import com.sun.tools.doclets.Taglet;
+import java.util.List;
+import java.util.Set;
+import java.util.EnumSet;
+import java.util.Collections;
+import jdk.javadoc.doclet.taglet.Taglet;
+import com.sun.source.doctree.DocTree;
/**
@@ -27,36 +30,26 @@ import com.sun.tools.doclets.Taglet;
*
* @author Martin Desruisseaux (IRD, Geomatys)
* @since 0.3
- * @version 0.4
+ * @version 0.8
* @module
*/
public final class Module implements Taglet {
/**
- * 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 SIS module in which the <code>@module</code> taglet has been found.
*/
private String module;
/**
- * Constructs a default <code>@module</code> taglet.
+ * Constructs a <code>@module</code> taglet.
*/
- private Module() {
+ public Module() {
super();
}
/**
* Returns the name of this custom tag.
*
- * @return The tag name.
+ * @return "module".
*/
@Override
public String getName() {
@@ -64,70 +57,20 @@ public final class Module implements Tag
}
/**
- * 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.
+ * Returns the set of locations in which this taglet may be used.
*
- * @return Always {@code true}.
+ * @return the set of locations in which this taglet may be used.
*/
@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;
+ public Set<Taglet.Location> getAllowedLocations() {
+ return EnumSet.of(Taglet.Location.PACKAGE,
+ Taglet.Location.TYPE);
}
/**
* Returns {@code false} since <code>@module</code> is not an inline tag.
*
- * @return Always {@code false}.
+ * @return always {@code false}.
*/
@Override
public boolean isInlineTag() {
@@ -135,33 +78,32 @@ public final class Module implements Tag
}
/**
- * Given the <code>Tag</code> representation of this custom tag, return its string representation.
- * The default implementation invokes the array variant of this method.
+ * Given the <code>DocTree</code> representation of this custom tag, return its string representation.
+ * The default implementation invokes the list variant of this method.
*
- * @param tag The tag to format.
- * @return A string representation of the given tag.
+ * @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});
+ public String toString(final DocTree tag) {
+ return toString(Collections.singletonList(tag));
}
/**
- * Given an array of {@code Tag}s representing this custom tag, return its string
- * representation.
+ * Given a list of {@code DocTree}s representing this custom tag, returns its string representation.
*
- * @param tags The tags to format.
- * @return A string representation of the given tags.
+ * @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) {
+ public String toString(final List<? extends DocTree> tags) {
+ if (tags == null || tags.isEmpty()) {
return "";
}
final StringBuilder buffer = new StringBuilder(128);
buffer.append("\n<p><font size=\"-1\">");
- for (final Tag tag : tags) {
- File file = tag.position().file();
+ for (final DocTree tag : tags) {
+ File file = InlineTaglet.file(tag);
module = file.getName();
while ((file = file.getParentFile()) != null) {
if (file.getName().equals("src")) {
Modified: sis/branches/JDK9/core/sis-build-helper/src/main/java/org/apache/sis/internal/taglet/Preformat.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK9/core/sis-build-helper/src/main/java/org/apache/sis/internal/taglet/Preformat.java?rev=1773593&r1=1773592&r2=1773593&view=diff
==============================================================================
--- sis/branches/JDK9/core/sis-build-helper/src/main/java/org/apache/sis/internal/taglet/Preformat.java [UTF-8] (original)
+++ sis/branches/JDK9/core/sis-build-helper/src/main/java/org/apache/sis/internal/taglet/Preformat.java [UTF-8] Sun Dec 11 17:56:17 2016
@@ -16,10 +16,8 @@
*/
package org.apache.sis.internal.taglet;
-import java.util.Map;
import java.util.StringTokenizer;
-import com.sun.javadoc.Tag;
-import com.sun.tools.doclets.Taglet;
+import com.sun.source.doctree.DocTree;
import org.apache.sis.internal.book.CodeColorizer;
@@ -31,11 +29,11 @@ import org.apache.sis.internal.book.Code
*
* <p>This taglet will automatically replace {@code &}, {@code <} and {@code >} by their HTML entities.
* The only exception is {@code @}, which is converted to the original {@code @} character because
- * we can't use that character directly inside this taglet.</p>
+ * we can not use that character directly inside this taglet.</p>
*
* @author Martin Desruisseaux (Geomatys)
* @since 0.3
- * @version 0.3
+ * @version 0.8
* @module
*/
public final class Preformat extends InlineTaglet {
@@ -59,26 +57,16 @@ public final class Preformat extends Inl
};
/**
- * 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.
+ * Constructs a <code>@preformat</code> taglet.
*/
- private Preformat() {
+ public Preformat() {
super();
}
/**
* Returns the name of this custom tag.
*
- * @return The tag name.
+ * @return "preformat".
*/
@Override
public String getName() {
@@ -86,24 +74,14 @@ public final class Preformat extends Inl
}
/**
- * Returns {@code false} since <code>@preformat</code> can not be used in overview.
- *
- * @return Always {@code false}.
- */
- @Override
- public boolean inOverview() {
- return false;
- }
-
- /**
- * Given the <code>Tag</code> representation of this custom tag, return its string representation.
+ * Given the <code>DocTree</code> representation of this custom tag, return its string representation.
*
- * @param tag The tag to format.
- * @return A string representation of the given tag.
+ * @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');
+ public String toString(final DocTree tag) {
+ String text = text(tag).replace("\r\n", "\n").replace('\r', '\n');
String format = "<unspecified>";
/*
* Extracts the first word, which is expected to be the format name.
@@ -119,7 +97,7 @@ public final class Preformat extends Inl
try {
style = Style.valueOf(format);
} catch (IllegalArgumentException e) {
- printWarning(tag.position(), "Unknown format: " + format);
+ printWarning(tag, "Unknown format: " + format);
style = Style.text;
}
/*
Modified: sis/branches/JDK9/core/sis-build-helper/src/main/java/org/apache/sis/internal/taglet/package-info.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK9/core/sis-build-helper/src/main/java/org/apache/sis/internal/taglet/package-info.java?rev=1773593&r1=1773592&r2=1773593&view=diff
==============================================================================
--- sis/branches/JDK9/core/sis-build-helper/src/main/java/org/apache/sis/internal/taglet/package-info.java [UTF-8] (original)
+++ sis/branches/JDK9/core/sis-build-helper/src/main/java/org/apache/sis/internal/taglet/package-info.java [UTF-8] Sun Dec 11 17:56:17 2016
@@ -21,7 +21,7 @@
*
* @author Martin Desruisseaux (IRD, Geomatys)
* @since 0.3
- * @version 0.3
+ * @version 0.8
* @module
*/
package org.apache.sis.internal.taglet;