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 htmlComment = new Comment(configuration.getText("doclet.New_Page"));
|
||||||
Content head = new HtmlTree(HtmlTag.HEAD);
|
Content head = new HtmlTree(HtmlTag.HEAD);
|
||||||
head.addContent(getGeneratedBy(!configuration.notimestamp));
|
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());
|
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) {
|
if (!configuration.notimestamp) {
|
||||||
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
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);
|
head.addContent(meta);
|
||||||
}
|
}
|
||||||
if (metakeywords != null) {
|
if (metakeywords != null) {
|
||||||
for (String metakeyword : metakeywords) {
|
for (String metakeyword : metakeywords) {
|
||||||
Content meta = HtmlTree.META("keywords", metakeyword);
|
meta = HtmlTree.META("keywords", metakeyword);
|
||||||
head.addContent(meta);
|
head.addContent(meta);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -220,4 +220,9 @@ public class HtmlConstants {
|
|||||||
* Html tag for the member heading.
|
* Html tag for the member heading.
|
||||||
*/
|
*/
|
||||||
public static final HtmlTag MEMBER_HEADING = HtmlTag.H4;
|
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 htmlComment = new Comment(configuration.getText("doclet.New_Page"));
|
||||||
Content head = new HtmlTree(HtmlTag.HEAD);
|
Content head = new HtmlTree(HtmlTag.HEAD);
|
||||||
head.addContent(getGeneratedBy(!noTimeStamp));
|
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));
|
Content windowTitle = HtmlTree.TITLE(new StringContent(title));
|
||||||
head.addContent(windowTitle);
|
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());
|
head.addContent(getFramesetJavaScript());
|
||||||
Content htmlTree = HtmlTree.HTML(configuration.getLocale().getLanguage(),
|
Content htmlTree = HtmlTree.HTML(configuration.getLocale().getLanguage(),
|
||||||
head, frameset);
|
head, frameset);
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* @test
|
* @test
|
||||||
* @bug 7052170
|
* @bug 7052170 8047745
|
||||||
* @summary Run a test on -charset to make sure the charset gets generated as a
|
* @summary Run a test on -charset to make sure the charset gets generated as a
|
||||||
* part of the meta tag.
|
* part of the meta tag.
|
||||||
* @author Bhavesh Patel
|
* @author Bhavesh Patel
|
||||||
@ -42,19 +42,32 @@ public class TestCharset extends JavadocTester {
|
|||||||
@Test
|
@Test
|
||||||
void test() {
|
void test() {
|
||||||
javadoc("-d", "out",
|
javadoc("-d", "out",
|
||||||
"-charset", "UTF-8",
|
"-charset", "ISO-8859-1",
|
||||||
"-sourcepath", testSrc,
|
"-sourcepath", testSrc,
|
||||||
"pkg");
|
"pkg");
|
||||||
checkExit(Exit.OK);
|
checkExit(Exit.OK);
|
||||||
|
|
||||||
checkOutput("index.html", true,
|
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,
|
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,
|
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,
|
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