< prev index next >
make/src/classes/build/tools/taglet/ExtLink.java
Print this page
*** 35,55 ****
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
* <p>
* {@code Please see {@extLink Borealis a spectacular} sight.}
! * <p>
! * will produce the following html
! * <p>
* {@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 {
--- 35,61 ----
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.*;
/**
* An inline tag to conveniently insert an external link.
* The tag can be used as follows:
! * {@extLink name description}.
* <p>
+ * Using the tag as follows:
+ * <br>
* {@code Please see {@extLink Borealis a spectacular} sight.}
! * <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,67 ****
--- 64,75 ----
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,109 ****
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)
.append(m.group("name"))
.append("\">")
.append(m.group("desc"))
.append("</a>");
!
return sb.toString();
}
}
--- 103,123 ----
String tagText = uitree.getContent().get(0).toString();
Matcher m = TAG_PATTERN.matcher(tagText);
if (!m.find())
return "";
! 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 >