8338133: Cleanup direct use of new HtmlTree
Reviewed-by: hannesw
This commit is contained in:
parent
b895d7cf9f
commit
98020e4799
@ -109,7 +109,7 @@ public abstract class AbstractExecutableMemberWriter extends AbstractMemberWrite
|
||||
}
|
||||
String signature = utils.flatSignature((ExecutableElement) member, typeElement);
|
||||
if (signature.length() > 2) {
|
||||
content.add(new HtmlTree(HtmlTag.WBR));
|
||||
content.add(HtmlTree.WBR());
|
||||
}
|
||||
content.add(signature);
|
||||
|
||||
@ -144,7 +144,7 @@ public abstract class AbstractExecutableMemberWriter extends AbstractMemberWrite
|
||||
// Add explicit line break between method type parameters and
|
||||
// return type in member summary table to avoid random wrapping.
|
||||
if (typeParameters.charCount() > 10) {
|
||||
target.add(new HtmlTree(HtmlTag.BR));
|
||||
target.add(HtmlTree.BR());
|
||||
} else {
|
||||
target.add(Entity.NO_BREAK_SPACE);
|
||||
}
|
||||
@ -233,7 +233,7 @@ public abstract class AbstractExecutableMemberWriter extends AbstractMemberWrite
|
||||
Content params = getParameters(member, false);
|
||||
if (params.charCount() > 2) {
|
||||
// only add <wbr> for non-empty parameters
|
||||
target.add(new HtmlTree(HtmlTag.WBR));
|
||||
target.add(HtmlTree.WBR());
|
||||
}
|
||||
target.add(params);
|
||||
}
|
||||
|
@ -451,7 +451,7 @@ public abstract class AbstractMemberWriter {
|
||||
*/
|
||||
protected void addModifiersAndType(Element member, TypeMirror type,
|
||||
Content target) {
|
||||
var code = new HtmlTree(HtmlTag.CODE);
|
||||
var code = HtmlTree.CODE();
|
||||
addModifiers(member, code);
|
||||
if (type == null) {
|
||||
code.add(switch (member.getKind()) {
|
||||
@ -670,7 +670,7 @@ public abstract class AbstractMemberWriter {
|
||||
* @return the inherited summary links
|
||||
*/
|
||||
public Content getInheritedSummaryLinks() {
|
||||
return new HtmlTree(HtmlTag.CODE);
|
||||
return HtmlTree.CODE();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -79,10 +79,9 @@ public abstract class AbstractTreeWriter extends HtmlDocletWriter {
|
||||
protected void addLevelInfo(TypeElement parent, Collection<TypeElement> collection,
|
||||
Hierarchy hierarchy, Content content) {
|
||||
if (!collection.isEmpty()) {
|
||||
var ul = new HtmlTree(HtmlTag.UL);
|
||||
var ul = HtmlTree.UL();
|
||||
for (TypeElement local : collection) {
|
||||
var li = new HtmlTree(HtmlTag.LI);
|
||||
li.setStyle(HtmlStyles.circle);
|
||||
var li = HtmlTree.LI(HtmlStyles.circle);
|
||||
addPartialInfo(local, li);
|
||||
addExtendsImplements(parent, local, li);
|
||||
addLevelInfo(local, hierarchy.subtypes(local), hierarchy, li); // Recurse
|
||||
|
@ -423,7 +423,7 @@ public class ClassUseWriter extends SubWriterHolderWriter {
|
||||
HtmlTree body = getBody(getWindowTitle(title));
|
||||
ContentBuilder headingContent = new ContentBuilder();
|
||||
headingContent.add(contents.getContent("doclet.ClassUse_Title", cltype));
|
||||
headingContent.add(new HtmlTree(HtmlTag.BR));
|
||||
headingContent.add(HtmlTree.BR());
|
||||
headingContent.add(clname);
|
||||
var heading = HtmlTree.HEADING_TITLE(Headings.PAGE_TITLE_HEADING,
|
||||
HtmlStyles.title, headingContent);
|
||||
|
@ -165,7 +165,7 @@ public class ClassWriter extends SubWriterHolderWriter {
|
||||
buildInterfaceUsageInfo(c);
|
||||
buildNestedClassInfo(c);
|
||||
buildFunctionalInterfaceInfo(c);
|
||||
c.add(new HtmlTree(HtmlTag.HR));
|
||||
c.add(HtmlTree.HR());
|
||||
var div = HtmlTree.DIV(HtmlStyles.horizontalScroll);
|
||||
buildClassSignature(div);
|
||||
buildDeprecationInfo(div);
|
||||
@ -461,7 +461,7 @@ public class ClassWriter extends SubWriterHolderWriter {
|
||||
var first = true;
|
||||
for (TypeParameterElement t : typeParams) {
|
||||
if (!first) {
|
||||
content.add(",").add(new HtmlTree(HtmlTag.WBR));
|
||||
content.add(",").add(HtmlTree.WBR());
|
||||
}
|
||||
var typeParamLink = getLink(linkInfo.forType(t.asType()));
|
||||
content.add(needsId
|
||||
@ -689,11 +689,9 @@ public class ClassWriter extends SubWriterHolderWriter {
|
||||
|
||||
protected void addFunctionalInterfaceInfo (Content target) {
|
||||
if (utils.isFunctionalInterface(typeElement)) {
|
||||
var dl = HtmlTree.DL(HtmlStyles.notes);
|
||||
dl.add(HtmlTree.DT(contents.functionalInterface));
|
||||
var dd = new HtmlTree(HtmlTag.DD);
|
||||
dd.add(contents.functionalInterfaceMessage);
|
||||
dl.add(dd);
|
||||
var dl = HtmlTree.DL(HtmlStyles.notes)
|
||||
.add(HtmlTree.DT(contents.functionalInterface))
|
||||
.add(HtmlTree.DD(contents.functionalInterfaceMessage));
|
||||
target.add(dl);
|
||||
}
|
||||
}
|
||||
|
@ -414,7 +414,7 @@ public class ConstantsSummaryWriter extends HtmlDocletWriter {
|
||||
*/
|
||||
private Content getTypeColumn(VariableElement member) {
|
||||
Content typeContent = new ContentBuilder();
|
||||
var code = new HtmlTree(HtmlTag.CODE)
|
||||
var code = HtmlTree.CODE()
|
||||
.setId(htmlIds.forMember(currentTypeElement, member));
|
||||
for (Modifier mod : member.getModifiers()) {
|
||||
code.add(Text.of(mod.toString()))
|
||||
|
@ -300,7 +300,7 @@ public class ConstructorWriter extends AbstractExecutableMemberWriter {
|
||||
@Override
|
||||
protected void addSummaryType(Element member, Content content) {
|
||||
if (threeColumnSummary()) {
|
||||
var code = new HtmlTree(HtmlTag.CODE);
|
||||
var code = HtmlTree.CODE();
|
||||
if (utils.isProtected(member)) {
|
||||
code.add("protected ");
|
||||
} else if (utils.isPrivate(member)) {
|
||||
|
@ -105,11 +105,11 @@ public class HelpWriter extends HtmlDocletWriter {
|
||||
tableOfContents.addLink(HtmlIds.TOP_OF_PAGE, mainHeading);
|
||||
tableOfContents.pushNestedList();
|
||||
content.add(HtmlTree.HEADING(Headings.PAGE_TITLE_HEADING, HtmlStyles.title, mainHeading))
|
||||
.add(new HtmlTree(HtmlTag.HR))
|
||||
.add(HtmlTree.HR())
|
||||
.add(getNavigationSection())
|
||||
.add(new HtmlTree(HtmlTag.HR))
|
||||
.add(HtmlTree.HR())
|
||||
.add(getPageKindSection())
|
||||
.add(new HtmlTree(HtmlTag.HR))
|
||||
.add(HtmlTree.HR())
|
||||
.add(HtmlTree.SPAN(HtmlStyles.helpFootnote,
|
||||
getContent("doclet.help.footnote")));
|
||||
tableOfContents.popNestedList();
|
||||
@ -255,7 +255,7 @@ public class HelpWriter extends HtmlDocletWriter {
|
||||
getContent("doclet.help.class_interface.implementations"),
|
||||
getContent("doclet.help.class_interface.declaration"),
|
||||
getContent("doclet.help.class_interface.description")))
|
||||
.add(new HtmlTree(HtmlTag.BR))
|
||||
.add(HtmlTree.BR())
|
||||
.add(newHelpSectionList(
|
||||
contents.nestedClassSummary,
|
||||
contents.enumConstantSummary,
|
||||
@ -265,7 +265,7 @@ public class HelpWriter extends HtmlDocletWriter {
|
||||
contents.methodSummary,
|
||||
contents.annotateTypeRequiredMemberSummaryLabel,
|
||||
contents.annotateTypeOptionalMemberSummaryLabel))
|
||||
.add(new HtmlTree(HtmlTag.BR))
|
||||
.add(HtmlTree.BR())
|
||||
.add(newHelpSectionList(
|
||||
contents.enumConstantDetailLabel,
|
||||
contents.fieldDetailsLabel,
|
||||
|
@ -685,7 +685,7 @@ public abstract class HtmlDocletWriter {
|
||||
return (bottom == null || bottom.isEmpty())
|
||||
? null
|
||||
: HtmlTree.FOOTER()
|
||||
.add(new HtmlTree(HtmlTag.HR))
|
||||
.add(HtmlTree.HR())
|
||||
.add(HtmlTree.P(HtmlStyles.legalCopy,
|
||||
HtmlTree.SMALL(
|
||||
RawHtml.of(replaceDocRootDir(bottom)))));
|
||||
@ -2405,7 +2405,7 @@ public abstract class HtmlDocletWriter {
|
||||
* @return an HtmlTree for the BODY tag
|
||||
*/
|
||||
public HtmlTree getBody(String title) {
|
||||
var body = new HtmlTree(HtmlTag.BODY).setStyle(getBodyStyle());
|
||||
var body = HtmlTree.BODY(getBodyStyle());
|
||||
|
||||
this.winTitle = title;
|
||||
// Don't print windowtitle script for overview-frame, allclasses-frame
|
||||
@ -2601,7 +2601,7 @@ public abstract class HtmlDocletWriter {
|
||||
});
|
||||
return contents.getContent(key,
|
||||
HtmlTree.CODE(Text.of(className)),
|
||||
new HtmlTree(HtmlTag.EM).add(featureName),
|
||||
HtmlTree.EM(featureName),
|
||||
featureCodes);
|
||||
}
|
||||
|
||||
|
@ -395,14 +395,14 @@ public class HtmlLinkFactory {
|
||||
}
|
||||
if (!vars.isEmpty()) {
|
||||
if (linkInfo.addLineBreakOpportunitiesInTypeParameters()) {
|
||||
links.add(new HtmlTree(HtmlTag.WBR));
|
||||
links.add(HtmlTree.WBR());
|
||||
}
|
||||
links.add("<");
|
||||
boolean many = false;
|
||||
for (TypeMirror t : vars) {
|
||||
if (many) {
|
||||
links.add(",");
|
||||
links.add(new HtmlTree(HtmlTag.WBR));
|
||||
links.add(HtmlTree.WBR());
|
||||
if (linkInfo.addLineBreaksInTypeParameters()) {
|
||||
links.add(Text.NL);
|
||||
}
|
||||
|
@ -92,7 +92,7 @@ public class IndexRedirectWriter extends HtmlDocletWriter {
|
||||
Script script = new Script("window.location.replace(")
|
||||
.appendStringLiteral(targetPath, '\'')
|
||||
.append(")");
|
||||
var metaRefresh = new HtmlTree(HtmlTag.META)
|
||||
var metaRefresh = HtmlTree.of(HtmlTag.META)
|
||||
.put(HtmlAttr.HTTP_EQUIV, "Refresh")
|
||||
.put(HtmlAttr.CONTENT, "0;" + targetPath);
|
||||
head.addContent(script.asContent(), HtmlTree.NOSCRIPT(metaRefresh));
|
||||
@ -103,9 +103,8 @@ public class IndexRedirectWriter extends HtmlDocletWriter {
|
||||
|
||||
bodyContent.add(HtmlTree.P(HtmlTree.A(targetPath, Text.of(targetPath))));
|
||||
|
||||
var body = new HtmlTree(HtmlTag.BODY).setStyle(HtmlStyles.indexRedirectPage);
|
||||
var main = HtmlTree.MAIN(bodyContent);
|
||||
body.add(main);
|
||||
var body = HtmlTree.BODY(HtmlStyles.indexRedirectPage)
|
||||
.add(HtmlTree.MAIN(bodyContent));
|
||||
|
||||
HtmlDocument htmlDocument = new HtmlDocument(
|
||||
HtmlTree.HTML(configuration.getLocale().getLanguage(), head, body));
|
||||
|
@ -224,7 +224,7 @@ public class IndexWriter extends HtmlDocletWriter {
|
||||
default -> throw new Error();
|
||||
}
|
||||
target.add(dt);
|
||||
var dd = new HtmlTree(HtmlTag.DD);
|
||||
var dd = HtmlTree.DD();
|
||||
if (element.getKind() == ElementKind.MODULE || element.getKind() == ElementKind.PACKAGE) {
|
||||
addSummaryComment(element, dd);
|
||||
} else {
|
||||
@ -261,7 +261,7 @@ public class IndexWriter extends HtmlDocletWriter {
|
||||
dt.add(" - ");
|
||||
dt.add(contents.getContent("doclet.Search_tag_in", item.getHolder()));
|
||||
target.add(dt);
|
||||
var dd = new HtmlTree(HtmlTag.DD);
|
||||
var dd = HtmlTree.DD();
|
||||
if (item.getDescription().isEmpty()) {
|
||||
dd.add(Entity.NO_BREAK_SPACE);
|
||||
} else {
|
||||
@ -348,7 +348,7 @@ public class IndexWriter extends HtmlDocletWriter {
|
||||
content.add(Entity.NO_BREAK_SPACE);
|
||||
}
|
||||
|
||||
content.add(new HtmlTree(HtmlTag.BR));
|
||||
content.add(HtmlTree.BR());
|
||||
var pageLinks = Stream.of(IndexItem.Category.values())
|
||||
.flatMap(c -> mainIndex.getItems(c).stream())
|
||||
.filter(i -> !(i.isElementItem() || i.isTagItem()))
|
||||
|
@ -194,7 +194,7 @@ public class ModuleWriter extends HtmlDocletWriter {
|
||||
*/
|
||||
protected void buildContent() {
|
||||
Content moduleContent = getContentHeader();
|
||||
moduleContent.add(new HtmlTree(HtmlTag.HR));
|
||||
moduleContent.add(HtmlTree.HR());
|
||||
Content div = HtmlTree.DIV(HtmlStyles.horizontalScroll);
|
||||
addModuleSignature(div);
|
||||
buildModuleDescription(div);
|
||||
@ -825,7 +825,7 @@ public class ModuleWriter extends HtmlDocletWriter {
|
||||
}
|
||||
// Only display the implementation details in the "all" mode.
|
||||
if (moduleMode == ModuleMode.ALL && !implSet.isEmpty()) {
|
||||
desc.add(new HtmlTree(HtmlTag.BR));
|
||||
desc.add(HtmlTree.BR());
|
||||
desc.add("(");
|
||||
var implSpan = HtmlTree.SPAN(HtmlStyles.implementationLabel, contents.implementation);
|
||||
desc.add(implSpan);
|
||||
|
@ -516,14 +516,14 @@ public class Navigation {
|
||||
}
|
||||
var navigationBar = HtmlTree.NAV();
|
||||
|
||||
var navContent = new HtmlTree(HtmlTag.DIV);
|
||||
var navContent = HtmlTree.DIV(HtmlStyles.navContent);
|
||||
Content skipNavLinks = contents.getContent("doclet.Skip_navigation_links");
|
||||
String toggleNavLinks = configuration.getDocResources().getText("doclet.Toggle_navigation_links");
|
||||
navigationBar.add(MarkerComments.START_OF_TOP_NAVBAR);
|
||||
// The mobile menu button uses three empty spans to produce its animated icon
|
||||
HtmlTree iconSpan = HtmlTree.SPAN(HtmlStyles.navBarToggleIcon).add(Entity.NO_BREAK_SPACE);
|
||||
navContent.setStyle(HtmlStyles.navContent).add(HtmlTree.DIV(HtmlStyles.navMenuButton,
|
||||
new HtmlTree(HtmlTag.BUTTON).setId(HtmlIds.NAVBAR_TOGGLE_BUTTON)
|
||||
navContent.add(HtmlTree.DIV(HtmlStyles.navMenuButton,
|
||||
HtmlTree.BUTTON(HtmlIds.NAVBAR_TOGGLE_BUTTON)
|
||||
.put(HtmlAttr.ARIA_CONTROLS, HtmlIds.NAVBAR_TOP.name())
|
||||
.put(HtmlAttr.ARIA_EXPANDED, String.valueOf(false))
|
||||
.put(HtmlAttr.ARIA_LABEL, toggleNavLinks)
|
||||
@ -535,9 +535,7 @@ public class Navigation {
|
||||
skipNavLinks.toString())));
|
||||
Content aboutContent = userHeader;
|
||||
|
||||
var navList = new HtmlTree(HtmlTag.UL)
|
||||
.setId(HtmlIds.NAVBAR_TOP_FIRSTROW)
|
||||
.setStyle(HtmlStyles.navList)
|
||||
var navList = HtmlTree.UL(HtmlIds.NAVBAR_TOP_FIRSTROW, HtmlStyles.navList)
|
||||
.put(HtmlAttr.TITLE, rowListTitle);
|
||||
addMainNavLinks(navList);
|
||||
navContent.add(navList);
|
||||
|
@ -204,7 +204,7 @@ public class PackageUseWriter extends SubWriterHolderWriter {
|
||||
HtmlTree body = getBody(getWindowTitle(title));
|
||||
ContentBuilder headingContent = new ContentBuilder();
|
||||
headingContent.add(contents.getContent("doclet.ClassUse_Title", packageText));
|
||||
headingContent.add(new HtmlTree(HtmlTag.BR));
|
||||
headingContent.add(HtmlTree.BR());
|
||||
headingContent.add(name);
|
||||
var heading = HtmlTree.HEADING_TITLE(Headings.PAGE_TITLE_HEADING,
|
||||
HtmlStyles.title, headingContent);
|
||||
|
@ -128,7 +128,7 @@ public class PackageWriter extends HtmlDocletWriter {
|
||||
*/
|
||||
protected void buildContent() {
|
||||
Content packageContent = getContentHeader();
|
||||
packageContent.add(new HtmlTree(HtmlTag.HR));
|
||||
packageContent.add(HtmlTree.HR());
|
||||
Content div = HtmlTree.DIV(HtmlStyles.horizontalScroll);
|
||||
addPackageSignature(div);
|
||||
buildPackageDescription(div);
|
||||
|
@ -97,24 +97,21 @@ public class SearchWriter extends HtmlDocletWriter {
|
||||
.add(HtmlTree.P(contents.getContent("doclet.search.browser_info")))
|
||||
.add(HtmlTree.SPAN(Text.of("link"))
|
||||
.setId(HtmlId.of("page-search-link")))
|
||||
.add(new HtmlTree(HtmlTag.BUTTON)
|
||||
.add(new HtmlTree(HtmlTag.IMG)
|
||||
.add(HtmlTree.BUTTON(HtmlId.of("page-search-copy"))
|
||||
.add(HtmlTree.of(HtmlTag.IMG)
|
||||
.put(HtmlAttr.SRC, pathToRoot.resolve(DocPaths.RESOURCE_FILES)
|
||||
.resolve(DocPaths.CLIPBOARD_SVG).getPath())
|
||||
.put(HtmlAttr.ALT, copyUrlText))
|
||||
.add(HtmlTree.SPAN(Text.of(copyText))
|
||||
.put(HtmlAttr.DATA_COPIED, copiedText))
|
||||
.addStyle(HtmlStyles.copy)
|
||||
.put(HtmlAttr.ARIA_LABEL, copyUrlText)
|
||||
.setId(HtmlId.of("page-search-copy")))
|
||||
.put(HtmlAttr.ARIA_LABEL, copyUrlText))
|
||||
.add(HtmlTree.P(HtmlTree.INPUT(HtmlAttr.InputType.CHECKBOX, HtmlId.of("search-redirect")))
|
||||
.add(HtmlTree.LABEL("search-redirect",
|
||||
contents.getContent("doclet.search.redirect")))))
|
||||
.add(new HtmlTree(HtmlTag.P)
|
||||
.setId(HtmlId.of("page-search-notify"))
|
||||
.add(contents.getContent("doclet.search.loading")))
|
||||
.add(HtmlTree.DIV(new HtmlTree(HtmlTag.DIV)
|
||||
.setId(HtmlId.of("result-container"))
|
||||
.add(HtmlTree.P(contents.getContent("doclet.search.loading"))
|
||||
.setId(HtmlId.of("page-search-notify")))
|
||||
.add(HtmlTree.DIV(HtmlTree.DIV(HtmlId.of("result-container"))
|
||||
.addUnchecked(Text.EMPTY))
|
||||
.setId(HtmlId.of("result-section"))
|
||||
.put(HtmlAttr.STYLE, "display: none;")
|
||||
|
@ -58,7 +58,7 @@ public class SerialFieldWriter extends FieldWriter {
|
||||
}
|
||||
|
||||
protected Content getFieldsContentHeader() {
|
||||
return new HtmlTree(HtmlTag.LI).setStyle(HtmlStyles.blockList);
|
||||
return HtmlTree.LI(HtmlStyles.blockList);
|
||||
}
|
||||
|
||||
protected Content getSerializableFields(String heading, Content source) {
|
||||
@ -76,12 +76,12 @@ public class SerialFieldWriter extends FieldWriter {
|
||||
Content nameContent = Text.of(fieldName);
|
||||
var heading = HtmlTree.HEADING(Headings.SerializedForm.MEMBER_HEADING, nameContent);
|
||||
content.add(heading);
|
||||
var pre = new HtmlTree(HtmlTag.PRE);
|
||||
Content fieldContent = writer.getLink(new HtmlLinkInfo(
|
||||
configuration, HtmlLinkInfo.Kind.LINK_TYPE_PARAMS_AND_BOUNDS, fieldType));
|
||||
pre.add(fieldContent);
|
||||
pre.add(" ");
|
||||
pre.add(fieldName);
|
||||
var pre = HtmlTree.PRE()
|
||||
.add(fieldContent)
|
||||
.add(" ")
|
||||
.add(fieldName);
|
||||
content.add(pre);
|
||||
}
|
||||
|
||||
|
@ -51,7 +51,7 @@ public class SerialMethodWriter extends MethodWriter {
|
||||
}
|
||||
|
||||
protected Content getMethodsContentHeader() {
|
||||
return new HtmlTree(HtmlTag.LI);
|
||||
return HtmlTree.LI();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -569,7 +569,7 @@ public class Signatures {
|
||||
// empty parameters are added without packing
|
||||
target.add(parameters);
|
||||
} else {
|
||||
target.add(new HtmlTree(HtmlTag.WBR))
|
||||
target.add(HtmlTree.WBR())
|
||||
.add(HtmlTree.SPAN(HtmlStyles.parameters, parameters));
|
||||
}
|
||||
|
||||
|
@ -201,7 +201,7 @@ public class SourceToHTMLConverter {
|
||||
.resolve(configuration.docPaths.forPackage(te))
|
||||
.invert();
|
||||
Content body = getHeader();
|
||||
var pre = new HtmlTree(HtmlTag.PRE);
|
||||
var pre = HtmlTree.PRE();
|
||||
try (var reader = new LineNumberReader(r)) {
|
||||
while ((line = reader.readLine()) != null) {
|
||||
addLineNo(pre, lineno);
|
||||
@ -246,7 +246,7 @@ public class SourceToHTMLConverter {
|
||||
* @return the header content for the HTML file
|
||||
*/
|
||||
private static Content getHeader() {
|
||||
return new HtmlTree(HtmlTag.BODY).setStyle(HtmlStyles.sourcePage);
|
||||
return HtmlTree.BODY(HtmlStyles.sourcePage);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -361,7 +361,7 @@ public class Table<T> extends Content {
|
||||
private Content toContent() {
|
||||
Content main;
|
||||
if (id != null) {
|
||||
main = new HtmlTree(HtmlTag.DIV).setId(id);
|
||||
main = HtmlTree.DIV(id);
|
||||
} else {
|
||||
main = new ContentBuilder();
|
||||
}
|
||||
@ -403,8 +403,7 @@ public class Table<T> extends Content {
|
||||
if (id == null) {
|
||||
throw new IllegalStateException("no id set for table");
|
||||
}
|
||||
var tabpanel = new HtmlTree(HtmlTag.DIV)
|
||||
.setId(HtmlIds.forTabPanel(id))
|
||||
var tabpanel = HtmlTree.DIV(HtmlIds.forTabPanel(id))
|
||||
.put(HtmlAttr.ROLE, "tabpanel")
|
||||
.put(HtmlAttr.ARIA_LABELLEDBY, defaultTabId.name());
|
||||
table.add(getTableBody());
|
||||
@ -416,8 +415,7 @@ public class Table<T> extends Content {
|
||||
}
|
||||
|
||||
private HtmlTree createTab(HtmlId tabId, HtmlStyle style, boolean defaultTab, Content tabLabel) {
|
||||
var tab = new HtmlTree(HtmlTag.BUTTON)
|
||||
.setId(tabId)
|
||||
var tab = HtmlTree.BUTTON(tabId)
|
||||
.put(HtmlAttr.ROLE, "tab")
|
||||
.put(HtmlAttr.ARIA_SELECTED, defaultTab ? "true" : "false")
|
||||
.put(HtmlAttr.ARIA_CONTROLS, HtmlIds.forTabPanel(id).name())
|
||||
|
@ -101,10 +101,10 @@ public class TableOfContents {
|
||||
.put(HtmlAttr.VALUE, writer.resources.getText("doclet.filter_reset")));
|
||||
}
|
||||
content.add(header);
|
||||
content.add(new HtmlTree(HtmlTag.BUTTON).addStyle(HtmlStyles.hideSidebar)
|
||||
content.add(HtmlTree.BUTTON(HtmlStyles.hideSidebar)
|
||||
.add(HtmlTree.SPAN(writer.contents.hideSidebar).add(Entity.NO_BREAK_SPACE))
|
||||
.add(Entity.LEFT_POINTING_ANGLE));
|
||||
content.add(new HtmlTree(HtmlTag.BUTTON).addStyle(HtmlStyles.showSidebar)
|
||||
content.add(HtmlTree.BUTTON(HtmlStyles.showSidebar)
|
||||
.add(Entity.RIGHT_POINTING_ANGLE)
|
||||
.add(HtmlTree.SPAN(Entity.NO_BREAK_SPACE).add(writer.contents.showSidebar)));
|
||||
return content.add(listBuilder);
|
||||
|
@ -272,9 +272,9 @@ public class Head extends Content {
|
||||
* @return the HTML
|
||||
*/
|
||||
private Content toContent() {
|
||||
var head = new HtmlTree(HtmlTag.HEAD);
|
||||
head.add(getGeneratedBy(showTimestamp, generatedDate));
|
||||
head.add(HtmlTree.TITLE(title));
|
||||
var head = HtmlTree.of(HtmlTag.HEAD)
|
||||
.add(getGeneratedBy(showTimestamp, generatedDate))
|
||||
.add(HtmlTree.TITLE(title));
|
||||
|
||||
head.add(HtmlTree.META("viewport", "width=device-width, initial-scale=1"));
|
||||
|
||||
@ -300,9 +300,9 @@ public class Head extends Content {
|
||||
}
|
||||
|
||||
if (canonicalLink != null) {
|
||||
var link = new HtmlTree(HtmlTag.LINK);
|
||||
link.put(HtmlAttr.REL, "canonical");
|
||||
link.put(HtmlAttr.HREF, canonicalLink.getPath());
|
||||
var link = HtmlTree.of(HtmlTag.LINK)
|
||||
.put(HtmlAttr.REL, "canonical")
|
||||
.put(HtmlAttr.HREF, canonicalLink.getPath());
|
||||
head.add(link);
|
||||
}
|
||||
|
||||
|
@ -122,13 +122,13 @@ public class SnippetTaglet extends BaseTaglet {
|
||||
private Content snippetTagOutput(Element element, SnippetTree tag, StyledText content,
|
||||
String id, String lang) {
|
||||
var pathToRoot = tagletWriter.htmlWriter.pathToRoot;
|
||||
var pre = new HtmlTree(HtmlTag.PRE).setStyle(HtmlStyles.snippet);
|
||||
var pre = HtmlTree.PRE(HtmlStyles.snippet);
|
||||
if (id != null && !id.isBlank()) {
|
||||
pre.put(HtmlAttr.ID, id);
|
||||
} else {
|
||||
pre.put(HtmlAttr.ID, config.htmlIds.forSnippet(element, ids).name());
|
||||
}
|
||||
var code = new HtmlTree(HtmlTag.CODE)
|
||||
var code = HtmlTree.CODE()
|
||||
.addUnchecked(Text.EMPTY); // Make sure the element is always rendered
|
||||
if (lang != null && !lang.isBlank()) {
|
||||
code.addStyle("language-" + lang);
|
||||
@ -197,10 +197,10 @@ public class SnippetTaglet extends BaseTaglet {
|
||||
String copiedText = resources.getText("doclet.Copied_to_clipboard");
|
||||
String copySnippetText = resources.getText("doclet.Copy_snippet_to_clipboard");
|
||||
var snippetContainer = HtmlTree.DIV(HtmlStyles.snippetContainer,
|
||||
new HtmlTree(HtmlTag.BUTTON)
|
||||
HtmlTree.of(HtmlTag.BUTTON)
|
||||
.add(HtmlTree.SPAN(Text.of(copyText))
|
||||
.put(HtmlAttr.DATA_COPIED, copiedText))
|
||||
.add(new HtmlTree(HtmlTag.IMG)
|
||||
.add(HtmlTree.of(HtmlTag.IMG)
|
||||
.put(HtmlAttr.SRC, pathToRoot.resolve(DocPaths.RESOURCE_FILES)
|
||||
.resolve(DocPaths.CLIPBOARD_SVG).getPath())
|
||||
.put(HtmlAttr.ALT, copySnippetText))
|
||||
|
@ -83,7 +83,17 @@ public class HtmlTree extends Content {
|
||||
*
|
||||
* @param tag the name
|
||||
*/
|
||||
public HtmlTree(HtmlTag tag) {
|
||||
public static HtmlTree of(HtmlTag tag) {
|
||||
return new HtmlTree(tag);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an {@code HTMLTree} object representing an HTML element
|
||||
* with the given name.
|
||||
*
|
||||
* @param tag the name
|
||||
*/
|
||||
HtmlTree(HtmlTag tag) {
|
||||
this.tag = Objects.requireNonNull(tag);
|
||||
}
|
||||
|
||||
@ -365,6 +375,46 @@ public class HtmlTree extends Content {
|
||||
.add(body);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an HTML {@code BODY} element with the given style.
|
||||
*
|
||||
* @param style the style
|
||||
* @return the element
|
||||
*/
|
||||
public static HtmlTree BODY(HtmlStyle style) {
|
||||
return new HtmlTree(HtmlTag.BODY)
|
||||
.setStyle(style);
|
||||
}
|
||||
|
||||
private static final HtmlTree BR_INSTANCE = unmodifiableTree(HtmlTag.BR);
|
||||
|
||||
/**
|
||||
* {@return an HTML {@code BR} element}
|
||||
*/
|
||||
public static HtmlTree BR() {
|
||||
return BR_INSTANCE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an HTML {@code BUTTON} element with the given id.
|
||||
*
|
||||
* @param id the id
|
||||
* @return the element
|
||||
*/
|
||||
public static HtmlTree BUTTON(HtmlId id) {
|
||||
return new HtmlTree(HtmlTag.BUTTON).setId(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an HTML {@code BUTTON} element with the given style.
|
||||
*
|
||||
* @param style the style
|
||||
* @return the element
|
||||
*/
|
||||
public static HtmlTree BUTTON(HtmlStyle style) {
|
||||
return new HtmlTree(HtmlTag.BUTTON).setStyle(style);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an HTML {@code CAPTION} element with the given content.
|
||||
*
|
||||
@ -376,6 +426,15 @@ public class HtmlTree extends Content {
|
||||
.add(body);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an empty HTML {@code CODE} element.
|
||||
*
|
||||
* @return the element
|
||||
*/
|
||||
public static HtmlTree CODE() {
|
||||
return new HtmlTree(HtmlTag.CODE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an HTML {@code CODE} element with the given content.
|
||||
*
|
||||
@ -387,6 +446,15 @@ public class HtmlTree extends Content {
|
||||
.add(body);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an empty HTML {@code DD} element.
|
||||
*
|
||||
* @return the element
|
||||
*/
|
||||
public static HtmlTree DD() {
|
||||
return new HtmlTree(HtmlTag.DD);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an HTML {@code DD} element with the given content.
|
||||
*
|
||||
@ -418,27 +486,14 @@ public class HtmlTree extends Content {
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an HTML {@code DL} element with the given style.
|
||||
* Creates an HTML {@code DIV} element with the given id.
|
||||
*
|
||||
* @param style the style
|
||||
* @param id the id
|
||||
* @return the element
|
||||
*/
|
||||
public static HtmlTree DL(HtmlStyle style) {
|
||||
return new HtmlTree(HtmlTag.DL)
|
||||
.setStyle(style);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an HTML {@code DL} element with the given style and content.
|
||||
*
|
||||
* @param style the style
|
||||
* @param body the content
|
||||
* @return the element
|
||||
*/
|
||||
public static HtmlTree DL(HtmlStyle style, Content body) {
|
||||
return new HtmlTree(HtmlTag.DL)
|
||||
.setStyle(style)
|
||||
.add(body);
|
||||
public static HtmlTree DIV(HtmlId id) {
|
||||
return new HtmlTree(HtmlTag.DIV)
|
||||
.setId(id);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -476,6 +531,30 @@ public class HtmlTree extends Content {
|
||||
.add(body);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an HTML {@code DL} element with the given style.
|
||||
*
|
||||
* @param style the style
|
||||
* @return the element
|
||||
*/
|
||||
public static HtmlTree DL(HtmlStyle style) {
|
||||
return new HtmlTree(HtmlTag.DL)
|
||||
.setStyle(style);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an HTML {@code DL} element with the given style and content.
|
||||
*
|
||||
* @param style the style
|
||||
* @param body the content
|
||||
* @return the element
|
||||
*/
|
||||
public static HtmlTree DL(HtmlStyle style, Content body) {
|
||||
return new HtmlTree(HtmlTag.DL)
|
||||
.setStyle(style)
|
||||
.add(body);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an HTML {@code DT} element with the given content.
|
||||
*
|
||||
@ -487,6 +566,17 @@ public class HtmlTree extends Content {
|
||||
.add(body);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an HTML {@code EM} element with the given content.
|
||||
*
|
||||
* @param body content for the element
|
||||
* @return the element
|
||||
*/
|
||||
public static HtmlTree EM(String body) {
|
||||
return new HtmlTree(HtmlTag.EM)
|
||||
.add(body);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an HTML {@code FOOTER} element.
|
||||
* The role is set to {@code contentinfo}.
|
||||
@ -573,6 +663,15 @@ public class HtmlTree extends Content {
|
||||
};
|
||||
}
|
||||
|
||||
private static final HtmlTree HR_INSTANCE = unmodifiableTree(HtmlTag.HR);
|
||||
|
||||
/**
|
||||
* {@return an HTML {@code HR} element}
|
||||
*/
|
||||
public static HtmlTree HR() {
|
||||
return HR_INSTANCE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an HTML {@code HTML} element with the given {@code lang} attribute,
|
||||
* and {@code HEAD} and {@code BODY} contents.
|
||||
@ -630,6 +729,27 @@ public class HtmlTree extends Content {
|
||||
.add(body);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an empty HTML {@code LI} element.
|
||||
*
|
||||
* @return the element
|
||||
*/
|
||||
public static HtmlTree LI() {
|
||||
return new HtmlTree(HtmlTag.LI);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Creates an HTML {@code LI} element with the given style.
|
||||
*
|
||||
* @param style the style
|
||||
* @return the element
|
||||
*/
|
||||
public static HtmlTree LI(HtmlStyle style) {
|
||||
return new HtmlTree(HtmlTag.LI)
|
||||
.setStyle(style);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an HTML {@code LI} element with the given content.
|
||||
*
|
||||
@ -776,6 +896,25 @@ public class HtmlTree extends Content {
|
||||
.setStyle(style);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an empty HTML {@code PRE} element.
|
||||
*
|
||||
* @return the element
|
||||
*/
|
||||
public static HtmlTree PRE() {
|
||||
return new HtmlTree(HtmlTag.PRE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an HTML {@code PRE} element with the given style
|
||||
*
|
||||
* @param style the style
|
||||
* @return the element
|
||||
*/
|
||||
public static HtmlTree PRE(HtmlStyle style) {
|
||||
return new HtmlTree(HtmlTag.PRE).setStyle(style);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an HTML {@code PRE} element with some content.
|
||||
*
|
||||
@ -971,6 +1110,15 @@ public class HtmlTree extends Content {
|
||||
.add(body);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an empty HTML {@code UL} element.
|
||||
*
|
||||
* @return the element
|
||||
*/
|
||||
public static HtmlTree UL() {
|
||||
return new HtmlTree(HtmlTag.UL);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an HTML {@code UL} element with the given style.
|
||||
*
|
||||
@ -982,6 +1130,19 @@ public class HtmlTree extends Content {
|
||||
.setStyle(style);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an HTML {@code UL} element with the given id and style.
|
||||
*
|
||||
* @param id the id
|
||||
* @param style the style
|
||||
* @return the element
|
||||
*/
|
||||
public static HtmlTree UL(HtmlId id, HtmlStyle style) {
|
||||
return new HtmlTree(HtmlTag.UL)
|
||||
.setId(id)
|
||||
.setStyle(style);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an HTML {@code UL} element with the given style and some content.
|
||||
*
|
||||
@ -1015,6 +1176,15 @@ public class HtmlTree extends Content {
|
||||
.addAll(items, mapper);
|
||||
}
|
||||
|
||||
private static final HtmlTree WBR_INSTANCE = unmodifiableTree(HtmlTag.WBR);
|
||||
|
||||
/**
|
||||
* {@return an HTML {@code WBR} element}
|
||||
*/
|
||||
public static HtmlTree WBR() {
|
||||
return WBR_INSTANCE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEmpty() {
|
||||
return (!hasContent() && !hasAttrs());
|
||||
@ -1152,4 +1322,17 @@ public class HtmlTree extends Content {
|
||||
// remove extra whitespaces
|
||||
return rawString.trim();
|
||||
}
|
||||
|
||||
private static HtmlTree unmodifiableTree(HtmlTag tag) {
|
||||
return new HtmlTree(tag) {
|
||||
@Override
|
||||
public HtmlTree add(Content c) {
|
||||
throw new UnsupportedOperationException(this.tag + " add");
|
||||
}
|
||||
@Override
|
||||
public HtmlTree put(HtmlAttr attrName, String attrValue) {
|
||||
throw new UnsupportedOperationException(this.tag + " put");
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -70,19 +70,19 @@ public class TestHtmlDocument extends JavadocTester {
|
||||
// Generate the HTML output using the HTML document generation within doclet.
|
||||
public static String generateHtmlTree() {
|
||||
// Document type for the HTML document
|
||||
HtmlTree html = new HtmlTree(HtmlTag.HTML);
|
||||
HtmlTree head = new HtmlTree(HtmlTag.HEAD);
|
||||
HtmlTree title = new HtmlTree(HtmlTag.TITLE);
|
||||
HtmlTree html = HtmlTree.of(HtmlTag.HTML);
|
||||
HtmlTree head = HtmlTree.of(HtmlTag.HEAD);
|
||||
HtmlTree title = HtmlTree.of(HtmlTag.TITLE);
|
||||
// String content within the document
|
||||
TextBuilder titleContent = new TextBuilder("Markup test");
|
||||
title.add(titleContent);
|
||||
head.add(title);
|
||||
// Test META tag
|
||||
HtmlTree meta = new HtmlTree(HtmlTag.META);
|
||||
HtmlTree meta = HtmlTree.of(HtmlTag.META);
|
||||
meta.put(HtmlAttr.NAME, "keywords");
|
||||
meta.put(HtmlAttr.CONTENT, "testContent");
|
||||
head.add(meta);
|
||||
HtmlTree link = new HtmlTree(HtmlTag.LINK);
|
||||
HtmlTree link = HtmlTree.of(HtmlTag.LINK);
|
||||
link.put(HtmlAttr.REL, "testRel");
|
||||
link.put(HtmlAttr.HREF, "testLink.html");
|
||||
head.add(link);
|
||||
@ -90,10 +90,10 @@ public class TestHtmlDocument extends JavadocTester {
|
||||
// Comment within the document
|
||||
Comment bodyMarker = new Comment("======== START OF BODY ========");
|
||||
html.add(bodyMarker);
|
||||
HtmlTree body = new HtmlTree(HtmlTag.BODY);
|
||||
HtmlTree body = HtmlTree.of(HtmlTag.BODY);
|
||||
Comment pMarker = new Comment("======== START OF PARAGRAPH ========");
|
||||
body.add(pMarker);
|
||||
HtmlTree p = new HtmlTree(HtmlTag.P);
|
||||
HtmlTree p = HtmlTree.of(HtmlTag.P);
|
||||
TextBuilder bodyContent = new TextBuilder(
|
||||
"This document is generated from sample source code and HTML " +
|
||||
"files with examples of a wide variety of Java language constructs: packages, " +
|
||||
@ -106,24 +106,24 @@ public class TestHtmlDocument extends JavadocTester {
|
||||
TextBuilder pContent = new TextBuilder(" to <test> out a link.");
|
||||
p.add(pContent);
|
||||
body.add(p);
|
||||
HtmlTree p1 = new HtmlTree(HtmlTag.P);
|
||||
HtmlTree p1 = HtmlTree.of(HtmlTag.P);
|
||||
// Test another version of A tag.
|
||||
HtmlTree anchor = new HtmlTree(HtmlTag.A);
|
||||
HtmlTree anchor = HtmlTree.of(HtmlTag.A);
|
||||
anchor.put(HtmlAttr.HREF, "testLink.html");
|
||||
anchor.put(HtmlAttr.ID, "Another version of a tag");
|
||||
p1.add(anchor);
|
||||
body.add(p1);
|
||||
// Test for empty tags.
|
||||
HtmlTree dl = new HtmlTree(HtmlTag.DL);
|
||||
HtmlTree dl = HtmlTree.of(HtmlTag.DL);
|
||||
html.add(dl);
|
||||
// Test for empty nested tags.
|
||||
HtmlTree dlTree = new HtmlTree(HtmlTag.DL);
|
||||
dlTree.add(new HtmlTree(HtmlTag.DT));
|
||||
dlTree.add(new HtmlTree (HtmlTag.DD));
|
||||
HtmlTree dlTree = HtmlTree.of(HtmlTag.DL);
|
||||
dlTree.add(HtmlTree.of(HtmlTag.DT));
|
||||
dlTree.add(HtmlTree.of (HtmlTag.DD));
|
||||
html.add(dlTree);
|
||||
HtmlTree dlDisplay = new HtmlTree(HtmlTag.DL);
|
||||
dlDisplay.add(new HtmlTree(HtmlTag.DT));
|
||||
HtmlTree dd = new HtmlTree (HtmlTag.DD);
|
||||
HtmlTree dlDisplay = HtmlTree.of(HtmlTag.DL);
|
||||
dlDisplay.add(HtmlTree.of(HtmlTag.DT));
|
||||
HtmlTree dd = HtmlTree.of (HtmlTag.DD);
|
||||
TextBuilder ddContent = new TextBuilder("Test DD");
|
||||
dd.add(ddContent);
|
||||
dlDisplay.add(dd);
|
||||
@ -132,7 +132,7 @@ public class TestHtmlDocument extends JavadocTester {
|
||||
body.add(emptyString);
|
||||
Comment emptyComment = new Comment("");
|
||||
body.add(emptyComment);
|
||||
HtmlTree hr = new HtmlTree(HtmlTag.HR);
|
||||
HtmlTree hr = HtmlTree.of(HtmlTag.HR);
|
||||
body.add(hr);
|
||||
html.add(body);
|
||||
HtmlDocument htmlDoc = new HtmlDocument(html);
|
||||
|
@ -55,7 +55,7 @@ public class TestVoidHtmlElements {
|
||||
}
|
||||
|
||||
private static void check(HtmlTag htmlTag) {
|
||||
boolean elementIsVoid = new HtmlTree(htmlTag).isVoid();
|
||||
boolean elementIsVoid = HtmlTree.of(htmlTag).isVoid();
|
||||
boolean elementHasNoEndTag = htmlTag.endKind == HtmlTag.EndKind.NONE;
|
||||
if (elementIsVoid != elementHasNoEndTag) {
|
||||
throw new AssertionError(htmlTag + ", " + elementIsVoid + ", " + elementHasNoEndTag);
|
||||
|
Loading…
Reference in New Issue
Block a user