< prev index next >
make/src/classes/build/tools/taglet/ExtLink.java
Print this page
@@ -35,21 +35,27 @@
import com.sun.source.doctree.DocTree;
import com.sun.source.doctree.UnknownInlineTagTree;
import jdk.javadoc.doclet.Taglet;
import static com.sun.source.doctree.DocTree.Kind.*;
-import static jdk.javadoc.doclet.Taglet.Location.*;
/**
* An inline tag to conveniently insert an external link.
* The tag can be used as follows:
- * {@extLink name description}, for example
+ * {@extLink name description}.
* <p>
+ * Using the tag as follows:
+ * <br>
* {@code Please see {@extLink Borealis a spectacular} sight.}
- * <p>
- * will produce the following html
- * <p>
+ * <br>
+ * the taglet will produce the following html:
+ * <br><br>
+ * {@code Please see <cite>a spectacular</cite> sight.}
+ * <br><br>
+ * If the property {@code build.tools.taglet.ExtLink.LINK} is set, using
+ * the above example, the taglet will produce the following html:
+ * <br><br>
* {@code
* Please see <a href="https://www.oracle.com/pls/topic/lookup?ctx=javase9&id=Borealis">a spectacular</a> sight.
* }
*/
public class ExtLink implements Taglet {
@@ -58,10 +64,12 @@
static final String URL = "https://www.oracle.com/pls/topic/lookup?ctx=javase9&id=";
static final Pattern TAG_PATTERN = Pattern.compile("(\\s*)(?<name>\\w+)(\\s+)(?<desc>.*)");
+ static final boolean LINK = Boolean.getBoolean("build.tools.taglet.ExtLink.LINK");
+
/**
* Returns the set of locations in which the tag may be used.
*/
@Override
public Set<Location> getAllowedLocations() {
@@ -95,15 +103,21 @@
String tagText = uitree.getContent().get(0).toString();
Matcher m = TAG_PATTERN.matcher(tagText);
if (!m.find())
return "";
- StringBuilder sb = new StringBuilder("<a href=\"");
- sb.append(URL)
+ StringBuilder sb = new StringBuilder();
+ if (LINK) {
+ sb.append("<a href=\"")
+ .append(URL)
.append(m.group("name"))
.append("\">")
.append(m.group("desc"))
.append("</a>");
-
+ } else {
+ sb.append("<cite>")
+ .append(m.group("desc"))
+ .append("</cite>");
+ }
return sb.toString();
}
}
< prev index next >