6786682: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - HTML tag should have lang attribute

Thu, 15 Jan 2009 17:21:11 -0800

author
bpatel
date
Thu, 15 Jan 2009 17:21:11 -0800
changeset 191
d79ad96ce47c
parent 187
e157bd68dfc5
child 192
42f9d392159d

6786682: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - HTML tag should have lang attribute
Reviewed-by: jjg

src/share/classes/com/sun/tools/doclets/formats/html/ConfigurationImpl.java file | annotate | diff | comparison | revisions
src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlWriter.java file | annotate | diff | comparison | revisions
src/share/classes/com/sun/tools/doclets/internal/toolkit/Configuration.java file | annotate | diff | comparison | revisions
src/share/classes/com/sun/tools/doclets/internal/toolkit/util/SourceToHTMLConverter.java file | annotate | diff | comparison | revisions
src/share/classes/com/sun/tools/javadoc/RootDocImpl.java file | annotate | diff | comparison | revisions
test/com/sun/javadoc/testHtmlTag/TestHtmlTag.java file | annotate | diff | comparison | revisions
test/com/sun/javadoc/testHtmlTag/pkg1/C1.java file | annotate | diff | comparison | revisions
test/com/sun/javadoc/testHtmlTag/pkg2/C2.java file | annotate | diff | comparison | revisions
     1.1 --- a/src/share/classes/com/sun/tools/doclets/formats/html/ConfigurationImpl.java	Tue Jan 13 13:31:35 2009 +0000
     1.2 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/ConfigurationImpl.java	Thu Jan 15 17:21:11 2009 -0800
     1.3 @@ -493,4 +493,14 @@
     1.4      public Comparator<ProgramElementDoc> getMemberComparator() {
     1.5          return null;
     1.6      }
     1.7 +
     1.8 +    /**
     1.9 +     * {@inheritDoc}
    1.10 +     */
    1.11 +    public Locale getLocale() {
    1.12 +        if (root instanceof com.sun.tools.javadoc.RootDocImpl)
    1.13 +            return ((com.sun.tools.javadoc.RootDocImpl)root).getLocale();
    1.14 +        else
    1.15 +            return Locale.getDefault();
    1.16 +    }
    1.17  }
     2.1 --- a/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlWriter.java	Tue Jan 13 13:31:35 2009 +0000
     2.2 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlWriter.java	Thu Jan 15 17:21:11 2009 -0800
     2.3 @@ -85,7 +85,7 @@
     2.4       * Print &lt;HTML&gt; tag. Add a newline character at the end.
     2.5       */
     2.6      public void html() {
     2.7 -        println("<HTML>");
     2.8 +        println("<HTML lang=\"" + configuration.getLocale().getLanguage() + "\">");
     2.9      }
    2.10  
    2.11      /**
     3.1 --- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/Configuration.java	Tue Jan 13 13:31:35 2009 +0000
     3.2 +++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/Configuration.java	Thu Jan 15 17:21:11 2009 -0800
     3.3 @@ -707,6 +707,11 @@
     3.4      }
     3.5  
     3.6      /**
     3.7 +     * Return the Locale for this document.
     3.8 +     */
     3.9 +    public abstract Locale getLocale();
    3.10 +
    3.11 +    /**
    3.12       * Return the comparator that will be used to sort member documentation.
    3.13       * To no do any sorting, return null.
    3.14       *
     4.1 --- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/SourceToHTMLConverter.java	Tue Jan 13 13:31:35 2009 +0000
     4.2 +++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/SourceToHTMLConverter.java	Thu Jan 15 17:21:11 2009 -0800
     4.3 @@ -142,7 +142,7 @@
     4.4                  reader.close();
     4.5              }
     4.6              output = addLineNumbers(output.toString());
     4.7 -            output.insert(0, getHeader());
     4.8 +            output.insert(0, getHeader(configuration));
     4.9              output.append(getFooter());
    4.10              writeToFile(output.toString(), outputdir, cd.name(), configuration);
    4.11          } catch (Exception e){
    4.12 @@ -192,10 +192,11 @@
    4.13  
    4.14      /**
    4.15       * Get the header.
    4.16 +     * @param configuration the Doclet configuration
    4.17       * @return the header to the output file
    4.18       */
    4.19 -    protected static String getHeader() {
    4.20 -        StringBuffer result = new StringBuffer("<HTML>" + DocletConstants.NL);
    4.21 +    protected static String getHeader(Configuration configuration) {
    4.22 +        StringBuffer result = new StringBuffer("<HTML lang=\"" + configuration.getLocale().getLanguage() + "\">" + DocletConstants.NL);
    4.23          result.append("<BODY BGCOLOR=\""+ BGCOLOR + "\">" + DocletConstants.NL);
    4.24          result.append("<PRE>" + DocletConstants.NL);
    4.25          return result.toString();
     5.1 --- a/src/share/classes/com/sun/tools/javadoc/RootDocImpl.java	Tue Jan 13 13:31:35 2009 +0000
     5.2 +++ b/src/share/classes/com/sun/tools/javadoc/RootDocImpl.java	Thu Jan 15 17:21:11 2009 -0800
     5.3 @@ -36,6 +36,7 @@
     5.4  import com.sun.tools.javac.util.List;
     5.5  import com.sun.tools.javac.util.ListBuffer;
     5.6  import com.sun.tools.javac.util.Position;
     5.7 +import java.util.Locale;
     5.8  
     5.9  /**
    5.10   * This class holds the information from one run of javadoc.
    5.11 @@ -351,4 +352,11 @@
    5.12              null :
    5.13              SourcePositionImpl.make(path, Position.NOPOS, null);
    5.14      }
    5.15 +
    5.16 +    /**
    5.17 +     * Return the locale provided by the user or the default locale value.
    5.18 +     */
    5.19 +    public Locale getLocale() {
    5.20 +        return env.doclocale.locale;
    5.21 +    }
    5.22  }
     6.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.2 +++ b/test/com/sun/javadoc/testHtmlTag/TestHtmlTag.java	Thu Jan 15 17:21:11 2009 -0800
     6.3 @@ -0,0 +1,93 @@
     6.4 +/*
     6.5 + * Copyright 2009 Sun Microsystems, Inc.  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.  Sun designates this
    6.11 + * particular file as subject to the "Classpath" exception as provided
    6.12 + * by Sun in the LICENSE file that accompanied this code.
    6.13 + *
    6.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
    6.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    6.16 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    6.17 + * version 2 for more details (a copy is included in the LICENSE file that
    6.18 + * accompanied this code).
    6.19 + *
    6.20 + * You should have received a copy of the GNU General Public License version
    6.21 + * 2 along with this work; if not, write to the Free Software Foundation,
    6.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    6.23 + *
    6.24 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
    6.25 + * CA 95054 USA or visit www.sun.com if you need additional information or
    6.26 + * have any questions.
    6.27 + */
    6.28 +
    6.29 +/*
    6.30 + * @test
    6.31 + * @bug 6786682
    6.32 + * @summary This test verifies the use of lang attribute by <HTML>.
    6.33 + * @author Bhavesh Patel
    6.34 + * @library ../lib/
    6.35 + * @build JavadocTester
    6.36 + * @build TestHtmlTag
    6.37 + * @run main TestHtmlTag
    6.38 + */
    6.39 +
    6.40 +import java.util.Locale;
    6.41 +
    6.42 +public class TestHtmlTag extends JavadocTester {
    6.43 +
    6.44 +    private static final String BUG_ID = "6786682";
    6.45 +    private static final String[][] TEST1 = {
    6.46 +        {BUG_ID + FS + "pkg1" + FS + "C1.html", "<HTML lang=\"" + Locale.getDefault().getLanguage() + "\">"},
    6.47 +        {BUG_ID + FS + "pkg1" + FS + "package-summary.html", "<HTML lang=\"" + Locale.getDefault().getLanguage() + "\">"}};
    6.48 +    private static final String[][] NEGATED_TEST1 = {
    6.49 +        {BUG_ID + FS + "pkg1" + FS + "C1.html", "<HTML>"}};
    6.50 +    private static final String[][] TEST2 = {
    6.51 +        {BUG_ID + FS + "pkg2" + FS + "C2.html", "<HTML lang=\"ja\">"},
    6.52 +        {BUG_ID + FS + "pkg2" + FS + "package-summary.html", "<HTML lang=\"ja\">"}};
    6.53 +    private static final String[][] NEGATED_TEST2 = {
    6.54 +        {BUG_ID + FS + "pkg2" + FS + "C2.html", "<HTML>"}};
    6.55 +    private static final String[][] TEST3 = {
    6.56 +        {BUG_ID + FS + "pkg1" + FS + "C1.html", "<HTML lang=\"en\">"},
    6.57 +        {BUG_ID + FS + "pkg1" + FS + "package-summary.html", "<HTML lang=\"en\">"}};
    6.58 +    private static final String[][] NEGATED_TEST3 = {
    6.59 +        {BUG_ID + FS + "pkg1" + FS + "C1.html", "<HTML>"}};
    6.60 +
    6.61 +    private static final String[] ARGS1 =
    6.62 +        new String[] {
    6.63 +            "-d", BUG_ID, "-sourcepath", SRC_DIR, "pkg1"};
    6.64 +    private static final String[] ARGS2 =
    6.65 +        new String[] {
    6.66 +            "-locale", "ja", "-d", BUG_ID, "-sourcepath", SRC_DIR, "pkg2"};
    6.67 +    private static final String[] ARGS3 =
    6.68 +        new String[] {
    6.69 +            "-locale", "en_US", "-d", BUG_ID, "-sourcepath", SRC_DIR, "pkg1"};
    6.70 +
    6.71 +    /**
    6.72 +     * The entry point of the test.
    6.73 +     * @param args the array of command line arguments.
    6.74 +     */
    6.75 +    public static void main(String[] args) {
    6.76 +        TestHtmlTag tester = new TestHtmlTag();
    6.77 +        run(tester, ARGS1, TEST1, NEGATED_TEST1);
    6.78 +        run(tester, ARGS2, TEST2, NEGATED_TEST2);
    6.79 +        run(tester, ARGS3, TEST3, NEGATED_TEST3);
    6.80 +        tester.printSummary();
    6.81 +    }
    6.82 +
    6.83 +    /**
    6.84 +     * {@inheritDoc}
    6.85 +     */
    6.86 +    public String getBugId() {
    6.87 +        return BUG_ID;
    6.88 +    }
    6.89 +
    6.90 +    /**
    6.91 +     * {@inheritDoc}
    6.92 +     */
    6.93 +    public String getBugName() {
    6.94 +        return getClass().getName();
    6.95 +    }
    6.96 +}
     7.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     7.2 +++ b/test/com/sun/javadoc/testHtmlTag/pkg1/C1.java	Thu Jan 15 17:21:11 2009 -0800
     7.3 @@ -0,0 +1,33 @@
     7.4 +/*
     7.5 + * Copyright 2009 Sun Microsystems, Inc.  All Rights Reserved.
     7.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     7.7 + *
     7.8 + * This code is free software; you can redistribute it and/or modify it
     7.9 + * under the terms of the GNU General Public License version 2 only, as
    7.10 + * published by the Free Software Foundation.  Sun designates this
    7.11 + * particular file as subject to the "Classpath" exception as provided
    7.12 + * by Sun in the LICENSE file that accompanied this code.
    7.13 + *
    7.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
    7.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    7.16 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    7.17 + * version 2 for more details (a copy is included in the LICENSE file that
    7.18 + * accompanied this code).
    7.19 + *
    7.20 + * You should have received a copy of the GNU General Public License version
    7.21 + * 2 along with this work; if not, write to the Free Software Foundation,
    7.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    7.23 + *
    7.24 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
    7.25 + * CA 95054 USA or visit www.sun.com if you need additional information or
    7.26 + * have any questions.
    7.27 + */
    7.28 +
    7.29 +package pkg1;
    7.30 +
    7.31 +public class C1 {
    7.32 +
    7.33 +    public void method(int param1, int param2) {
    7.34 +
    7.35 +    }
    7.36 +}
     8.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     8.2 +++ b/test/com/sun/javadoc/testHtmlTag/pkg2/C2.java	Thu Jan 15 17:21:11 2009 -0800
     8.3 @@ -0,0 +1,31 @@
     8.4 +/*
     8.5 + * Copyright 2009 Sun Microsystems, Inc.  All Rights Reserved.
     8.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     8.7 + *
     8.8 + * This code is free software; you can redistribute it and/or modify it
     8.9 + * under the terms of the GNU General Public License version 2 only, as
    8.10 + * published by the Free Software Foundation.  Sun designates this
    8.11 + * particular file as subject to the "Classpath" exception as provided
    8.12 + * by Sun in the LICENSE file that accompanied this code.
    8.13 + *
    8.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
    8.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    8.16 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    8.17 + * version 2 for more details (a copy is included in the LICENSE file that
    8.18 + * accompanied this code).
    8.19 + *
    8.20 + * You should have received a copy of the GNU General Public License version
    8.21 + * 2 along with this work; if not, write to the Free Software Foundation,
    8.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    8.23 + *
    8.24 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
    8.25 + * CA 95054 USA or visit www.sun.com if you need additional information or
    8.26 + * have any questions.
    8.27 + */
    8.28 +
    8.29 +package pkg2;
    8.30 +
    8.31 +/**
    8.32 + * <B>Comments:</B> Class 2
    8.33 + */
    8.34 +public class C2 {}

mercurial