mirror of
https://github.com/openjdk/jdk.git
synced 2026-02-06 16:38:36 +00:00
8011668: Allow HTMLWriter.getResource to take Content args
Reviewed-by: darcy
This commit is contained in:
parent
1711056efc
commit
b2becec2bc
@ -160,8 +160,9 @@ public class AbstractIndexWriter extends HtmlDocletWriter {
|
||||
protected void addClassInfo(ClassDoc cd, Content contentTree) {
|
||||
contentTree.addContent(getResource("doclet.in",
|
||||
Util.getTypeName(configuration, cd, false),
|
||||
getPackageLinkString(cd.containingPackage(),
|
||||
Util.escapeHtmlChars(Util.getPackageName(cd.containingPackage())), false)));
|
||||
getPackageLink(cd.containingPackage(),
|
||||
Util.getPackageName(cd.containingPackage()))
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -331,11 +331,10 @@ public class ClassUseWriter extends SubWriterHolderWriter {
|
||||
for (Iterator<PackageDoc> it = pkgSet.iterator(); it.hasNext();) {
|
||||
PackageDoc pkg = it.next();
|
||||
Content li = HtmlTree.LI(HtmlStyle.blockList, getMarkerAnchor(pkg.name()));
|
||||
Content link = new RawHtml(
|
||||
configuration.getText("doclet.ClassUse_Uses.of.0.in.1",
|
||||
Content link = getResource("doclet.ClassUse_Uses.of.0.in.1",
|
||||
getLink(new LinkInfoImpl(configuration, LinkInfoImpl.Kind.CLASS_USE_HEADER,
|
||||
classdoc)).toString(),
|
||||
getPackageLinkString(pkg, Util.escapeHtmlChars(Util.getPackageName(pkg)), false)));
|
||||
classdoc)),
|
||||
getPackageLink(pkg, Util.getPackageName(pkg)));
|
||||
Content heading = HtmlTree.HEADING(HtmlConstants.SUMMARY_HEADING, link);
|
||||
li.addContent(heading);
|
||||
addClassUse(pkg, li);
|
||||
|
||||
@ -31,6 +31,7 @@ import java.util.*;
|
||||
import javax.tools.JavaFileManager;
|
||||
|
||||
import com.sun.javadoc.*;
|
||||
import com.sun.tools.doclets.formats.html.markup.ContentBuilder;
|
||||
import com.sun.tools.doclets.internal.toolkit.*;
|
||||
import com.sun.tools.doclets.internal.toolkit.util.*;
|
||||
import com.sun.tools.doclint.DocLint;
|
||||
@ -562,4 +563,9 @@ public class ConfigurationImpl extends Configuration {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Content getContentForResource() {
|
||||
return new ContentBuilder();
|
||||
}
|
||||
}
|
||||
|
||||
@ -121,7 +121,7 @@ public class FrameOutputWriter extends HtmlDocletWriter {
|
||||
getResource("doclet.Frame_Alert"));
|
||||
noframes.addContent(noframesHead);
|
||||
Content p = HtmlTree.P(getResource("doclet.Frame_Warning_Message",
|
||||
getHyperLinkString(configuration.topFile,
|
||||
getHyperLink(configuration.topFile,
|
||||
configuration.getText("doclet.Non_Frame_Version"))));
|
||||
noframes.addContent(p);
|
||||
contentTree.addContent(noframes);
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1998, 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
|
||||
@ -113,7 +113,7 @@ public class HelpWriter extends HtmlDocletWriter {
|
||||
getResource("doclet.Overview"));
|
||||
Content liOverview = HtmlTree.LI(HtmlStyle.blockList, overviewHeading);
|
||||
Content line3 = getResource("doclet.Help_line_3",
|
||||
getHyperLinkString(DocPaths.OVERVIEW_SUMMARY,
|
||||
getHyperLink(DocPaths.OVERVIEW_SUMMARY,
|
||||
configuration.getText("doclet.Overview")));
|
||||
Content overviewPara = HtmlTree.P(line3);
|
||||
liOverview.addContent(overviewPara);
|
||||
@ -234,8 +234,9 @@ public class HelpWriter extends HtmlDocletWriter {
|
||||
getResource("doclet.Help_line_16"));
|
||||
Content liTree = HtmlTree.LI(HtmlStyle.blockList, treeHead);
|
||||
Content line17 = getResource("doclet.Help_line_17_with_tree_link",
|
||||
getHyperLinkString(DocPaths.OVERVIEW_TREE,
|
||||
configuration.getText("doclet.Class_Hierarchy")));
|
||||
getHyperLink(DocPaths.OVERVIEW_TREE,
|
||||
configuration.getText("doclet.Class_Hierarchy")),
|
||||
HtmlTree.CODE(new StringContent("java.lang.Object")));
|
||||
Content treePara = HtmlTree.P(line17);
|
||||
liTree.addContent(treePara);
|
||||
HtmlTree tul = new HtmlTree(HtmlTag.UL);
|
||||
@ -252,19 +253,19 @@ public class HelpWriter extends HtmlDocletWriter {
|
||||
getResource("doclet.Deprecated_API"));
|
||||
Content liDeprecated = HtmlTree.LI(HtmlStyle.blockList, dHead);
|
||||
Content line20 = getResource("doclet.Help_line_20_with_deprecated_api_link",
|
||||
getHyperLinkString(DocPaths.DEPRECATED_LIST,
|
||||
getHyperLink(DocPaths.DEPRECATED_LIST,
|
||||
configuration.getText("doclet.Deprecated_API")));
|
||||
Content dPara = HtmlTree.P(line20);
|
||||
liDeprecated.addContent(dPara);
|
||||
ul.addContent(liDeprecated);
|
||||
}
|
||||
if (configuration.createindex) {
|
||||
String indexlink;
|
||||
Content indexlink;
|
||||
if (configuration.splitindex) {
|
||||
indexlink = getHyperLinkString(DocPaths.INDEX_FILES.resolve(DocPaths.indexN(1)),
|
||||
indexlink = getHyperLink(DocPaths.INDEX_FILES.resolve(DocPaths.indexN(1)),
|
||||
configuration.getText("doclet.Index"));
|
||||
} else {
|
||||
indexlink = getHyperLinkString(DocPaths.INDEX_ALL,
|
||||
indexlink = getHyperLink(DocPaths.INDEX_ALL,
|
||||
configuration.getText("doclet.Index"));
|
||||
}
|
||||
Content indexHead = HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING,
|
||||
@ -293,7 +294,7 @@ public class HelpWriter extends HtmlDocletWriter {
|
||||
getResource("doclet.All_Classes"));
|
||||
Content liAllClasses = HtmlTree.LI(HtmlStyle.blockList, allclassesHead);
|
||||
Content line27 = getResource("doclet.Help_line_27",
|
||||
getHyperLinkString(DocPaths.ALLCLASSES_NOFRAME,
|
||||
getHyperLink(DocPaths.ALLCLASSES_NOFRAME,
|
||||
configuration.getText("doclet.All_Classes")));
|
||||
Content allclassesPara = HtmlTree.P(line27);
|
||||
liAllClasses.addContent(allclassesPara);
|
||||
@ -309,7 +310,7 @@ public class HelpWriter extends HtmlDocletWriter {
|
||||
getResource("doclet.Constants_Summary"));
|
||||
Content liConst = HtmlTree.LI(HtmlStyle.blockList, constHead);
|
||||
Content line29 = getResource("doclet.Help_line_29",
|
||||
getHyperLinkString(DocPaths.CONSTANT_VALUES,
|
||||
getHyperLink(DocPaths.CONSTANT_VALUES,
|
||||
configuration.getText("doclet.Constants_Summary")));
|
||||
Content constPara = HtmlTree.P(line29);
|
||||
liConst.addContent(constPara);
|
||||
|
||||
@ -1042,6 +1042,17 @@ public class HtmlDocletWriter extends HtmlDocWriter {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the link to the given package.
|
||||
*
|
||||
* @param pkg the package to link to.
|
||||
* @param label the label for the link.
|
||||
* @return a content tree for the package link.
|
||||
*/
|
||||
public Content getPackageLink(PackageDoc pkg, String label) {
|
||||
return getPackageLink(pkg, new StringContent(label));
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the link to the given package.
|
||||
*
|
||||
|
||||
@ -115,7 +115,7 @@ public class PackageTreeWriter extends AbstractTreeWriter {
|
||||
protected void generatePackageTreeFile() throws IOException {
|
||||
Content body = getPackageTreeHeader();
|
||||
Content headContent = getResource("doclet.Hierarchy_For_Package",
|
||||
Util.escapeHtmlChars(Util.getPackageName(packagedoc)));
|
||||
Util.getPackageName(packagedoc));
|
||||
Content heading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, false,
|
||||
HtmlStyle.title, headContent);
|
||||
Content div = HtmlTree.DIV(HtmlStyle.header, heading);
|
||||
|
||||
@ -81,6 +81,7 @@ public class ContentBuilder extends Content {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int charCount() {
|
||||
int n = 0;
|
||||
for (Content c : contents)
|
||||
|
||||
@ -82,6 +82,10 @@ public abstract class HtmlDocWriter extends HtmlWriter {
|
||||
return getHyperLinkString(link, label, false, "", "", "");
|
||||
}
|
||||
|
||||
public Content getHyperLink(DocPath link, String label) {
|
||||
return getHyperLink(link, new StringContent(label), false, "", "", "");
|
||||
}
|
||||
|
||||
public String getHyperLinkString(DocLink link, String label) {
|
||||
return getHyperLinkString(link, label, false, "", "", "");
|
||||
}
|
||||
@ -184,6 +188,13 @@ public abstract class HtmlDocWriter extends HtmlWriter {
|
||||
return retlink.toString();
|
||||
}
|
||||
|
||||
public Content getHyperLink(DocPath link,
|
||||
Content label, boolean strong,
|
||||
String stylename, String title, String target) {
|
||||
return getHyperLink(new DocLink(link), label, strong,
|
||||
stylename, title, target);
|
||||
}
|
||||
|
||||
public Content getHyperLink(DocLink link,
|
||||
Content label, boolean strong,
|
||||
String stylename, String title, String target) {
|
||||
@ -282,20 +293,6 @@ public abstract class HtmlDocWriter extends HtmlWriter {
|
||||
write(htmlDocument);
|
||||
}
|
||||
|
||||
/**
|
||||
* Print the appropriate spaces to format the class tree in the class page.
|
||||
*
|
||||
* @param len Number of spaces.
|
||||
*/
|
||||
public String spaces(int len) {
|
||||
String space = "";
|
||||
|
||||
for (int i = 0; i < len; i++) {
|
||||
space += " ";
|
||||
}
|
||||
return space;
|
||||
}
|
||||
|
||||
protected String getGeneratedByString() {
|
||||
Calendar calendar = new GregorianCalendar(TimeZone.getDefault());
|
||||
Date today = calendar.getTime();
|
||||
|
||||
@ -27,6 +27,8 @@ package com.sun.tools.doclets.formats.html.markup;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import com.sun.tools.doclets.internal.toolkit.*;
|
||||
import com.sun.tools.doclets.internal.toolkit.util.*;
|
||||
@ -252,30 +254,30 @@ public class HtmlWriter {
|
||||
* @return a content tree for the text
|
||||
*/
|
||||
public Content getResource(String key) {
|
||||
return new StringContent(configuration.getText(key));
|
||||
return configuration.getResource(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the configuration string as a content.
|
||||
*
|
||||
* @param key the key to look for in the configuration file
|
||||
* @param a1 string argument added to configuration text
|
||||
* @param o string or content argument added to configuration text
|
||||
* @return a content tree for the text
|
||||
*/
|
||||
public Content getResource(String key, String a1) {
|
||||
return new RawHtml(configuration.getText(key, a1));
|
||||
public Content getResource(String key, Object o) {
|
||||
return configuration.getResource(key, o);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the configuration string as a content.
|
||||
*
|
||||
* @param key the key to look for in the configuration file
|
||||
* @param a1 string argument added to configuration text
|
||||
* @param a2 string argument added to configuration text
|
||||
* @param o1 string or content argument added to configuration text
|
||||
* @param o2 string or content argument added to configuration text
|
||||
* @return a content tree for the text
|
||||
*/
|
||||
public Content getResource(String key, String a1, String a2) {
|
||||
return new RawHtml(configuration.getText(key, a1, a2));
|
||||
public Content getResource(String key, Object o0, Object o1) {
|
||||
return configuration.getResource(key, o0, o1);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -132,7 +132,7 @@ doclet.Help_line_13=Each summary entry contains the first sentence from the deta
|
||||
doclet.Help_line_14=Use
|
||||
doclet.Help_line_15=Each documented package, class and interface has its own Use page. This page describes what packages, classes, methods, constructors and fields use any part of the given class or package. Given a class or interface A, its Use page includes subclasses of A, fields declared as A, methods that return A, and methods and constructors with parameters of type A. You can access this page by first going to the package, class or interface, then clicking on the "Use" link in the navigation bar.
|
||||
doclet.Help_line_16=Tree (Class Hierarchy)
|
||||
doclet.Help_line_17_with_tree_link=There is a {0} page for all packages, plus a hierarchy for each package. Each hierarchy page contains a list of classes and a list of interfaces. The classes are organized by inheritance structure starting with <code>java.lang.Object</code>. The interfaces do not inherit from <code>java.lang.Object</code>.
|
||||
doclet.Help_line_17_with_tree_link=There is a {0} page for all packages, plus a hierarchy for each package. Each hierarchy page contains a list of classes and a list of interfaces. The classes are organized by inheritance structure starting with {1}. The interfaces do not inherit from {1}.
|
||||
doclet.Help_line_18=When viewing the Overview page, clicking on "Tree" displays the hierarchy for all packages.
|
||||
doclet.Help_line_19=When viewing a particular package, class or interface page, clicking "Tree" displays the hierarchy for only that package.
|
||||
doclet.Help_line_20_with_deprecated_api_link=The {0} page lists all of the API that have been deprecated. A deprecated API is not recommended for use, generally due to improvements, and a replacement API is usually given. Deprecated APIs may be removed in future implementations.
|
||||
|
||||
@ -27,6 +27,8 @@ package com.sun.tools.doclets.internal.toolkit;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import com.sun.javadoc.*;
|
||||
import com.sun.tools.javac.sym.Profiles;
|
||||
@ -825,6 +827,82 @@ public abstract class Configuration {
|
||||
}
|
||||
}
|
||||
|
||||
public abstract Content getContentForResource();
|
||||
|
||||
/**
|
||||
* Get the configuration string as a content.
|
||||
*
|
||||
* @param key the key to look for in the configuration file
|
||||
* @return a content tree for the text
|
||||
*/
|
||||
public Content getResource(String key) {
|
||||
Content c = getContentForResource();
|
||||
c.addContent(getText(key));
|
||||
return c;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the configuration string as a content.
|
||||
*
|
||||
* @param key the key to look for in the configuration file
|
||||
* @param o string or content argument added to configuration text
|
||||
* @return a content tree for the text
|
||||
*/
|
||||
public Content getResource(String key, Object o) {
|
||||
return getResource(key, o, null, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the configuration string as a content.
|
||||
*
|
||||
* @param key the key to look for in the configuration file
|
||||
* @param o string or content argument added to configuration text
|
||||
* @return a content tree for the text
|
||||
*/
|
||||
public Content getResource(String key, Object o1, Object o2) {
|
||||
return getResource(key, o1, o2, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the configuration string as a content.
|
||||
*
|
||||
* @param key the key to look for in the configuration file
|
||||
* @param o1 string or content argument added to configuration text
|
||||
* @param o2 string or content argument added to configuration text
|
||||
* @return a content tree for the text
|
||||
*/
|
||||
public Content getResource(String key, Object o0, Object o1, Object o2) {
|
||||
Content c = getContentForResource();
|
||||
Pattern p = Pattern.compile("\\{([012])\\}");
|
||||
String text = getText(key);
|
||||
Matcher m = p.matcher(text);
|
||||
int start = 0;
|
||||
while (m.find(start)) {
|
||||
c.addContent(text.substring(start, m.start()));
|
||||
|
||||
Object o = null;
|
||||
switch (m.group(1).charAt(0)) {
|
||||
case '0': o = o0; break;
|
||||
case '1': o = o1; break;
|
||||
case '2': o = o2; break;
|
||||
}
|
||||
|
||||
if (o == null) {
|
||||
c.addContent("{" + m.group(1) + "}");
|
||||
} else if (o instanceof String) {
|
||||
c.addContent((String) o);
|
||||
} else if (o instanceof Content) {
|
||||
c.addContent((Content) o);
|
||||
}
|
||||
|
||||
start = m.end();
|
||||
}
|
||||
|
||||
c.addContent(text.substring(start));
|
||||
return c;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return true if the ClassDoc element is getting documented, depending upon
|
||||
* -nodeprecated option and the deprecation information. Return true if
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user