8024288: javadoc generated-by comment should always be present

Wed, 04 Sep 2013 14:44:05 -0700

author
jjg
date
Wed, 04 Sep 2013 14:44:05 -0700
changeset 2006
044721d4d359
parent 2005
b94824ddcbb6
child 2007
a76c663a9cac

8024288: javadoc generated-by comment should always be present
Reviewed-by: bpatel

src/share/classes/com/sun/tools/doclets/formats/html/HtmlDocletWriter.java file | annotate | diff | comparison | revisions
src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlDocWriter.java file | annotate | diff | comparison | revisions
test/com/sun/javadoc/testGeneratedBy/TestGeneratedBy.java file | annotate | diff | comparison | revisions
     1.1 --- a/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDocletWriter.java	Wed Sep 04 11:53:09 2013 +0100
     1.2 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDocletWriter.java	Wed Sep 04 14:44:05 2013 -0700
     1.3 @@ -406,10 +406,7 @@
     1.4          Content htmlDocType = DocType.TRANSITIONAL;
     1.5          Content htmlComment = new Comment(configuration.getText("doclet.New_Page"));
     1.6          Content head = new HtmlTree(HtmlTag.HEAD);
     1.7 -        if (!configuration.notimestamp) {
     1.8 -            Content headComment = new Comment(getGeneratedByString());
     1.9 -            head.addContent(headComment);
    1.10 -        }
    1.11 +        head.addContent(getGeneratedBy(!configuration.notimestamp));
    1.12          if (configuration.charset.length() > 0) {
    1.13              Content meta = HtmlTree.META("Content-Type", CONTENT_TYPE,
    1.14                      configuration.charset);
     2.1 --- a/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlDocWriter.java	Wed Sep 04 11:53:09 2013 +0100
     2.2 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlDocWriter.java	Wed Sep 04 14:44:05 2013 -0700
     2.3 @@ -191,10 +191,7 @@
     2.4          Content htmlDocType = DocType.FRAMESET;
     2.5          Content htmlComment = new Comment(configuration.getText("doclet.New_Page"));
     2.6          Content head = new HtmlTree(HtmlTag.HEAD);
     2.7 -        if (! noTimeStamp) {
     2.8 -            Content headComment = new Comment(getGeneratedByString());
     2.9 -            head.addContent(headComment);
    2.10 -        }
    2.11 +        head.addContent(getGeneratedBy(!noTimeStamp));
    2.12          if (configuration.charset.length() > 0) {
    2.13              Content meta = HtmlTree.META("Content-Type", CONTENT_TYPE,
    2.14                      configuration.charset);
    2.15 @@ -210,9 +207,13 @@
    2.16          write(htmlDocument);
    2.17      }
    2.18  
    2.19 -    protected String getGeneratedByString() {
    2.20 -        Calendar calendar = new GregorianCalendar(TimeZone.getDefault());
    2.21 -        Date today = calendar.getTime();
    2.22 -        return "Generated by javadoc ("+ ConfigurationImpl.BUILD_DATE + ") on " + today;
    2.23 +    protected Comment getGeneratedBy(boolean timestamp) {
    2.24 +        String text = "Generated by javadoc"; // marker string, deliberately not localized
    2.25 +        if (timestamp) {
    2.26 +            Calendar calendar = new GregorianCalendar(TimeZone.getDefault());
    2.27 +            Date today = calendar.getTime();
    2.28 +            text += " ("+ ConfigurationImpl.BUILD_DATE + ") on " + today;
    2.29 +        }
    2.30 +        return new Comment(text);
    2.31      }
    2.32  }
     3.1 --- a/test/com/sun/javadoc/testGeneratedBy/TestGeneratedBy.java	Wed Sep 04 11:53:09 2013 +0100
     3.2 +++ b/test/com/sun/javadoc/testGeneratedBy/TestGeneratedBy.java	Wed Sep 04 14:44:05 2013 -0700
     3.3 @@ -1,5 +1,5 @@
     3.4  /*
     3.5 - * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
     3.6 + * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
     3.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3.8   *
     3.9   * This code is free software; you can redistribute it and/or modify it
    3.10 @@ -23,7 +23,7 @@
    3.11  
    3.12  /*
    3.13   * @test
    3.14 - * @bug 8000418
    3.15 + * @bug 8000418 8024288
    3.16   * @summary Verify that files use a common Generated By string
    3.17   * @library ../lib/
    3.18   * @build JavadocTester TestGeneratedBy
    3.19 @@ -50,32 +50,44 @@
    3.20          "index.html"
    3.21      };
    3.22  
    3.23 -    private static final String[] ARGS =
    3.24 +    private static final String[] STD_ARGS =
    3.25          new String[] {
    3.26              "-d", OUTPUT_DIR,
    3.27              "-sourcepath", SRC_DIR,
    3.28              "pkg"
    3.29          };
    3.30 -    private static final String BUG_ID = "8000418";
    3.31  
    3.32 -    private static String[][] getTests() {
    3.33 +    private static final String[] NO_TIMESTAMP_ARGS =
    3.34 +        new String[] {
    3.35 +            "-notimestamp",
    3.36 +            "-d", OUTPUT_DIR,
    3.37 +            "-sourcepath", SRC_DIR,
    3.38 +            "pkg"
    3.39 +        };
    3.40 +
    3.41 +    private static final String BUG_ID = "8000418-8024288";
    3.42 +
    3.43 +    private static String[][] getTests(boolean timestamp) {
    3.44          String version = System.getProperty("java.version");
    3.45          String[][] tests = new String[FILES.length][];
    3.46          for (int i = 0; i < FILES.length; i++) {
    3.47 +            String genBy = "Generated by javadoc";
    3.48 +            if (timestamp) genBy += " (" + version + ") on ";
    3.49              tests[i] = new String[] {
    3.50 -                OUTPUT_DIR + FS + FILES[i],
    3.51 -                "Generated by javadoc (" + version + ") on "
    3.52 +                OUTPUT_DIR + FS + FILES[i], genBy
    3.53              };
    3.54          }
    3.55          return tests;
    3.56      }
    3.57  
    3.58 -    private static String[][] getNegatedTests() {
    3.59 +    private static String[][] getNegatedTests(boolean timestamp) {
    3.60          String[][] tests = new String[FILES.length][];
    3.61          for (int i = 0; i < FILES.length; i++) {
    3.62              tests[i] = new String[] {
    3.63                  OUTPUT_DIR + FS + FILES[i],
    3.64 -                "Generated by javadoc (version",
    3.65 +                (timestamp
    3.66 +                    ? "Generated by javadoc (version"
    3.67 +                    : "Generated by javadoc ("),
    3.68                  "Generated by javadoc on"
    3.69              };
    3.70          }
    3.71 @@ -88,9 +100,10 @@
    3.72       */
    3.73      public static void main(String[] args) {
    3.74          TestGeneratedBy tester = new TestGeneratedBy();
    3.75 -        int exitCode = run(tester, ARGS, getTests(), getNegatedTests());
    3.76 +        int ec1 = run(tester, STD_ARGS, getTests(true), getNegatedTests(true));
    3.77 +        int ec2 = run(tester, NO_TIMESTAMP_ARGS, getTests(false), getNegatedTests(false));
    3.78          tester.printSummary();
    3.79 -        if (exitCode != 0) {
    3.80 +        if (ec1 != 0 || ec2 != 0) {
    3.81              throw new Error("Error found while executing Javadoc");
    3.82          }
    3.83      }

mercurial