mirror of
https://github.com/openjdk/jdk.git
synced 2026-02-19 23:05:28 +00:00
8012174: {@literal} and {@code} should use \"new\" Taglet, not old
Reviewed-by: darcy
This commit is contained in:
parent
0ac80e7f93
commit
fc641c0bd6
@ -26,6 +26,10 @@
|
||||
package com.sun.tools.doclets.formats.html;
|
||||
|
||||
import com.sun.javadoc.*;
|
||||
import com.sun.tools.doclets.formats.html.markup.HtmlAttr;
|
||||
import com.sun.tools.doclets.formats.html.markup.HtmlTag;
|
||||
import com.sun.tools.doclets.formats.html.markup.HtmlTree;
|
||||
import com.sun.tools.doclets.formats.html.markup.StringContent;
|
||||
import com.sun.tools.doclets.internal.toolkit.*;
|
||||
import com.sun.tools.doclets.internal.toolkit.builders.SerializedFormBuilder;
|
||||
import com.sun.tools.doclets.internal.toolkit.taglets.*;
|
||||
@ -62,6 +66,14 @@ public class TagletWriterImpl extends TagletWriter {
|
||||
return new TagletOutputImpl("");
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
protected TagletOutput codeTagOutput(Tag tag) {
|
||||
Content result = HtmlTree.CODE(new StringContent(tag.text()));
|
||||
return new TagletOutputImpl(result.toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@ -118,6 +130,23 @@ public class TagletWriterImpl extends TagletWriter {
|
||||
return new TagletOutputImpl(output.toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
protected TagletOutput expertTagOutput(Tag tag) {
|
||||
HtmlTree result = new HtmlTree(HtmlTag.SUB, new StringContent(tag.text()));
|
||||
result.addAttr(HtmlAttr.ID, "expert");
|
||||
return new TagletOutputImpl(result.toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
protected TagletOutput literalTagOutput(Tag tag) {
|
||||
Content result = new StringContent(tag.text());
|
||||
return new TagletOutputImpl(result.toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2010, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -75,6 +75,7 @@ public enum HtmlTag {
|
||||
SMALL(BlockType.INLINE, EndTag.END),
|
||||
SPAN(BlockType.INLINE, EndTag.END),
|
||||
STRONG(BlockType.INLINE, EndTag.END),
|
||||
SUB(BlockType.INLINE, EndTag.END),
|
||||
TABLE,
|
||||
TBODY,
|
||||
TD,
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -26,7 +26,6 @@ package com.sun.tools.doclets.internal.toolkit.taglets;
|
||||
|
||||
import java.util.Map;
|
||||
import com.sun.javadoc.Tag;
|
||||
import com.sun.tools.doclets.Taglet;
|
||||
|
||||
/**
|
||||
* An inline Taglet used to denote literal code fragments.
|
||||
@ -49,23 +48,23 @@ import com.sun.tools.doclets.Taglet;
|
||||
* @since 1.5
|
||||
*/
|
||||
|
||||
public class CodeTaglet extends LiteralTaglet {
|
||||
public class CodeTaglet extends BaseInlineTaglet {
|
||||
|
||||
private static final String NAME = "code";
|
||||
private static final String NAME = "code";
|
||||
|
||||
public static void register(Map<String, Taglet> map) {
|
||||
map.remove(NAME);
|
||||
map.put(NAME, new CodeTaglet());
|
||||
}
|
||||
public static void register(Map<String, Taglet> map) {
|
||||
map.remove(NAME);
|
||||
map.put(NAME, new CodeTaglet());
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return NAME;
|
||||
}
|
||||
public String getName() {
|
||||
return NAME;
|
||||
}
|
||||
|
||||
/*
|
||||
* Wraps @literal's result in a <code> element.
|
||||
*/
|
||||
public String toString(Tag tag) {
|
||||
return "<code>" + super.toString(tag) + "</code>";
|
||||
}
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public TagletOutput getTagletOutput(Tag tag, TagletWriter writer) {
|
||||
return writer.codeTagOutput(tag);
|
||||
}
|
||||
}
|
||||
|
||||
@ -27,7 +27,6 @@ package com.sun.tools.doclets.internal.toolkit.taglets;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import com.sun.tools.doclets.Taglet;
|
||||
import com.sun.javadoc.Tag;
|
||||
|
||||
/**
|
||||
@ -39,11 +38,9 @@ import com.sun.javadoc.Tag;
|
||||
* deletion without notice.</b>
|
||||
*
|
||||
*/
|
||||
public class ExpertTaglet implements Taglet {
|
||||
public class ExpertTaglet extends BaseTaglet {
|
||||
|
||||
private static final String NAME = "expert";
|
||||
private static final String START_TAG = "<sub id=\"expert\">";
|
||||
private static final String END_TAG = "</sub>";
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
@ -85,22 +82,10 @@ public class ExpertTaglet implements Taglet {
|
||||
map.put(NAME, new ExpertTaglet());
|
||||
}
|
||||
|
||||
public String toString(Tag tag) {
|
||||
return (tag.text() == null || tag.text().length() == 0) ? null :
|
||||
START_TAG + LiteralTaglet.textToString(tag.text()) + END_TAG;
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public TagletOutput getTagletOutput(Tag tag, TagletWriter writer) {
|
||||
return writer.expertTagOutput(tag);
|
||||
}
|
||||
|
||||
|
||||
public String toString(Tag[] tags) {
|
||||
if (tags == null || tags.length == 0) return null;
|
||||
|
||||
StringBuffer sb = new StringBuffer(START_TAG);
|
||||
|
||||
for(Tag t:tags) {
|
||||
sb.append(LiteralTaglet.textToString(t.text()));
|
||||
}
|
||||
sb.append(END_TAG);
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -25,8 +25,9 @@
|
||||
package com.sun.tools.doclets.internal.toolkit.taglets;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import com.sun.javadoc.Doc;
|
||||
import com.sun.javadoc.Tag;
|
||||
import com.sun.tools.doclets.Taglet;
|
||||
|
||||
|
||||
/**
|
||||
@ -47,60 +48,23 @@ import com.sun.tools.doclets.Taglet;
|
||||
* @since 1.5
|
||||
*/
|
||||
|
||||
public class LiteralTaglet implements Taglet {
|
||||
public class LiteralTaglet extends BaseInlineTaglet {
|
||||
|
||||
private static final String NAME = "literal";
|
||||
|
||||
public static void register(Map<String,Taglet> map) {
|
||||
map.remove(NAME);
|
||||
map.put(NAME, new LiteralTaglet());
|
||||
public static void register(Map<String, Taglet> map) {
|
||||
map.remove(NAME);
|
||||
map.put(NAME, new LiteralTaglet());
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return NAME;
|
||||
}
|
||||
|
||||
public String toString(Tag tag) {
|
||||
return textToString(tag.text());
|
||||
}
|
||||
|
||||
public String toString(Tag[] tags) { return null; }
|
||||
|
||||
public boolean inField() { return false; }
|
||||
|
||||
public boolean inConstructor() { return false; }
|
||||
|
||||
public boolean inMethod() { return false; }
|
||||
|
||||
public boolean inOverview() { return false; }
|
||||
|
||||
public boolean inPackage() { return false; }
|
||||
|
||||
public boolean inType() { return false; }
|
||||
|
||||
public boolean isInlineTag() { return true; }
|
||||
|
||||
/*
|
||||
* Replace occurrences of the following characters: < > &
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
protected static String textToString(String text) {
|
||||
StringBuilder buf = new StringBuilder();
|
||||
for (int i = 0; i < text.length(); i++) {
|
||||
char c = text.charAt(i);
|
||||
switch (c) {
|
||||
case '<':
|
||||
buf.append("<");
|
||||
break;
|
||||
case '>':
|
||||
buf.append(">");
|
||||
break;
|
||||
case '&':
|
||||
buf.append("&");
|
||||
break;
|
||||
default:
|
||||
buf.append(c);
|
||||
}
|
||||
}
|
||||
return buf.toString();
|
||||
public TagletOutput getTagletOutput(Tag tag, TagletWriter writer) {
|
||||
return writer.literalTagOutput(tag);
|
||||
}
|
||||
}
|
||||
|
||||
@ -659,10 +659,8 @@ public class TagletManager {
|
||||
customTags.put((temp = new DocRootTaglet()).getName(), temp);
|
||||
customTags.put((temp = new InheritDocTaglet()).getName(), temp);
|
||||
customTags.put((temp = new ValueTaglet()).getName(), temp);
|
||||
customTags.put((temp = new LegacyTaglet(new LiteralTaglet())).getName(),
|
||||
temp);
|
||||
customTags.put((temp = new LegacyTaglet(new CodeTaglet())).getName(),
|
||||
temp);
|
||||
customTags.put((temp = new LiteralTaglet()).getName(), temp);
|
||||
customTags.put((temp = new CodeTaglet()).getName(), temp);
|
||||
|
||||
//Keep track of the names of standard tags for error
|
||||
//checking purposes.
|
||||
@ -705,7 +703,7 @@ public class TagletManager {
|
||||
SimpleTaglet.FIELD + SimpleTaglet.METHOD)).getName(), temp);
|
||||
customTags.put((temp = new SimpleTaglet("treatAsPrivate", null,
|
||||
SimpleTaglet.FIELD + SimpleTaglet.METHOD + SimpleTaglet.TYPE)).getName(), temp);
|
||||
customTags.put((temp = new LegacyTaglet(new ExpertTaglet())).getName(), temp);
|
||||
customTags.put((temp = new ExpertTaglet()).getName(), temp);
|
||||
|
||||
standardTags.add("propertyGetter");
|
||||
standardTags.add("propertySetter");
|
||||
|
||||
@ -53,10 +53,18 @@ public abstract class TagletWriter {
|
||||
}
|
||||
|
||||
/**
|
||||
* @return an instance of the output object.
|
||||
* @return an instance of an output object.
|
||||
*/
|
||||
public abstract TagletOutput getOutputInstance();
|
||||
|
||||
/**
|
||||
* Return the output for a {@code...} tag.
|
||||
*
|
||||
* @param tag the tag.
|
||||
* @return the output of the taglet.
|
||||
*/
|
||||
protected abstract TagletOutput codeTagOutput(Tag tag);
|
||||
|
||||
/**
|
||||
* Returns the output for the DocRoot inline tag.
|
||||
* @return the output for the DocRoot inline tag.
|
||||
@ -71,6 +79,23 @@ public abstract class TagletWriter {
|
||||
*/
|
||||
protected abstract TagletOutput deprecatedTagOutput(Doc doc);
|
||||
|
||||
/**
|
||||
* Return the output for a {@expert...} tag.
|
||||
*
|
||||
* @param tag the tag.
|
||||
* @return the output of the taglet.
|
||||
*/
|
||||
// TODO: remove this taglet
|
||||
protected abstract TagletOutput expertTagOutput(Tag tag);
|
||||
|
||||
/**
|
||||
* Return the output for a {@literal...} tag.
|
||||
*
|
||||
* @param tag the tag.
|
||||
* @return the output of the taglet.
|
||||
*/
|
||||
protected abstract TagletOutput literalTagOutput(Tag tag);
|
||||
|
||||
/**
|
||||
* Returns {@link MessageRetriever} for output purposes.
|
||||
*
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user