6553182: Need to modify javadoc doclet for GPL
Reviewed-by: jjg
This commit is contained in:
parent
fbecf91f80
commit
a2642b89a7
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1998, 2009, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -31,6 +31,7 @@ import com.sun.tools.doclets.internal.toolkit.util.*;
|
||||
import com.sun.javadoc.*;
|
||||
import java.util.*;
|
||||
import java.io.*;
|
||||
import java.net.*;
|
||||
|
||||
/**
|
||||
* Configure the output based on the command line options.
|
||||
@ -48,6 +49,7 @@ import java.io.*;
|
||||
* @author Robert Field.
|
||||
* @author Atul Dambalkar.
|
||||
* @author Jamie Ho
|
||||
* @author Bhavesh Patel (Modified)
|
||||
*/
|
||||
public class ConfigurationImpl extends Configuration {
|
||||
|
||||
@ -109,6 +111,11 @@ public class ConfigurationImpl extends Configuration {
|
||||
*/
|
||||
public String stylesheetfile = "";
|
||||
|
||||
/**
|
||||
* Argument for command line option "-Xdocrootparent".
|
||||
*/
|
||||
public String docrootparent = "";
|
||||
|
||||
/**
|
||||
* True if command line option "-nohelp" is used. Default value is false.
|
||||
*/
|
||||
@ -239,6 +246,8 @@ public class ConfigurationImpl extends Configuration {
|
||||
stylesheetfile = os[1];
|
||||
} else if (opt.equals("-charset")) {
|
||||
charset = os[1];
|
||||
} else if (opt.equals("-xdocrootparent")) {
|
||||
docrootparent = os[1];
|
||||
} else if (opt.equals("-nohelp")) {
|
||||
nohelp = true;
|
||||
} else if (opt.equals("-splitindex")) {
|
||||
@ -322,7 +331,8 @@ public class ConfigurationImpl extends Configuration {
|
||||
option.equals("-helpfile") ||
|
||||
option.equals("-stylesheetfile") ||
|
||||
option.equals("-charset") ||
|
||||
option.equals("-overview")) {
|
||||
option.equals("-overview") ||
|
||||
option.equals("-xdocrootparent")) {
|
||||
return 2;
|
||||
} else {
|
||||
return 0;
|
||||
@ -372,6 +382,13 @@ public class ConfigurationImpl extends Configuration {
|
||||
return false;
|
||||
}
|
||||
nohelp = true;
|
||||
} else if (opt.equals("-xdocrootparent")) {
|
||||
try {
|
||||
new URL(os[1]);
|
||||
} catch (MalformedURLException e) {
|
||||
reporter.printError(getText("doclet.MalformedURL", os[1]));
|
||||
return false;
|
||||
}
|
||||
} else if (opt.equals("-overview")) {
|
||||
if (nooverview == true) {
|
||||
reporter.printError(getText("doclet.Option_conflict",
|
||||
|
@ -159,6 +159,25 @@ public class HtmlDocletWriter extends HtmlDocWriter {
|
||||
StringBuilder buf = new StringBuilder();
|
||||
int previndex = 0;
|
||||
while (true) {
|
||||
if (configuration.docrootparent.length() > 0) {
|
||||
// Search for lowercase version of {@docRoot}/..
|
||||
index = lowerHtml.indexOf("{@docroot}/..", previndex);
|
||||
// If next {@docRoot}/.. pattern not found, append rest of htmlstr and exit loop
|
||||
if (index < 0) {
|
||||
buf.append(htmlstr.substring(previndex));
|
||||
break;
|
||||
}
|
||||
// If next {@docroot}/.. pattern found, append htmlstr up to start of tag
|
||||
buf.append(htmlstr.substring(previndex, index));
|
||||
previndex = index + 13; // length for {@docroot}/.. string
|
||||
// Insert docrootparent absolute path where {@docRoot}/.. was located
|
||||
|
||||
buf.append(configuration.docrootparent);
|
||||
// Append slash if next character is not a slash
|
||||
if (previndex < htmlstr.length() && htmlstr.charAt(previndex) != '/') {
|
||||
buf.append(DirectoryManager.URL_FILE_SEPARATOR);
|
||||
}
|
||||
} else {
|
||||
// Search for lowercase version of {@docRoot}
|
||||
index = lowerHtml.indexOf("{@docroot}", previndex);
|
||||
// If next {@docRoot} tag not found, append rest of htmlstr and exit loop
|
||||
@ -172,11 +191,12 @@ public class HtmlDocletWriter extends HtmlDocWriter {
|
||||
// Insert relative path where {@docRoot} was located
|
||||
buf.append(relativepathNoSlash);
|
||||
// Append slash if next character is not a slash
|
||||
if (relativepathNoSlash.length() > 0 && previndex < htmlstr.length()
|
||||
&& htmlstr.charAt(previndex) != '/') {
|
||||
if (relativepathNoSlash.length() > 0 && previndex < htmlstr.length() &&
|
||||
htmlstr.charAt(previndex) != '/') {
|
||||
buf.append(DirectoryManager.URL_FILE_SEPARATOR);
|
||||
}
|
||||
}
|
||||
}
|
||||
return buf.toString();
|
||||
}
|
||||
|
||||
@ -2318,6 +2338,7 @@ public class HtmlDocletWriter extends HtmlDocWriter {
|
||||
public String commentTagsToString(Tag holderTag, Doc doc, Tag[] tags,
|
||||
boolean isFirstSentence) {
|
||||
StringBuilder result = new StringBuilder();
|
||||
boolean textTagChange = false;
|
||||
// Array of all possible inline tags for this javadoc run
|
||||
configuration.tagletManager.checkTags(doc, tags, true);
|
||||
for (int i = 0; i < tags.length; i++) {
|
||||
@ -2333,13 +2354,26 @@ public class HtmlDocletWriter extends HtmlDocWriter {
|
||||
result.append(output == null ? "" : output.toString());
|
||||
if (originalLength == 0 && isFirstSentence && tagelem.name().equals("@inheritDoc") && result.length() > 0) {
|
||||
break;
|
||||
} else if (configuration.docrootparent.length() > 0 &&
|
||||
tagelem.name().equals("@docRoot") &&
|
||||
((tags[i + 1]).text()).startsWith("/..")) {
|
||||
//If Xdocrootparent switch ON, set the flag to remove the /.. occurance after
|
||||
//{@docRoot} tag in the very next Text tag.
|
||||
textTagChange = true;
|
||||
continue;
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
String text = tagelem.text();
|
||||
//If Xdocrootparent switch ON, remove the /.. occurance after {@docRoot} tag.
|
||||
if (textTagChange) {
|
||||
text = text.replaceFirst("/..", "");
|
||||
textTagChange = false;
|
||||
}
|
||||
//This is just a regular text tag. The text may contain html links (<a>)
|
||||
//or inline tag {@docRoot}, which will be handled as special cases.
|
||||
String text = redirectRelativeLinks(tagelem.holder(), tagelem.text());
|
||||
text = redirectRelativeLinks(tagelem.holder(), text);
|
||||
|
||||
// Replace @docRoot only if not represented by an instance of DocRootTaglet,
|
||||
// that is, only if it was not present in a source file doc comment.
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -59,6 +59,9 @@ public class TagletWriterImpl extends TagletWriter {
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public TagletOutput getDocRootOutput() {
|
||||
if (htmlWriter.configuration.docrootparent.length() > 0)
|
||||
return new TagletOutputImpl(htmlWriter.configuration.docrootparent);
|
||||
else
|
||||
return new TagletOutputImpl(htmlWriter.relativepathNoSlash);
|
||||
}
|
||||
|
||||
|
@ -247,6 +247,7 @@ doclet.usage=Provided by Standard doclet:\n\
|
||||
-tag <name>:<locations>:<header> Specify single argument custom tags\n\
|
||||
-taglet The fully qualified name of Taglet to register\n\
|
||||
-tagletpath The path to Taglets\n\
|
||||
-Xdocrootparent <url> Replaces all appearances of @docRoot followed by /.. in doc comments with <url>\n\
|
||||
-charset <charset> Charset for cross-platform viewing of generated documentation.\n\
|
||||
-helpfile <file> Include file that help link links to\n\
|
||||
-linksource Generate source in HTML\n\
|
||||
|
@ -0,0 +1,101 @@
|
||||
/*
|
||||
* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 6553182
|
||||
* @summary This test verifies the -Xdocrootparent option.
|
||||
* @author Bhavesh Patel
|
||||
* @library ../lib/
|
||||
* @build JavadocTester TestDocRootLink
|
||||
* @run main TestDocRootLink
|
||||
*/
|
||||
public class TestDocRootLink extends JavadocTester {
|
||||
|
||||
private static final String BUG_ID = "6553182";
|
||||
private static final String[][] TEST1 = {
|
||||
{BUG_ID + FS + "pkg1" + FS + "C1.html",
|
||||
"<a href=\"../../technotes/guides/index.html\">"
|
||||
},
|
||||
{BUG_ID + FS + "pkg1" + FS + "package-summary.html",
|
||||
"<a href=\"../../technotes/guides/index.html\">"
|
||||
}
|
||||
};
|
||||
private static final String[][] NEGATED_TEST1 = {
|
||||
{BUG_ID + FS + "pkg1" + FS + "C1.html",
|
||||
"<a href=\"http://download.oracle.com/javase/7/docs/technotes/guides/index.html\">"
|
||||
},
|
||||
{BUG_ID + FS + "pkg1" + FS + "package-summary.html",
|
||||
"<a href=\"http://download.oracle.com/javase/7/docs/technotes/guides/index.html\">"
|
||||
}
|
||||
};
|
||||
private static final String[][] TEST2 = {
|
||||
{BUG_ID + FS + "pkg2" + FS + "C2.html",
|
||||
"<a href=\"http://download.oracle.com/javase/7/docs/technotes/guides/index.html\">"
|
||||
},
|
||||
{BUG_ID + FS + "pkg2" + FS + "package-summary.html",
|
||||
"<a href=\"http://download.oracle.com/javase/7/docs/technotes/guides/index.html\">"
|
||||
}
|
||||
};
|
||||
private static final String[][] NEGATED_TEST2 = {
|
||||
{BUG_ID + FS + "pkg2" + FS + "C2.html",
|
||||
"<a href=\"../../technotes/guides/index.html\">"
|
||||
},
|
||||
{BUG_ID + FS + "pkg2" + FS + "package-summary.html",
|
||||
"<a href=\"../../technotes/guides/index.html\">"
|
||||
}
|
||||
};
|
||||
private static final String[] ARGS1 =
|
||||
new String[]{
|
||||
"-d", BUG_ID, "-sourcepath", SRC_DIR, "pkg1"
|
||||
};
|
||||
private static final String[] ARGS2 =
|
||||
new String[]{
|
||||
"-d", BUG_ID, "-Xdocrootparent", "http://download.oracle.com/javase/7/docs", "-sourcepath", SRC_DIR, "pkg2"
|
||||
};
|
||||
|
||||
/**
|
||||
* The entry point of the test.
|
||||
* @param args the array of command line arguments.
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
TestDocRootLink tester = new TestDocRootLink();
|
||||
run(tester, ARGS1, TEST1, NEGATED_TEST1);
|
||||
run(tester, ARGS2, TEST2, NEGATED_TEST2);
|
||||
tester.printSummary();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public String getBugId() {
|
||||
return BUG_ID;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public String getBugName() {
|
||||
return getClass().getName();
|
||||
}
|
||||
}
|
31
langtools/test/com/sun/javadoc/testDocRootLink/pkg1/C1.java
Normal file
31
langtools/test/com/sun/javadoc/testDocRootLink/pkg1/C1.java
Normal file
@ -0,0 +1,31 @@
|
||||
/*
|
||||
* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package pkg1;
|
||||
|
||||
/**
|
||||
* Class 1. This is a test.
|
||||
* Refer <a href="{@docRoot}/../technotes/guides/index.html">Here</a>. Lets see if this works
|
||||
* or not.
|
||||
*/
|
||||
public class C1 {}
|
@ -0,0 +1,18 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>javax.management package</title>
|
||||
</head>
|
||||
<body bgcolor="white">
|
||||
This is a test.
|
||||
<p id="spec">
|
||||
@see <a href="{@docRoot}/../technotes/guides/index.html">
|
||||
Test document 1</a>
|
||||
in particular the
|
||||
<a href="{@docRoot}/../technotes/guides/index.html">
|
||||
|
||||
Test document 2.</a>
|
||||
|
||||
@since 1.5
|
||||
|
||||
</body>
|
||||
</html>
|
31
langtools/test/com/sun/javadoc/testDocRootLink/pkg2/C2.java
Normal file
31
langtools/test/com/sun/javadoc/testDocRootLink/pkg2/C2.java
Normal file
@ -0,0 +1,31 @@
|
||||
/*
|
||||
* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package pkg2;
|
||||
|
||||
/**
|
||||
* Class 1. This is a test.
|
||||
* Refer <a href="{@docRoot}/../technotes/guides/index.html">Here</a>. Lets see if this works
|
||||
* or not.
|
||||
*/
|
||||
public class C2 {}
|
@ -0,0 +1,18 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>javax.management package</title>
|
||||
</head>
|
||||
<body bgcolor="white">
|
||||
This is a test.
|
||||
<p id="spec">
|
||||
@see <a href="{@docRoot}/../technotes/guides/index.html">
|
||||
Test document 1</a>
|
||||
in particular the
|
||||
<a href="{@docRoot}/../technotes/guides/index.html">
|
||||
|
||||
Test document 2.</a>
|
||||
|
||||
@since 1.5
|
||||
|
||||
</body>
|
||||
</html>
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -23,20 +23,19 @@
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 4934778 4777599
|
||||
* @bug 4934778 4777599 6553182
|
||||
* @summary Make sure that the -help option works properly. Make sure
|
||||
* the help link appears in the documentation.
|
||||
* @author jamieh
|
||||
* @library ../lib/
|
||||
* @build JavadocTester
|
||||
* @build TestHelpOption
|
||||
* @build JavadocTester TestHelpOption
|
||||
* @run main TestHelpOption
|
||||
*/
|
||||
|
||||
public class TestHelpOption extends JavadocTester {
|
||||
|
||||
//Test information.
|
||||
private static final String BUG_ID = "4934778-4777599";
|
||||
private static final String BUG_ID = "4934778-4777599-6553182";
|
||||
|
||||
//Javadoc arguments.
|
||||
private static final String[] ARGS = new String[] {
|
||||
@ -79,6 +78,7 @@ public class TestHelpOption extends JavadocTester {
|
||||
{STANDARD_OUTPUT, "-tag "},
|
||||
{STANDARD_OUTPUT, "-taglet "},
|
||||
{STANDARD_OUTPUT, "-tagletpath "},
|
||||
{STANDARD_OUTPUT, "-Xdocrootparent "},
|
||||
{STANDARD_OUTPUT, "-charset "},
|
||||
{STANDARD_OUTPUT, "-helpfile "},
|
||||
{STANDARD_OUTPUT, "-linksource "},
|
||||
|
Loading…
x
Reference in New Issue
Block a user