8047745: Javadoc should include encoding information in generated html files
Reviewed-by: jjg, ksrini
This commit is contained in:
parent
99ec33372d
commit
b02c07123c
@ -397,20 +397,19 @@ public class HtmlDocletWriter extends HtmlDocWriter {
|
||||
Content htmlComment = new Comment(configuration.getText("doclet.New_Page"));
|
||||
Content head = new HtmlTree(HtmlTag.HEAD);
|
||||
head.addContent(getGeneratedBy(!configuration.notimestamp));
|
||||
if (configuration.charset.length() > 0) {
|
||||
Content meta = HtmlTree.META("Content-Type", CONTENT_TYPE,
|
||||
configuration.charset);
|
||||
head.addContent(meta);
|
||||
}
|
||||
head.addContent(getTitle());
|
||||
Content meta = HtmlTree.META("Content-Type", CONTENT_TYPE,
|
||||
(configuration.charset.length() > 0) ?
|
||||
configuration.charset : HtmlConstants.HTML_DEFAULT_CHARSET);
|
||||
head.addContent(meta);
|
||||
if (!configuration.notimestamp) {
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
||||
Content meta = HtmlTree.META("date", dateFormat.format(new Date()));
|
||||
meta = HtmlTree.META("date", dateFormat.format(new Date()));
|
||||
head.addContent(meta);
|
||||
}
|
||||
if (metakeywords != null) {
|
||||
for (String metakeyword : metakeywords) {
|
||||
Content meta = HtmlTree.META("keywords", metakeyword);
|
||||
meta = HtmlTree.META("keywords", metakeyword);
|
||||
head.addContent(meta);
|
||||
}
|
||||
}
|
||||
|
@ -220,4 +220,9 @@ public class HtmlConstants {
|
||||
* Html tag for the member heading.
|
||||
*/
|
||||
public static final HtmlTag MEMBER_HEADING = HtmlTag.H4;
|
||||
|
||||
/**
|
||||
* Default charset for HTML.
|
||||
*/
|
||||
public static final String HTML_DEFAULT_CHARSET = "utf-8";
|
||||
}
|
||||
|
@ -311,13 +311,12 @@ public abstract class HtmlDocWriter extends HtmlWriter {
|
||||
Content htmlComment = new Comment(configuration.getText("doclet.New_Page"));
|
||||
Content head = new HtmlTree(HtmlTag.HEAD);
|
||||
head.addContent(getGeneratedBy(!noTimeStamp));
|
||||
if (configuration.charset.length() > 0) {
|
||||
Content meta = HtmlTree.META("Content-Type", CONTENT_TYPE,
|
||||
configuration.charset);
|
||||
head.addContent(meta);
|
||||
}
|
||||
Content windowTitle = HtmlTree.TITLE(new StringContent(title));
|
||||
head.addContent(windowTitle);
|
||||
Content meta = HtmlTree.META("Content-Type", CONTENT_TYPE,
|
||||
(configuration.charset.length() > 0) ?
|
||||
configuration.charset : HtmlConstants.HTML_DEFAULT_CHARSET);
|
||||
head.addContent(meta);
|
||||
head.addContent(getFramesetJavaScript());
|
||||
Content htmlTree = HtmlTree.HTML(configuration.getLocale().getLanguage(),
|
||||
head, frameset);
|
||||
|
@ -23,7 +23,7 @@
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 7052170
|
||||
* @bug 7052170 8047745
|
||||
* @summary Run a test on -charset to make sure the charset gets generated as a
|
||||
* part of the meta tag.
|
||||
* @author Bhavesh Patel
|
||||
@ -42,19 +42,32 @@ public class TestCharset extends JavadocTester {
|
||||
@Test
|
||||
void test() {
|
||||
javadoc("-d", "out",
|
||||
"-charset", "UTF-8",
|
||||
"-charset", "ISO-8859-1",
|
||||
"-sourcepath", testSrc,
|
||||
"pkg");
|
||||
checkExit(Exit.OK);
|
||||
|
||||
checkOutput("index.html", true,
|
||||
"<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">");
|
||||
"<meta http-equiv=\"Content-Type\" content=\"text/html; charset=ISO-8859-1\">");
|
||||
checkOutput("pkg/Foo.html", true,
|
||||
"<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">");
|
||||
"<meta http-equiv=\"Content-Type\" content=\"text/html; charset=ISO-8859-1\">");
|
||||
|
||||
checkOutput("index.html", false,
|
||||
"<meta http-equiv=\"Content-Type\" content=\"text/html\" charset=\"UTF-8\">");
|
||||
"<meta http-equiv=\"Content-Type\" content=\"text/html\" charset=\"ISO-8859-1\">");
|
||||
checkOutput("pkg/Foo.html", false,
|
||||
"<meta http-equiv=\"Content-Type\" content=\"text/html\" charset=\"UTF-8\">");
|
||||
"<meta http-equiv=\"Content-Type\" content=\"text/html\" charset=\"ISO-8859-1\">");
|
||||
}
|
||||
|
||||
@Test
|
||||
void test1() {
|
||||
javadoc("-d", "out-1",
|
||||
"-sourcepath", testSrc,
|
||||
"pkg");
|
||||
checkExit(Exit.OK);
|
||||
|
||||
checkOutput("index.html", true,
|
||||
"<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">");
|
||||
checkOutput("pkg/Foo.html", true,
|
||||
"<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">");
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user