ICU-10988 Support v8 JavaDoc API

X-SVN-Rev: 37866
This commit is contained in:
Scott Russell 2015-09-02 15:31:55 +00:00
parent 3b7d1aa8aa
commit f169e1d936
6 changed files with 152 additions and 32 deletions

1
.gitattributes vendored
View file

@ -504,6 +504,7 @@ icu4j/tools/build/icu4j52.api3.gz -text
icu4j/tools/build/icu4j53.api3.gz -text
icu4j/tools/build/icu4j54.api3.gz -text
icu4j/tools/build/icu4j55.api3.gz -text
icu4j/tools/build/src/com/ibm/icu/dev/tool/docs/ICUTagletAdapter.java7 -text
tools/currency/.classpath -text
tools/currency/.project -text
tools/currency/.settings/org.eclipse.core.resources.prefs -text

View file

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JDK6"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="output" path="out/bin"/>
</classpath>

View file

@ -1,7 +1,7 @@
<!--
*******************************************************************************
* Copyright (C) 2009-2011, International Business Machines Corporation and *
* others. All Rights Reserved. *
* Copyright (C) 2009-2011, 2015 International Business Machines Corporation *
* and others. All Rights Reserved. *
*******************************************************************************
-->
<project name="build-tools" default="build" basedir=".">
@ -14,18 +14,55 @@
</path>
<property name="jar.name" value="icu4j-${ant.project.name}.jar"/>
<property name="src.jar.name" value="icu4j-${ant.project.name}-src.jar"/>
<property name="icutaglet.adapter" value="./src/com/ibm/icu/dev/tool/docs/ICUTagletAdapter.java"/>
<property name="v7.icutaglet.adapter" value="${icutaglet.adapter}7"/>
<target name="build" depends="compile, copy, jar" description="Build the project"/>
<target name="info" description="Display the build environment information">
<echo message="----- Build Environment Information -------------------"/>
<echo message="Java Home: ${java.home}"/>
<echo message="Java Version: ${java.version}"/>
<echo message="Ant Home: ${ant.home}"/>
<echo message="Ant Version: ${ant.version}"/>
<echo message="OS: ${os.name}"/>
<echo message="OS Version: ${os.version}"/>
<echo message="OS Arch: ${os.arch}"/>
<echo message="Host: ${env.COMPUTERNAME}"/>
<echo message="-------------------------------------------------------"/>
</target>
<target name="build" depends="info, compile, copy, jar, adapter-notify" description="Build the project"/>
<target name="build-all" depends="@build-all" description="Build the project including all dependencies"/>
<target name="clean" depends="@clean" description="Clean up the build outputs"/>
<target name="compile" depends="@compile" description="Compile java source files"/>
<target name="compile" depends="set-javadoc-adapter, @compile" description="Compile java source files"/>
<target name="copy" depends="@copy" description="Copy non-java runtime files to the project's binary directory"/>
<target name="jar" depends="compile, copy, @jar" description="Create the project's jar file"/>
<target name="src-jar" depends="@src-jar" description="Create the project's source jar file"/>
<target name="java-version" depends="info">
<condition property="java.version.pre8">
<or>
<equals arg1="${ant.java.version}" arg2="1.5"/>
<equals arg1="${ant.java.version}" arg2="1.6"/>
<equals arg1="${ant.java.version}" arg2="1.7"/>
</or>
</condition>
</target>
<target name="set-javadoc-adapter" depends="java-version" if="java.version.pre8">
<echo message="pre v8 Java build detected...setting taglet adapter to older API adapter"/>
<copy file="${v7.icutaglet.adapter}" tofile="${icutaglet.adapter}" overwrite="true" />
</target>
<target name="adapter-notify" depends="java-version" if="java.version.pre8">
<echo message="pre v8 Java build detected and the adapter was set to the older API adapter"/>
<echo message="NOTE: revert this change once the docs are built with this older Javadoc version "/>
<echo message="file to revert is: ${icutaglet.adapter}"/>
</target>
</project>

View file

@ -1,7 +1,7 @@
/**
*******************************************************************************
* Copyright (C) 2002-2011, International Business Machines Corporation and *
* others. All Rights Reserved. *
* Copyright (C) 2002-2011, 2015 International Business Machines Corporation *
* and others. All Rights Reserved. *
*******************************************************************************
*/
@ -11,13 +11,10 @@ import java.text.BreakIterator;
import java.util.Locale;
import java.util.Map;
import com.sun.javadoc.Doc;
import com.sun.javadoc.Tag;
import com.sun.tools.doclets.internal.toolkit.taglets.Taglet;
import com.sun.tools.doclets.internal.toolkit.taglets.TagletOutput;
import com.sun.tools.doclets.internal.toolkit.taglets.TagletWriter;
import com.sun.tools.doclets.internal.toolkit.taglets.Taglet;
public abstract class ICUTaglet implements Taglet {
public abstract class ICUTaglet extends ICUTagletAdapter implements Taglet {
protected final String name;
protected final int mask;
@ -101,26 +98,6 @@ public abstract class ICUTaglet implements Taglet {
return null;
}
public TagletOutput getTagletOutput(Tag tag, TagletWriter writer)
throws IllegalArgumentException {
TagletOutput out = writer.getTagletOutputInstance();
out.setOutput(toString(tag));
return out;
}
public TagletOutput getTagletOutput(Doc holder, TagletWriter writer)
throws IllegalArgumentException {
TagletOutput out = writer.getTagletOutputInstance();
Tag[] tags = holder.tags(getName());
if (tags.length == 0) {
return null;
}
out.setOutput(toString(tags[0]));
return out;
}
protected static final String STATUS = "<dt><b>Status:</b></dt>";
public static class ICUInternalTaglet extends ICUTaglet {

View file

@ -0,0 +1,58 @@
/*
*******************************************************************************
* Copyright (C) 2015, International Business Machines Corporation and *
* others. All Rights Reserved. *
*******************************************************************************
*/
package com.ibm.icu.dev.tool.docs;
import com.sun.javadoc.Doc;
import com.sun.javadoc.Tag;
import com.sun.tools.doclets.formats.html.markup.RawHtml;
import com.sun.tools.doclets.internal.toolkit.Content;
import com.sun.tools.doclets.internal.toolkit.taglets.Taglet;
import com.sun.tools.doclets.internal.toolkit.taglets.TagletWriter;
/**
* The ICUTagletAdapter class is the abstract base class that adapts the ICUTaglet class to different implementations of the JavaDoc API.
* The methods in this class are meant to minimize the dual maintenance nature of supporting multiple JavaDoc APIs.
*
* This adapter supports the v8 JavaDoc API
*/
public abstract class ICUTagletAdapter implements Taglet {
public abstract String toString(Tag tag);
public abstract String toString(Tag[] tags);
public Content getTagletOutput(Tag tag, TagletWriter writer)
throws IllegalArgumentException {
// addContext doesn't except nulls so filter them out
String encodedText = toString(tag);
if(encodedText == null) return null;
Content out = writer.getOutputInstance();
out.addContent(new RawHtml(encodedText));
return out;
}
public Content getTagletOutput(Doc holder, TagletWriter writer)
throws IllegalArgumentException {
Content out = writer.getOutputInstance();
Tag[] tags = holder.tags(getName());
if (tags.length == 0) {
return null;
}
// addContext doesn't except nulls so filter them out
String encodedText = toString(tags[0]);
if(encodedText == null) return null;
out.addContent(new RawHtml(encodedText));
return out;
}
}

View file

@ -0,0 +1,47 @@
/*
*******************************************************************************
* Copyright (C) 2015, International Business Machines Corporation and *
* others. All Rights Reserved. *
*******************************************************************************
*/
package com.ibm.icu.dev.tool.docs;
import com.sun.javadoc.Doc;
import com.sun.javadoc.Tag;
import com.sun.tools.doclets.internal.toolkit.taglets.Taglet;
import com.sun.tools.doclets.internal.toolkit.taglets.TagletOutput;
import com.sun.tools.doclets.internal.toolkit.taglets.TagletWriter;
/**
* The ICUTagletAdapter class is the abstract base class that adapts the ICUTaglet class to different implementations of the JavaDoc API.
* The methods in this class are meant to minimize the dual maintenance nature of supporting multiple JavaDoc APIs.
*
* This adapter supports the v7 and earlier JavaDoc API
*/
public abstract class ICUTagletAdapter implements Taglet {
public abstract String toString(Tag tag);
public abstract String toString(Tag[] tags);
public TagletOutput getTagletOutput(Tag tag, TagletWriter writer)
throws IllegalArgumentException {
TagletOutput out = writer.getTagletOutputInstance();
out.setOutput(toString(tag));
return out;
}
public TagletOutput getTagletOutput(Doc holder, TagletWriter writer)
throws IllegalArgumentException {
TagletOutput out = writer.getTagletOutputInstance();
Tag[] tags = holder.tags(getName());
if (tags.length == 0) {
return null;
}
out.setOutput(toString(tags[0]));
return out;
}
}