8303349: Simplify link format for generic types in index pages
Reviewed-by: jjg
This commit is contained in:
parent
b1d89f3066
commit
75d630621c
src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html
AllClassesIndexWriter.javaConstantsSummaryWriterImpl.javaHtmlLinkFactory.javaHtmlLinkInfo.javaIndexWriter.java
test/langtools/jdk/javadoc/doclet/testInterface
2
src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AllClassesIndexWriter.java
2
src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AllClassesIndexWriter.java
@ -149,7 +149,7 @@ public class AllClassesIndexWriter extends HtmlDocletWriter {
|
||||
protected void addTableRow(Table<TypeElement> table, TypeElement klass) {
|
||||
List<Content> rowContents = new ArrayList<>();
|
||||
Content classLink = getLink(new HtmlLinkInfo(
|
||||
configuration, HtmlLinkInfo.Kind.LINK_TYPE_PARAMS_AND_BOUNDS, klass));
|
||||
configuration, HtmlLinkInfo.Kind.SHOW_TYPE_PARAMS_IN_LABEL, klass));
|
||||
ContentBuilder description = new ContentBuilder();
|
||||
Set<ElementFlag> flags = utils.elementFlags(klass);
|
||||
if (flags.contains(ElementFlag.PREVIEW)) {
|
||||
|
@ -171,7 +171,7 @@ public class ConstantsSummaryWriterImpl extends HtmlDocletWriter implements Cons
|
||||
//generate links backward only to public classes.
|
||||
Content classLink = (utils.isPublic(typeElement) || utils.isProtected(typeElement)) ?
|
||||
getLink(new HtmlLinkInfo(configuration,
|
||||
HtmlLinkInfo.Kind.LINK_TYPE_PARAMS_AND_BOUNDS, typeElement)) :
|
||||
HtmlLinkInfo.Kind.SHOW_TYPE_PARAMS_IN_LABEL, typeElement)) :
|
||||
Text.of(utils.getFullyQualifiedName(typeElement));
|
||||
|
||||
PackageElement enclosingPackage = utils.containingPackage(typeElement);
|
||||
|
@ -83,6 +83,11 @@ public class HtmlLinkFactory extends LinkFactory {
|
||||
title = getClassToolTip(typeElement, isTypeLink);
|
||||
}
|
||||
Content label = classLinkInfo.getClassLinkLabel(configuration);
|
||||
if (classLinkInfo.context == HtmlLinkInfo.Kind.SHOW_TYPE_PARAMS_IN_LABEL) {
|
||||
// For this kind of link, type parameters are included in the link label
|
||||
// (and obviously not added after the link).
|
||||
label.add(getTypeParameterLinks(classLinkInfo));
|
||||
}
|
||||
Set<ElementFlag> flags;
|
||||
Element previewTarget;
|
||||
boolean showPreview = !classLinkInfo.skipPreview;
|
||||
|
@ -43,6 +43,9 @@ import jdk.javadoc.internal.doclets.toolkit.util.links.LinkInfo;
|
||||
*/
|
||||
public class HtmlLinkInfo extends LinkInfo {
|
||||
|
||||
/**
|
||||
* Enumeration of different kinds of links.
|
||||
*/
|
||||
public enum Kind {
|
||||
/**
|
||||
* Link with just the element name as label.
|
||||
@ -53,19 +56,25 @@ public class HtmlLinkInfo extends LinkInfo {
|
||||
*/
|
||||
SHOW_PREVIEW,
|
||||
/**
|
||||
* Link with additional type parameters as plain text if appropriate.
|
||||
* Link with optional type parameters appended as plain text.
|
||||
*/
|
||||
SHOW_TYPE_PARAMS,
|
||||
|
||||
/**
|
||||
* Link with additional type parameters and bounds as plain text if appropriate.
|
||||
* Link with optional type parameters included in the link label.
|
||||
*/
|
||||
SHOW_TYPE_PARAMS_IN_LABEL,
|
||||
|
||||
/**
|
||||
* Link with optional type parameters and bounds appended as plain text.
|
||||
*/
|
||||
SHOW_TYPE_PARAMS_AND_BOUNDS,
|
||||
/**
|
||||
* Link with additional type parameters as separate link if appropriate.
|
||||
* Link with optional type parameters but no bounds rendered as separate links.
|
||||
*/
|
||||
LINK_TYPE_PARAMS,
|
||||
/**
|
||||
* Link with additional type parameters and bounds as separate links if approprate.
|
||||
* Link with optional type parameters and bounds rendered as separate links.
|
||||
*/
|
||||
LINK_TYPE_PARAMS_AND_BOUNDS;
|
||||
}
|
||||
@ -228,7 +237,10 @@ public class HtmlLinkInfo extends LinkInfo {
|
||||
|
||||
@Override
|
||||
public boolean showTypeParameters() {
|
||||
return context != Kind.PLAIN && context != Kind.SHOW_PREVIEW;
|
||||
// Type parameters for these kinds of links are either not desired
|
||||
// or already included in the link label.
|
||||
return context != Kind.PLAIN && context != Kind.SHOW_PREVIEW
|
||||
&& context != Kind.SHOW_TYPE_PARAMS_IN_LABEL;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -209,7 +209,7 @@ public class IndexWriter extends HtmlDocletWriter {
|
||||
case ANNOTATION_TYPE:
|
||||
case INTERFACE:
|
||||
dt = HtmlTree.DT(getLink(new HtmlLinkInfo(configuration,
|
||||
HtmlLinkInfo.Kind.LINK_TYPE_PARAMS_AND_BOUNDS, (TypeElement) element).style(HtmlStyle.typeNameLink)));
|
||||
HtmlLinkInfo.Kind.SHOW_TYPE_PARAMS_IN_LABEL, (TypeElement) element).style(HtmlStyle.typeNameLink)));
|
||||
dt.add(" - ");
|
||||
addClassInfo((TypeElement) element, dt);
|
||||
break;
|
||||
|
@ -24,7 +24,7 @@
|
||||
/*
|
||||
* @test
|
||||
* @bug 4682448 4947464 5029946 8025633 8026567 8035473 8139101 8175200
|
||||
8186332 8186703 8182765 8187288 8261976
|
||||
8186332 8186703 8182765 8187288 8261976 8303349
|
||||
* @summary Verify that the public modifier does not show up in the
|
||||
* documentation for public methods, as recommended by the JLS.
|
||||
* If A implements I and B extends A, B should be in the list of
|
||||
@ -217,7 +217,8 @@ public class TestInterface extends JavadocTester {
|
||||
<div class="table-header col-last">Description</div>
|
||||
<div class="col-first even-row-color"><code>static interface </code></div>
|
||||
<div class="col-second even-row-color"><code><a href="Spliterator.OfDouble.html"\
|
||||
class="type-name-link" title="interface in pkg2">Spliterator.OfDouble</a></code></div>
|
||||
class="type-name-link" title="interface in pkg2">Spliterator.OfDouble</a></code\
|
||||
></div>
|
||||
<div class="col-last even-row-color"> </div>
|
||||
<div class="col-first odd-row-color"><code>static interface </code></div>
|
||||
<div class="col-second odd-row-color"><code><a href="Spliterator.OfInt.html" cla\
|
||||
@ -247,58 +248,42 @@ public class TestInterface extends JavadocTester {
|
||||
<div class="col-last even-row-color all-classes-table all-classes-table-tab2">&n\
|
||||
bsp;</div>
|
||||
<div class="col-first odd-row-color all-classes-table all-classes-table-tab1"><a\
|
||||
href="pkg2/Spliterator.html" title="interface in pkg2">Spliterator</a><<a hr\
|
||||
ef="pkg2/Spliterator.html" title="type parameter in Spliterator">T</a>></div>
|
||||
<div class="col-last odd-row-color all-classes-table all-classes-table-tab1"> </div>
|
||||
href="pkg2/Spliterator.html" title="interface in pkg2">Spliterator<T></a>\
|
||||
</div>
|
||||
<div class="col-last odd-row-color all-classes-table all-classes-table-tab1">&nb\
|
||||
sp;</div>
|
||||
<div class="col-first even-row-color all-classes-table all-classes-table-tab1"><\
|
||||
a href="pkg2/Spliterator.OfDouble.html" title="interface in pkg2">Spliterator.Of\
|
||||
Double</a></div>
|
||||
<div class="col-last even-row-color all-classes-table all-classes-table-tab1"> </div>
|
||||
<div class="col-last even-row-color all-classes-table all-classes-table-tab1">&n\
|
||||
bsp;</div>
|
||||
<div class="col-first odd-row-color all-classes-table all-classes-table-tab1"><a\
|
||||
href="pkg2/Spliterator.OfInt.html" title="interface in pkg2">Spliterator.OfInt<\
|
||||
/a><<a href="pkg2/Spliterator.OfInt.html" title="type parameter in Spliterato\
|
||||
r.OfInt">Integer</a>></div>
|
||||
<div class="col-last odd-row-color all-classes-table all-classes-table-tab1"> </div>
|
||||
href="pkg2/Spliterator.OfInt.html" title="interface in pkg2">Spliterator.OfInt&\
|
||||
lt;Integer></a></div>
|
||||
<div class="col-last odd-row-color all-classes-table all-classes-table-tab1">&nb\
|
||||
sp;</div>
|
||||
<div class="col-first even-row-color all-classes-table all-classes-table-tab1"><\
|
||||
a href="pkg2/Spliterator.OfPrimitive.html" title="interface in pkg2">Spliterator\
|
||||
.OfPrimitive</a><<a href="pkg2/Spliterator.OfPrimitive.html" title="type para\
|
||||
meter in Spliterator.OfPrimitive">T</a>,<wbr><a href="pkg2/Spliterator.OfPrimiti\
|
||||
ve.html" title="type parameter in Spliterator.OfPrimitive">T_CONS</a>,<wbr><a hr\
|
||||
ef="pkg2/Spliterator.OfPrimitive.html" title="type parameter in Spliterator.OfPr\
|
||||
imitive">T_SPLITR</a> extends <a href="pkg2/Spliterator.OfPrimitive.html" title=\
|
||||
"interface in pkg2">Spliterator.OfPrimitive</a><<a href="pkg2/Spliterator.OfP\
|
||||
rimitive.html" title="type parameter in Spliterator.OfPrimitive">T</a>,<wbr><a h\
|
||||
ref="pkg2/Spliterator.OfPrimitive.html" title="type parameter in Spliterator.OfP\
|
||||
rimitive">T_CONS</a>,<wbr><a href="pkg2/Spliterator.OfPrimitive.html" title="typ\
|
||||
e parameter in Spliterator.OfPrimitive">T_SPLITR</a>>></div>
|
||||
<div class="col-last even-row-color all-classes-table all-classes-table-tab1"> </div>""");
|
||||
.OfPrimitive<T,<wbr>T_CONS,<wbr>T_SPLITR></a></div>
|
||||
<div class="col-last even-row-color all-classes-table all-classes-table-tab1">&n\
|
||||
bsp;</div>""");
|
||||
checkOutput("index-all.html", true,
|
||||
"""
|
||||
<dt><a href="pkg2/Spliterator.html" class="type-name-link" title="interface in p\
|
||||
kg2">Spliterator</a><<a href="pkg2/Spliterator.html" title="type parameter in\
|
||||
Spliterator">T</a>> - Interface in <a href="pkg2/package-summary.html">pkg2</a></dt>
|
||||
kg2">Spliterator<T></a> - Interface in <a href="pkg2/package-summary.html"\
|
||||
>pkg2</a></dt>
|
||||
<dd> </dd>
|
||||
<dt><a href="pkg2/Spliterator.OfDouble.html" class="type-name-link" title="inter\
|
||||
face in pkg2">Spliterator.OfDouble</a> - Interface in <a href="pkg2/package-summ\
|
||||
ary.html">pkg2</a></dt>
|
||||
<dd> </dd>
|
||||
<dt><a href="pkg2/Spliterator.OfInt.html" class="type-name-link" title="interfac\
|
||||
e in pkg2">Spliterator.OfInt</a><<a href="pkg2/Spliterator.OfInt.html" title=\
|
||||
"type parameter in Spliterator.OfInt">Integer</a>> - Interface in <a href="pk\
|
||||
g2/package-summary.html">pkg2</a></dt>
|
||||
e in pkg2">Spliterator.OfInt<Integer></a> - Interface in <a href="pkg2/pac\
|
||||
kage-summary.html">pkg2</a></dt>
|
||||
<dd> </dd>
|
||||
<dt><a href="pkg2/Spliterator.OfPrimitive.html" class="type-name-link" title="in\
|
||||
terface in pkg2">Spliterator.OfPrimitive</a><<a href="pkg2/Spliterator.OfPrim\
|
||||
itive.html" title="type parameter in Spliterator.OfPrimitive">T</a>,<wbr><a href\
|
||||
="pkg2/Spliterator.OfPrimitive.html" title="type parameter in Spliterator.OfPrim\
|
||||
itive">T_CONS</a>,<wbr><a href="pkg2/Spliterator.OfPrimitive.html" title="type p\
|
||||
arameter in Spliterator.OfPrimitive">T_SPLITR</a> extends <a href="pkg2/Splitera\
|
||||
tor.OfPrimitive.html" title="interface in pkg2">Spliterator.OfPrimitive</a><<\
|
||||
a href="pkg2/Spliterator.OfPrimitive.html" title="type parameter in Spliterator.\
|
||||
OfPrimitive">T</a>,<wbr><a href="pkg2/Spliterator.OfPrimitive.html" title="type \
|
||||
parameter in Spliterator.OfPrimitive">T_CONS</a>,<wbr><a href="pkg2/Spliterator.\
|
||||
OfPrimitive.html" title="type parameter in Spliterator.OfPrimitive">T_SPLITR</a>\
|
||||
>> - Interface in <a href="pkg2/package-summary.html">pkg2</a></dt>
|
||||
terface in pkg2">Spliterator.OfPrimitive<T,<wbr>T_CONS,<wbr>T_SPLITR></a> \
|
||||
- Interface in <a href="pkg2/package-summary.html">pkg2</a></dt>
|
||||
<dd> </dd>""");
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user