This commit is contained in:
Jesper Wilhelmsson 2020-06-30 20:59:15 +02:00
commit 545d56dd42
8 changed files with 17 additions and 27 deletions

View File

@ -26,6 +26,7 @@
package jdk.javadoc.internal;
import java.util.ResourceBundle;
import java.util.stream.Collectors;
import static java.util.ResourceBundle.getBundle;
@ -77,15 +78,18 @@ public final class Versions {
/**
* Returns a short string representation of the provided version.
*
* <p> Examples of strings returned from this method are: "15" and
* "15-internal".
* <p> The string contains the dotted representation of the version number,
* followed by the prerelease info, if any.
* For example, "15", "15.1", "15.0.1", "15-internal".
*
* @return a short string representation of the provided version
*
* @throws NullPointerException if {@code v == null}
*/
public static String shortVersionStringOf(Runtime.Version v) {
String svstr = String.valueOf(v.feature());
String svstr = v.version().stream()
.map(Object::toString)
.collect(Collectors.joining("."));
if (v.pre().isPresent()) {
svstr += "-" + v.pre().get();
}

View File

@ -159,11 +159,6 @@ public class HtmlConfiguration extends BaseConfiguration {
return docletVersion;
}
@Override
public String getDocletVersionString() {
return Versions.shortVersionStringOf(docletVersion);
}
@Override
public Resources getDocResources() {
return docResources;

View File

@ -431,7 +431,7 @@ public class HtmlDocletWriter {
Content htmlComment = contents.newPage;
List<DocPath> additionalStylesheets = configuration.getAdditionalStylesheets();
additionalStylesheets.addAll(localStylesheets);
Head head = new Head(path, configuration.getDocletVersionString(), configuration.startTime)
Head head = new Head(path, configuration.getDocletVersion(), configuration.startTime)
.setTimestamp(!options.noTimestamp())
.setDescription(description)
.setGenerator(getGenerator(getClass()))

View File

@ -75,7 +75,7 @@ public class IndexRedirectWriter extends HtmlDocletWriter {
*/
private void generateIndexFile() throws DocFileIOException {
Content htmlComment = contents.newPage;
Head head = new Head(path, configuration.getDocletVersionString(), configuration.startTime)
Head head = new Head(path, configuration.getDocletVersion(), configuration.startTime)
.setTimestamp(!options.noTimestamp())
.setDescription("index redirect")
.setGenerator(getGenerator(getClass()))

View File

@ -235,7 +235,7 @@ public class SourceToHTMLConverter {
* @param path the path for the file.
*/
private void writeToFile(Content body, DocPath path, TypeElement te) throws DocFileIOException {
Head head = new Head(path, configuration.getDocletVersionString(), configuration.startTime)
Head head = new Head(path, configuration.getDocletVersion(), configuration.startTime)
// .setTimestamp(!options.notimestamp) // temporary: compatibility!
.setTitle(resources.getText("doclet.Window_Source_title"))
// .setCharset(options.charset) // temporary: compatibility!

View File

@ -49,7 +49,7 @@ import jdk.javadoc.internal.doclets.toolkit.util.DocPaths;
* deletion without notice.</b>
*/
public class Head extends Content {
private final String docletVersion;
private final Runtime.Version docletVersion;
private final Date generatedDate;
private final DocPath pathToRoot;
private String title;
@ -74,9 +74,9 @@ public class Head extends Content {
* recording the time the file was created.
* The doclet version should also be provided for recording in the file.
* @param path the path for the file that will include this HEAD element
* @param docletVersion a string identifying the doclet version
* @param docletVersion the doclet version
*/
public Head(DocPath path, String docletVersion, Date generatedDate) {
public Head(DocPath path, Runtime.Version docletVersion, Date generatedDate) {
this.docletVersion = docletVersion;
this.generatedDate = generatedDate;
pathToRoot = path.parent().invert();
@ -294,9 +294,8 @@ public class Head extends Content {
private Comment getGeneratedBy(boolean timestamp, Date now) {
String text = "Generated by javadoc"; // marker string, deliberately not localized
text += " (" + docletVersion + ")";
if (timestamp) {
text += " on " + now;
text += " ("+ docletVersion.feature() + ") on " + now;
}
return new Comment(text);
}

View File

@ -157,14 +157,6 @@ public abstract class BaseConfiguration {
*/
public abstract Runtime.Version getDocletVersion();
/**
* Returns a short string representation of the version returned by
* {@linkplain #getDocletVersion()}.
*
* @return a short string representation of the version
*/
public abstract String getDocletVersionString();
/**
* This method should be defined in all those doclets (configurations),
* which want to derive themselves from this BaseConfiguration. This method

View File

@ -79,9 +79,9 @@ public class TestGeneratedBy extends JavadocTester {
}
void checkTimestamps(boolean timestamp, String... files) {
String version = System.getProperty("java.version");
String genBy = "Generated by javadoc (" + version + ")";
if (timestamp) genBy += " on ";
String version = System.getProperty("java.specification.version");
String genBy = "Generated by javadoc";
if (timestamp) genBy += " (" + version + ") on ";
for (String file: files) {
// genBy is the current standard "Generated by" text