8000418: javadoc should used a standard "generated by javadoc" string

Wed, 10 Oct 2012 18:34:46 -0700

author
jjg
date
Wed, 10 Oct 2012 18:34:46 -0700
changeset 1361
6517bf8e50d0
parent 1360
560d4a5d14e6
child 1362
c46e0c9940d6

8000418: javadoc should used a standard "generated by javadoc" string
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/SerializedFormWriterImpl.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/VersionNumber/VersionNumber.java file | annotate | diff | comparison | revisions
test/com/sun/javadoc/testGeneratedBy/TestGeneratedBy.java file | annotate | diff | comparison | revisions
test/com/sun/javadoc/testGeneratedBy/pkg/MyClass.java file | annotate | diff | comparison | revisions
     1.1 --- a/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDocletWriter.java	Wed Oct 10 18:08:19 2012 -0700
     1.2 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDocletWriter.java	Wed Oct 10 18:34:46 2012 -0700
     1.3 @@ -351,66 +351,6 @@
     1.4      }
     1.5  
     1.6      /**
     1.7 -     * Print the html file header. Also print Html page title and stylesheet
     1.8 -     * default properties.
     1.9 -     *
    1.10 -     * @param title         String window title to go in the <TITLE> tag
    1.11 -     * @param metakeywords  Array of String keywords for META tag.  Each element
    1.12 -     *                      of the array is assigned to a separate META tag.
    1.13 -     *                      Pass in null for no array.
    1.14 -     * @param includeScript boolean true if printing windowtitle script.
    1.15 -     *             False for files that appear in the left-hand frames.
    1.16 -     */
    1.17 -    public void printHtmlHeader(String title, String[] metakeywords,
    1.18 -            boolean includeScript) {
    1.19 -        println("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 " +
    1.20 -                    "Transitional//EN\" " +
    1.21 -                    "\"http://www.w3.org/TR/html4/loose.dtd\">");
    1.22 -        println("<!--NewPage-->");
    1.23 -        html();
    1.24 -        head();
    1.25 -        if (! configuration.notimestamp) {
    1.26 -            print("<!-- Generated by javadoc (build " + ConfigurationImpl.BUILD_DATE + ") on ");
    1.27 -            print(today());
    1.28 -            println(" -->");
    1.29 -        }
    1.30 -        if (configuration.charset.length() > 0) {
    1.31 -            println("<META http-equiv=\"Content-Type\" content=\"text/html; "
    1.32 -                        + "charset=" + configuration.charset + "\">");
    1.33 -        }
    1.34 -        if ( configuration.windowtitle.length() > 0 ) {
    1.35 -            title += " (" + configuration.windowtitle  + ")";
    1.36 -        }
    1.37 -        title(title);
    1.38 -        println(title);
    1.39 -        titleEnd();
    1.40 -        println("");
    1.41 -        if (! configuration.notimestamp) {
    1.42 -                SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
    1.43 -                println("<META NAME=\"date\" "
    1.44 -                                    + "CONTENT=\"" + dateFormat.format(new Date()) + "\">");
    1.45 -        }
    1.46 -        if ( metakeywords != null ) {
    1.47 -            for ( int i=0; i < metakeywords.length; i++ ) {
    1.48 -                println("<META NAME=\"keywords\" "
    1.49 -                            + "CONTENT=\"" + metakeywords[i] + "\">");
    1.50 -            }
    1.51 -        }
    1.52 -        println("");
    1.53 -        printStyleSheetProperties();
    1.54 -        println("");
    1.55 -        // Don't print windowtitle script for overview-frame, allclasses-frame
    1.56 -        // and package-frame
    1.57 -        if (includeScript) {
    1.58 -            printWinTitleScript(title);
    1.59 -        }
    1.60 -        println("");
    1.61 -        headEnd();
    1.62 -        println("");
    1.63 -        body("white", includeScript);
    1.64 -    }
    1.65 -
    1.66 -    /**
    1.67       * Generates the HTML document tree and prints it out.
    1.68       *
    1.69       * @param metakeywords Array of String keywords for META tag. Each element
    1.70 @@ -426,8 +366,7 @@
    1.71          Content htmlComment = new Comment(configuration.getText("doclet.New_Page"));
    1.72          Content head = new HtmlTree(HtmlTag.HEAD);
    1.73          if (!configuration.notimestamp) {
    1.74 -            Content headComment = new Comment("Generated by javadoc (version " +
    1.75 -                    ConfigurationImpl.BUILD_DATE + ") on " + today());
    1.76 +            Content headComment = new Comment(getGeneratedByString());
    1.77              head.addContent(headComment);
    1.78          }
    1.79          if (configuration.charset.length() > 0) {
     2.1 --- a/src/share/classes/com/sun/tools/doclets/formats/html/SerializedFormWriterImpl.java	Wed Oct 10 18:08:19 2012 -0700
     2.2 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/SerializedFormWriterImpl.java	Wed Oct 10 18:34:46 2012 -0700
     2.3 @@ -55,23 +55,6 @@
     2.4      }
     2.5  
     2.6      /**
     2.7 -     * Writes the given header.
     2.8 -     *
     2.9 -     * @param header the header to write.
    2.10 -     */
    2.11 -    public void writeHeader(String header) {
    2.12 -        printHtmlHeader(header, null, true);
    2.13 -        printTop();
    2.14 -        navLinks(true);
    2.15 -        hr();
    2.16 -        center();
    2.17 -        h1();
    2.18 -        print(header);
    2.19 -        h1End();
    2.20 -        centerEnd();
    2.21 -    }
    2.22 -
    2.23 -    /**
    2.24       * Get the given header.
    2.25       *
    2.26       * @param header the header to write
     3.1 --- a/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlDocWriter.java	Wed Oct 10 18:08:19 2012 -0700
     3.2 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlDocWriter.java	Wed Oct 10 18:34:46 2012 -0700
     3.3 @@ -29,6 +29,7 @@
     3.4  import java.util.*;
     3.5  
     3.6  import com.sun.javadoc.*;
     3.7 +import com.sun.tools.doclets.formats.html.ConfigurationImpl;
     3.8  import com.sun.tools.doclets.internal.toolkit.*;
     3.9  
    3.10  
    3.11 @@ -329,7 +330,7 @@
    3.12          Content htmlComment = new Comment(configuration.getText("doclet.New_Page"));
    3.13          Content head = new HtmlTree(HtmlTag.HEAD);
    3.14          if (! noTimeStamp) {
    3.15 -            Content headComment = new Comment("Generated by javadoc on " + today());
    3.16 +            Content headComment = new Comment(getGeneratedByString());
    3.17              head.addContent(headComment);
    3.18          }
    3.19          if (configuration.charset.length() > 0) {
    3.20 @@ -391,16 +392,9 @@
    3.21          print("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");
    3.22      }
    3.23  
    3.24 -    /**
    3.25 -     * Get the day and date information for today, depending upon user option.
    3.26 -     *
    3.27 -     * @return String Today.
    3.28 -     * @see java.util.Calendar
    3.29 -     * @see java.util.GregorianCalendar
    3.30 -     * @see java.util.TimeZone
    3.31 -     */
    3.32 -    public String today() {
    3.33 +    protected String getGeneratedByString() {
    3.34          Calendar calendar = new GregorianCalendar(TimeZone.getDefault());
    3.35 -        return calendar.getTime().toString();
    3.36 +        Date today = calendar.getTime();
    3.37 +        return "Generated by javadoc ("+ ConfigurationImpl.BUILD_DATE + ") on " + today;
    3.38      }
    3.39  }
     4.1 --- a/test/com/sun/javadoc/VersionNumber/VersionNumber.java	Wed Oct 10 18:08:19 2012 -0700
     4.2 +++ b/test/com/sun/javadoc/VersionNumber/VersionNumber.java	Wed Oct 10 18:34:46 2012 -0700
     4.3 @@ -1,5 +1,5 @@
     4.4  /*
     4.5 - * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved.
     4.6 + * Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved.
     4.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4.8   *
     4.9   * This code is free software; you can redistribute it and/or modify it
    4.10 @@ -84,7 +84,7 @@
    4.11  
    4.12              // Test the proper DOCTYPE element is present:
    4.13              {
    4.14 -                 "<!-- Generated by javadoc (version",
    4.15 +                 "<!-- Generated by javadoc (",
    4.16                       TMPDEST_DIR1 + "p1" + FS + "C.html"  },
    4.17  
    4.18          };
     5.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.2 +++ b/test/com/sun/javadoc/testGeneratedBy/TestGeneratedBy.java	Wed Oct 10 18:34:46 2012 -0700
     5.3 @@ -0,0 +1,112 @@
     5.4 +/*
     5.5 + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
     5.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     5.7 + *
     5.8 + * This code is free software; you can redistribute it and/or modify it
     5.9 + * under the terms of the GNU General Public License version 2 only, as
    5.10 + * published by the Free Software Foundation.
    5.11 + *
    5.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
    5.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    5.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    5.15 + * version 2 for more details (a copy is included in the LICENSE file that
    5.16 + * accompanied this code).
    5.17 + *
    5.18 + * You should have received a copy of the GNU General Public License version
    5.19 + * 2 along with this work; if not, write to the Free Software Foundation,
    5.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    5.21 + *
    5.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    5.23 + * or visit www.oracle.com if you need additional information or have any
    5.24 + * questions.
    5.25 + */
    5.26 +
    5.27 +/*
    5.28 + * @test
    5.29 + * @bug 8000418
    5.30 + * @summary Verify that files use a common Generated By string
    5.31 + * @library ../lib/
    5.32 + * @build JavadocTester TestGeneratedBy
    5.33 + * @run main TestGeneratedBy
    5.34 + */
    5.35 +
    5.36 +public class TestGeneratedBy extends JavadocTester {
    5.37 +
    5.38 +    private static final String OUTPUT_DIR = "tmp";
    5.39 +
    5.40 +    private static final String[] FILES = {
    5.41 +        "pkg/MyClass.html",
    5.42 +        "pkg/package-summary.html",
    5.43 +        "pkg/package-frame.html",
    5.44 +        "pkg/package-tree.html",
    5.45 +        "allclasses-noframe.html",
    5.46 +        "constant-values.html",
    5.47 +        "allclasses-frame.html",
    5.48 +        "overview-tree.html",
    5.49 +        "deprecated-list.html",
    5.50 +        "serialized-form.html",
    5.51 +        "help-doc.html",
    5.52 +        "index-all.html",
    5.53 +        "index.html"
    5.54 +    };
    5.55 +
    5.56 +    private static final String[] ARGS =
    5.57 +        new String[] {
    5.58 +            "-d", OUTPUT_DIR,
    5.59 +            "-sourcepath", SRC_DIR,
    5.60 +            "pkg"
    5.61 +        };
    5.62 +    private static final String BUG_ID = "8000418";
    5.63 +
    5.64 +    private static String[][] getTests() {
    5.65 +        String version = System.getProperty("java.version");
    5.66 +        String[][] tests = new String[FILES.length][];
    5.67 +        for (int i = 0; i < FILES.length; i++) {
    5.68 +            tests[i] = new String[] {
    5.69 +                OUTPUT_DIR + FS + FILES[i],
    5.70 +                "Generated by javadoc (" + version + ") on "
    5.71 +            };
    5.72 +        }
    5.73 +        return tests;
    5.74 +    }
    5.75 +
    5.76 +    private static String[][] getNegatedTests() {
    5.77 +        String[][] tests = new String[FILES.length][];
    5.78 +        for (int i = 0; i < FILES.length; i++) {
    5.79 +            tests[i] = new String[] {
    5.80 +                OUTPUT_DIR + FS + FILES[i],
    5.81 +                "Generated by javadoc (version",
    5.82 +                "Generated by javadoc on"
    5.83 +            };
    5.84 +        }
    5.85 +        return tests;
    5.86 +    }
    5.87 +
    5.88 +    /**
    5.89 +     * The entry point of the test.
    5.90 +     * @param args the array of command line arguments.
    5.91 +     */
    5.92 +    public static void main(String[] args) {
    5.93 +        TestGeneratedBy tester = new TestGeneratedBy();
    5.94 +        int exitCode = run(tester, ARGS, getTests(), getNegatedTests());
    5.95 +        tester.printSummary();
    5.96 +        if (exitCode != 0) {
    5.97 +            throw new Error("Error found while executing Javadoc");
    5.98 +        }
    5.99 +    }
   5.100 +
   5.101 +    /**
   5.102 +     * {@inheritDoc}
   5.103 +     */
   5.104 +    public String getBugId() {
   5.105 +        return BUG_ID;
   5.106 +    }
   5.107 +
   5.108 +    /**
   5.109 +     * {@inheritDoc}
   5.110 +     */
   5.111 +    public String getBugName() {
   5.112 +        return getClass().getName();
   5.113 +    }
   5.114 +}
   5.115 +
     6.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.2 +++ b/test/com/sun/javadoc/testGeneratedBy/pkg/MyClass.java	Wed Oct 10 18:34:46 2012 -0700
     6.3 @@ -0,0 +1,29 @@
     6.4 +/*
     6.5 + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
     6.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     6.7 + *
     6.8 + * This code is free software; you can redistribute it and/or modify it
     6.9 + * under the terms of the GNU General Public License version 2 only, as
    6.10 + * published by the Free Software Foundation.
    6.11 + *
    6.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
    6.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    6.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    6.15 + * version 2 for more details (a copy is included in the LICENSE file that
    6.16 + * accompanied this code).
    6.17 + *
    6.18 + * You should have received a copy of the GNU General Public License version
    6.19 + * 2 along with this work; if not, write to the Free Software Foundation,
    6.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    6.21 + *
    6.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    6.23 + * or visit www.oracle.com if you need additional information or have any
    6.24 + * questions.
    6.25 + */
    6.26 +
    6.27 +package pkg;
    6.28 +
    6.29 +import java.io.Serializable;
    6.30 +
    6.31 +public class MyClass implements Serializable {
    6.32 +}

mercurial