From dcb310be2aae4bf9507575eee4d5c97699d1eab3 Mon Sep 17 00:00:00 2001 From: Dirk Dougherty Date: Wed, 12 Jul 2017 22:29:11 -0700 Subject: Merge in some android customizations. Minor cleanup. Required to generate API diffs for platform SDK and Support Lib. Test: ./gradlew generateDiffs for Support Library Change-Id: Id00a3b420214057e9b2b0f51007a5f26f4b0fb3a --- src/api.xsd | 3 +- src/jdiff/API.java | 16 +- src/jdiff/APIComparator.java | 18 +- src/jdiff/Comments.java | 8 +- src/jdiff/CommentsHandler.java | 4 +- src/jdiff/ConstructorAPI.java | 5 +- src/jdiff/Diff.java | 20 +- src/jdiff/HTMLFiles.java | 192 +++++------ src/jdiff/HTMLIndexes.java | 79 +++-- src/jdiff/HTMLReportGenerator.java | 647 ++++++++++++++----------------------- src/jdiff/HTMLStatistics.java | 215 ++++++------ src/jdiff/JDiff.java | 6 +- src/jdiff/MergeChanges.java | 12 +- src/jdiff/RootDocToXML.java | 32 +- src/jdiff/XMLToAPI.java | 6 +- 15 files changed, 530 insertions(+), 733 deletions(-) diff --git a/src/api.xsd b/src/api.xsd index bb2368f..de8a301 100755 --- a/src/api.xsd +++ b/src/api.xsd @@ -52,6 +52,7 @@ + @@ -76,7 +77,7 @@ - + diff --git a/src/jdiff/API.java b/src/jdiff/API.java index 800e752..b5cb8e2 100755 --- a/src/jdiff/API.java +++ b/src/jdiff/API.java @@ -4,23 +4,23 @@ import java.io.*; import java.util.*; /** - * The internal representation of an API. - * - * RootDoc could have been used for representing this, but + * The internal representation of an API. + * + * RootDoc could have been used for representing this, but * you cannot serialize a RootDoc object - see - * http://developer.java.sun.com/developer/bugParade/bugs/4125581.html - * You might be able use Javadoc.Main() to create another RootDoc, but the + * https://developer.java.sun.com/developer/bugParade/bugs/4125581.html + * You might be able use Javadoc.Main() to create another RootDoc, but the * methods are package private. You can run javadoc in J2SE1.4, see: - * http://java.sun.com/j2se/1.4/docs/tooldocs/javadoc/standard-doclet.html#runningprogrammatically + * https://java.sun.com/j2se/1.4/docs/tooldocs/javadoc/standard-doclet.html#runningprogrammatically * but you still can't get the RootDoc object. * * The advantage of writing out an XML representation of each API is that * later runs of JDiff don't have to have Javadoc scan all the files again, - * a possibly lengthy process. XML also permits other source code in + * a possibly lengthy process. XML also permits other source code in * languages other than Java to be scanned to produce XML, and then versions * of JDiff can be used to create documents describing the difference in those * APIs. - * + * * See the file LICENSE.txt for copyright details. * @author Matthew Doar, mdoar@pobox.com */ diff --git a/src/jdiff/APIComparator.java b/src/jdiff/APIComparator.java index c877785..b79c829 100755 --- a/src/jdiff/APIComparator.java +++ b/src/jdiff/APIComparator.java @@ -862,17 +862,17 @@ public class APIComparator { return linkToClass(m.inheritedFrom_, m.name_, null, useNew); } - /** + /** * Given the name of the class, generate a link to a relevant page. - * This was originally for inheritance changes, so the JDiff page could - * be a class changes page, or a section in a removed or added classes + * This was originally for inheritance changes, so the JDiff page could + * be a class changes page, or a section in a removed or added classes. * table. Since there was no easy way to tell which type the link * should be, it is now just a link to the relevant Javadoc page. */ public static String linkToClass(String className, String memberName, String memberType, boolean useNew) { if (!useNew && HTMLReportGenerator.oldDocPrefix == null) { - return "" + className + ""; // No link possible + return "" + className + ""; // No link possible } API api = oldAPI_; String prefix = HTMLReportGenerator.oldDocPrefix; @@ -886,7 +886,7 @@ public class APIComparator { System.out.println("Warning: class " + className + " not found in the new API when creating Javadoc link"); else System.out.println("Warning: class " + className + " not found in the old API when creating Javadoc link"); - return "" + className + ""; + return "" + className + ""; } int clsIdx = className.indexOf(cls.name_); if (clsIdx != -1) { @@ -895,13 +895,13 @@ public class APIComparator { String res = "" + "" + cls.name_ + ""; + res += "\" target=\"_top\">" + "" + cls.name_ + ""; return res; } - return "" + className + ""; - } + return "" + className + ""; + } - /** + /** * Return the number of methods which are locally defined. */ public int numLocalMethods(List methods) { diff --git a/src/jdiff/Comments.java b/src/jdiff/Comments.java index b732596..0ead7ee 100755 --- a/src/jdiff/Comments.java +++ b/src/jdiff/Comments.java @@ -73,9 +73,9 @@ public class Comments { } if (XMLToAPI.validateXML) { - parser.setFeature("http://xml.org/sax/features/namespaces", true); - parser.setFeature("http://xml.org/sax/features/validation", true); - parser.setFeature("http://apache.org/xml/features/validation/schema", true); + parser.setFeature("https://xml.org/sax/features/namespaces", true); + parser.setFeature("https://xml.org/sax/features/validation", true); + parser.setFeature("https://apache.org/xml/features/validation/schema", true); } parser.setContentHandler(handler); parser.setErrorHandler(handler); @@ -125,7 +125,7 @@ public class Comments { PrintWriter xsdFile = new PrintWriter(fos); // The contents of the comments.xsd file xsdFile.println(""); - xsdFile.println(""); + xsdFile.println(""); xsdFile.println(); xsdFile.println(""); xsdFile.println(" "); diff --git a/src/jdiff/CommentsHandler.java b/src/jdiff/CommentsHandler.java index 8061fbe..9872cb7 100755 --- a/src/jdiff/CommentsHandler.java +++ b/src/jdiff/CommentsHandler.java @@ -17,8 +17,8 @@ import org.xml.sax.helpers.DefaultHandler; * use tags such as <p/> rather than just <p>, since the XML * parser used requires that or matching end elements. * - * From http://www.w3.org/TR/2000/REC-xhtml1-20000126: - * "Empty elements must either have an end tag or the start tag must end with /<". + * From https://www.w3.org/TR/2000/REC-xhtml1-20000126: + * "Empty elements must either have an end tag or the start tag must end with /<". * * See the file LICENSE.txt for copyright details. * @author Matthew Doar, mdoar@pobox.com diff --git a/src/jdiff/ConstructorAPI.java b/src/jdiff/ConstructorAPI.java index 8fc7159..65467ef 100755 --- a/src/jdiff/ConstructorAPI.java +++ b/src/jdiff/ConstructorAPI.java @@ -81,9 +81,10 @@ class ConstructorAPI implements Comparable { * Tests two constructors, using just the name and type, used by indexOf(). */ public boolean equals(Object o) { + ConstructorAPI constructorAPI = (ConstructorAPI)o; if (compareNullIsLeast(name_, constructorAPI.name_) == 0 && - compareNullIsLeast(type_, constructorAPI.type_) == 0) + compareNullIsLeast(getSignature(), constructorAPI.getSignature()) == 0) return true; return false; } @@ -119,4 +120,4 @@ class ConstructorAPI implements Comparable { signature_ = res; return res; } -} +} \ No newline at end of file diff --git a/src/jdiff/Diff.java b/src/jdiff/Diff.java index a9c9776..8cba311 100755 --- a/src/jdiff/Diff.java +++ b/src/jdiff/Diff.java @@ -324,7 +324,7 @@ class Diff { diffFile.println(""); diffFile.println(""); diffFile.println(""); - + // Write the navigation bar diffFile.println(""); diffFile.println(""); @@ -336,7 +336,7 @@ class Diff { String pkgRef = currPkgName; pkgRef = pkgRef.replace('.', '/'); pkgRef = HTMLReportGenerator.newDocPrefix + pkgRef + "/package-summary"; - diffFile.println(" "); + diffFile.println(" "); diffFile.println(" "); diffFile.println(" "); diffFile.println(" "); @@ -468,7 +468,7 @@ class Diff { diffFile.println("
" + APIDiff.newAPIName_ + "  " + APIDiff.newAPIName_ + "  Overview   Package   Class 
"); diffFile.println(" "); // Always have a link to the Javadoc files - diffFile.println(" "); + diffFile.println(" "); diffFile.println(" "); diffFile.println(" "); diffFile.println(" "); @@ -632,23 +632,23 @@ class Diff { */ public static int insertEffect = 1; - /** + /** * For each package and class, the first DiffOutput is added to * this hash table. Used when generating navigation bars. */ public static Hashtable firstDiffOutput = new Hashtable(); - /** + /** * If set, then show changes in implementation-related modifiers such as - * native and synchronized. For more information, see - * http://java.sun.com/j2se/1.4.1/docs/tooldocs/solaris/javadoc.html#generatedapideclarations + * native and synchronized. For more information, see + * https://java.sun.com/j2se/1.4.1/docs/tooldocs/solaris/javadoc.html#generatedapideclarations */ public static boolean showAllChanges = false; /** The list of documentation differences. */ private static List docDiffs = new ArrayList(); // DiffOutput[] - + /** Set to enable increased logging verbosity for debugging. */ private static boolean trace = false; - -} + +} diff --git a/src/jdiff/HTMLFiles.java b/src/jdiff/HTMLFiles.java index a141e6c..3b3cf14 100755 --- a/src/jdiff/HTMLFiles.java +++ b/src/jdiff/HTMLFiles.java @@ -43,31 +43,31 @@ public class HTMLFiles { h_.writeHTMLTitle(h_.windowTitle); // Note that the stylesheet is in the same directory h_.writeStyleSheetRef(true); - h_.writeText(""); + h_.writeText(""); // Note that the top-level frame file doesn't have the BODY tag - h_.writeText(""); - h_.writeText(""); + h_.writeText(" "); + h_.writeText(""); // Convert filenames to web links String tlfLink = h_.reportFileName + "/jdiff_topleftframe" + h_.reportFileExt; String allDiffsLink = h_.reportFileName + "/alldiffs_index_all" + h_.reportFileExt; String csnLink = h_.reportFileName + "/" + h_.reportFileName + "-summary" + h_.reportFileExt; - h_.writeText(" "); - h_.writeText(" "); - h_.writeText(" "); - h_.writeText(" "); - h_.writeText(""); - h_.writeText(""); - h_.writeText("<H2>"); + h_.writeText(" <frame src=\"" + tlfLink + "\" scrolling=\"no\" name=\"topleftframe\" frameborder=\"1\">"); + h_.writeText(" <frame src=\"" + allDiffsLink + "\" scrolling=\"auto\" name=\"bottomleftframe\" frameborder=\"1\">"); + h_.writeText(" </frameset>"); + h_.writeText(" <frame src=\"" + csnLink + "\" scrolling=\"auto\" name=\"rightframe\" frameborder=\"1\">"); + h_.writeText("</frameset>"); + h_.writeText("<noframes>"); + h_.writeText("<h2>"); h_.writeText("Frame Alert"); - h_.writeText("</H2>\n"); - h_.writeText("<P>"); + h_.writeText("</h2>\n"); + h_.writeText("<p>"); h_.writeText("This document is designed to be viewed using the frames feature. If you see this message, you are using a non-frame-capable web client."); - h_.writeText("<BR>"); - h_.writeText("Link to <A HREF=\"" + csnLink + "\" target=\"_top\">Non-frame version.</A>"); - h_.writeText(""); - h_.writeText(""); + h_.writeText("
"); + h_.writeText("Link to Non-frame version."); + h_.writeText(""); + h_.writeText(""); h_.reportFile.close(); } catch(IOException e) { System.out.println("IO Error while attempting to create " + tln); @@ -76,39 +76,39 @@ public class HTMLFiles { } } - /** Emit a top left frame with all the links to the index files. */ + /** Emit a frame with all the links to the index files. */ public void emitTopLeftFile(String tlf) { try { FileOutputStream fos = new FileOutputStream(tlf); h_.reportFile = new PrintWriter(fos); h_.writeStartHTMLHeader(); - h_.writeHTMLTitle("Android Diffs Index"); + h_.writeHTMLTitle("Android API Version Differences"); h_.writeStyleSheetRef(); h_.writeText(""); - h_.writeText(""); + h_.writeText(""); - h_.writeText("
" + APIDiff.newAPIName_ + "  " + APIDiff.newAPIName_ + "  Overview   Package   Class 
"); + h_.writeText("
"); h_.writeText(""); h_.writeText(" "); h_.writeText(""); h_.writeText(""); - h_.writeText(" "); + h_.writeText(" "); h_.writeText(""); h_.writeText(""); - h_.writeText(" "); + h_.writeText(" "); h_.writeText(""); h_.writeText(""); - h_.writeText(" "); + h_.writeText(" "); h_.writeText(""); h_.writeText(""); - h_.writeText(" "); + h_.writeText(" "); h_.writeText(""); h_.writeText(""); - h_.writeText(" "); + h_.writeText(" "); h_.writeText(""); h_.writeText(""); - h_.writeText(" "); + h_.writeText(" "); h_.writeText(""); h_.writeText("
"); h_.writeText(" Select a Diffs Index:
All Differences
All Differences
By Package
By Package
By Class
By Class
By Constructor
By Constructor
By Method
By Method
By Field
By Field
"); @@ -140,7 +140,7 @@ public class HTMLFiles { h_.writeText(" "); h_.writeText(" "); // Always have a link to the Javadoc files - h_.writeText(" "); + h_.writeText(" "); h_.writeText(" "); h_.writeText(" "); h_.writeText(" "); @@ -167,17 +167,17 @@ public class HTMLFiles { h_.writeText(" FRAMES  "); h_.writeText("  NO FRAMES"); h_.writeText(""); - + h_.writeText("
" + apiDiff.newAPIName_ + "  " + apiDiff.newAPIName_ + "  Overview   Package   Class 
"); h_.writeText("
"); h_.writeText (""); - h_.writeText("
"); + h_.writeText("
"); h_.writeText("

JDiff Documentation

"); - h_.writeText("
"); + h_.writeText("
"); h_.writeText("
"); - h_.writeText("JDiff is a Javadoc doclet which generates a report of the API differences between two versions of a product. It does not report changes in Javadoc comments, or changes in what a class or method does. "); + h_.writeText("JDiff is a Javadoc doclet which generates a report of the API differences between two versions of a product. It does not report changes in Javadoc comments, or changes in what a class or method does. "); h_.writeText("This help page describes the different parts of the output from JDiff."); h_.writeText("
"); @@ -197,23 +197,23 @@ public class HTMLFiles { h_.writeText("
"); h_.writeText("You can always tell when you are reading a JDiff page, rather than a Javadoc page, by the color of the index bar and the color of the background. "); - h_.writeText("Links which take you to a Javadoc page are always in a typewriter font. "); + h_.writeText("Links which take you to a Javadoc page are always in a typewriter font. "); h_.writeText("Just like Javadoc, all interface names are in italic, and class names are not italicized. Where there are multiple entries in an index with the same name, the heading for them is also in italics, but is not a link."); h_.writeText("
"); h_.writeText("
"); - h_.writeText("

Javadoc

"); + h_.writeText("

Javadoc

"); h_.writeText("This is a link to the top-level Javadoc page for the new version of the product."); h_.writeText("
"); - + h_.writeText("
"); - h_.writeText("

Overview

"); - h_.writeText("The overview is the top-level summary of what was removed, added and changed between versions."); + h_.writeText("

Overview

"); + h_.writeText("The overview is the top-level summary of what was removed, added and changed between versions."); h_.writeText("
"); - + h_.writeText("
"); - h_.writeText("

Package

"); + h_.writeText("

Package

"); h_.writeText("This is a link to the package containing the current changed class or interface."); h_.writeText("
"); @@ -265,7 +265,7 @@ public class HTMLFiles { } } - /** Emit the CSS external stylesheet file. */ + /** Emit the external stylesheet file. */ public void emitStylesheet() { String stylesheetFileName = "stylesheet-jdiff.css"; if (h_.outputDir != null) @@ -277,56 +277,10 @@ public class HTMLFiles { h_.writeText("/* (" + JDiff.jDiffLocation + ") */"); //h_.writeText("/* on " + new Date() + " */"); h_.writeText(); - //h_.writeText("/* Define colors, fonts and other style attributes here to override the defaults */"); - //h_.writeText(); - //h_.writeText("/* Page background color */"); - //h_.writeText("body { background-color: " + h_.bgcolor + "; font-family: arial; }"); - //First argument after backgroun: is for older Netscape browsers - //For more information, see http://css.nu/pointers/bugs.html and - //http://www.richinstyle.com/bugs/netscape4.html - //h_.writeText("body { background: #CCFFFF url(background.gif); font-family: arial; }"); - //h_.writeText(); - //h_.writeText("/* Table colors */"); - //h_.writeText(".TableHeadingColor { background: #CCCCFF } /* Dark mauve */"); - //h_.writeText(".TableSubHeadingColor { background: #EEEEFF } /* Light mauve */"); - //h_.writeText(".TableRowColor { background: #FFFFFF } /* White */"); - //h_.writeText(); - //h_.writeText("/* Font used in left-hand frame lists */"); - //h_.writeText(".FrameTitleFont { font-size: normal; font-family: normal }"); - //h_.writeText(".FrameHeadingFont { font-size: normal; font-family: normal }"); - //h_.writeText(".FrameItemFont { font-size: normal; font-family: normal }"); - //h_.writeText(); - //h_.writeText("/* Example of smaller, sans-serif font in frames */"); - //h_.writeText("/* .FrameItemFont { font-size: 10pt; font-family: Helvetica, Arial, sans-serif } */"); - //h_.writeText(); - //h_.writeText("/* Navigation bar fonts and colors */"); - //h_.writeText(".NavBarCell1 { background-color:#FFFFCC;} /* Changed to yellowish to make difference from Javadoc clear */"); - //h_.writeText(".NavBarCell1Rev { background-color:#00008B;}/* Dark Blue */"); - //h_.writeText(".NavBarFont1 { font-family: Arial, Helvetica, sans-serif; color:#000000;}"); - //h_.writeText(".NavBarFont1Rev { font-family: Arial, Helvetica, sans-serif; color:#FFFFFF;}"); - //h_.writeText(); - //h_.writeText(".NavBarCell2 { font-family: Arial, Helvetica, sans-serif; background-color:#FFFFFF;}"); - //h_.writeText(".NavBarCell3 { font-family: Arial, Helvetica, sans-serif; background-color:#FFFFFF;}"); - //h_.writeText(); - h_.writeText("/* "); - h_.writeText(" Links which become blue when hovered upon and show that they have been "); - h_.writeText(" visited. "); - h_.writeText("*/"); - h_.writeText(".hiddenlink {text-decoration:none;}"); - h_.writeText("a.hiddenlink:link {color: black; text-decoration: none}"); - h_.writeText("a.hiddenlink:visited {color: purple; text-decoration: none}"); - h_.writeText("a.hiddenlink:hover {color: blue; text-decoration: underline;}"); - h_.writeText(); - h_.writeText("/* "); - h_.writeText(" Links which become blue when hovered upon but do not show that they have "); - h_.writeText(" been visited. "); - h_.writeText("*/"); - h_.writeText("a.staysblack:link {color: black; text-decoration: none}"); - h_.writeText("a.staysblack:visited {color: black; text-decoration: none}"); - h_.writeText("a.staysblack:hover {color: blue; text-decoration: underline;}"); - h_.writeText(""); + h_.writeText("div.and-diff-id {border: 1px solid #eee;position:relative;float:right;clear:both;padding:0px;}"); h_.writeText("table.diffspectable {border:1px;padding:0px;margin:0px;}"); + h_.writeText(".diffspechead {background-color:#eee;}"); h_.writeText(".diffspectable tr {border:0px;padding:0px;}"); h_.writeText(".diffspectable td {background-color:eee;border:0px;font-size:90%;font-weight:normal;padding:0px;padding-left:1px;padding-right:1px;text-align:center;color:777;}"); h_.writeText("td.diffvalueold {color:orange;background-color:white;border:0px;font-size:80%;font-style:normal;text-align:left;padding:0px;padding-left:1px;padding-right:1px;line-height:.95em;}"); @@ -334,28 +288,46 @@ public class HTMLFiles { h_.writeText("td.diffvalue {color:444;background-color:white;border:0px;font-size:80%;font-weight:normal;text-align:left;padding:0px;padding-left:1px;padding-right:1px;line-height:.95em;}"); h_.writeText("td.diffspec {background-color:white;border:0px;font-size:80%;font-weight:normal;padding:1px;color:444;text-align:right;padding-right:.5em;line-height:.95em;}"); h_.writeText("tt {font-size:11pt;font-family:monospace;}"); - h_.writeText("code {font-size:11pt;font-family:monospace;}"); - h_.writeText(".indexHeader {font-size:11pt;line-height:.8em;}"); - h_.writeText(".indexText {font-size:9pt;line-height:.8em;padding-left:1em;}"); - - h_.writeText(".pagecontenth1 {"); - h_.writeText(" line-height: 130%;"); - h_.writeText(" font-size: 170%;"); - h_.writeText(" xmargin: 0 0 0 -10px;"); - h_.writeText(" padding: .8em 0 0;"); - h_.writeText(" border: none;"); - h_.writeText(" background: none;"); - h_.writeText("}"); - h_.writeText(""); - h_.writeText(".pagecontenth2 {"); - h_.writeText(" font-size: 130%;"); - h_.writeText(" font-weight: bold;"); - h_.writeText(" margin: 2em 0 0 -10px; "); - h_.writeText(" padding: 1px 3px;"); - h_.writeText(" position: relative;"); - h_.writeText(" border-top: 1px solid #3366CC;"); - h_.writeText(" background-color: #e5ecf9;"); - h_.writeText("}"); + h_.writeText(".indexHeader {"); + h_.writeText(" font-size:96%;"); + h_.writeText(" line-height:.8em;}"); + + h_.writeText(".jdiffIndex td {"); + h_.writeText(" font-size:96%;"); + h_.writeText(" xline-height:.8em;"); + h_.writeText(" padding:2px;"); + h_.writeText(" padding-left:1em;}"); + + h_.writeText(".indexText {"); + h_.writeText(" font-size:100%;"); + h_.writeText(" padding-left:1em;}"); + + h_.writeText("#indexTableCaption {"); + h_.writeText(" font-size:96%;"); + h_.writeText(" margin-top:.25em;"); + h_.writeText(" margin-bottom:0;"); + h_.writeText(" }"); + + h_.writeText(".hiddenlink {"); + h_.writeText(" font-size:96%;"); + h_.writeText(" line-height:.8em;"); + h_.writeText(" text-decoration:none;}"); + + h_.writeText("a {"); + h_.writeText(" text-decoration:none;}"); + + h_.writeText("a:hover {"); + h_.writeText(" text-decoration:underline;}"); + + h_.writeText(".indexBox {"); + h_.writeText(" border: 1px solid red;"); + h_.writeText(" margin:1em 0 0 0;}"); + + h_.writeText(".letterIndexHead {"); + h_.writeText(" font-size: 1.5em;font-weight:9;"); + h_.writeText(" margin:0 0 0em 0;"); + h_.writeText(" border: 1px solid red;}"); + h_.reportFile.close(); } catch(IOException e) { diff --git a/src/jdiff/HTMLIndexes.java b/src/jdiff/HTMLIndexes.java index 9e65d96..5cd90a1 100755 --- a/src/jdiff/HTMLIndexes.java +++ b/src/jdiff/HTMLIndexes.java @@ -84,15 +84,15 @@ public class HTMLIndexes { filename += "_all" + h_.reportFileExt; title = programElementType + " Differences Index"; } - + FileOutputStream fos = new FileOutputStream(filename); h_.reportFile = new PrintWriter(fos); h_.writeStartHTMLHeader(); h_.writeHTMLTitle(title); h_.writeStyleSheetRef(); h_.writeText(""); - h_.writeText(""); - + h_.writeText(""); + if (programElementType.compareTo("Package") == 0) { emitPackagesIndex(apiDiff, indexType); } else if (programElementType.compareTo("Class") == 0) { @@ -145,7 +145,7 @@ public class HTMLIndexes { // Don't emit a reference to the current letter if (Character.toUpperCase(sw) != Character.toUpperCase(currChar)) { if (swu == '_') { - h_.writeText("" + "underscore" + " "); + h_.writeText("" + "_" + " "); } else { h_.writeText("" + swu + " "); } @@ -162,7 +162,7 @@ public class HTMLIndexes { * added and changes sub-indexes. */ private void emitIndexHeader(String indexName, int indexType, - boolean hasRemovals, + boolean hasRemovals, boolean hasAdditions, boolean hasChanges) { String linkIndexName = indexName.toLowerCase(); boolean isAllDiffs = false; @@ -171,71 +171,66 @@ public class HTMLIndexes { isAllDiffs = true; } h_.writeText(""); // Named anchor - h_.writeText(""); + h_.writeText("
"); h_.writeText(" "); h_.writeText(" "); h_.writeText(" "); h_.writeText(" "); - h_.writeText(" "); h_.writeText(" "); h_.writeText("
"); h_.writeText(" Filter the Index:"); h_.writeText("
"); -// h_.writeText("
\">"); -// h_.writeText(" "); - // The index name is also a hidden link to the *index_all page + h_.writeText("
"); + if (indexType == 3) { h_.writeText("" + indexName + ""); } else if (isAllDiffs) { - h_.writeText("" + indexName + ""); + h_.writeText("" + indexName + ""); } else { h_.writeText("All " + indexName + ""); } -// h_.writeText(" "); h_.writeText("
"); -// h_.writeText(" "); + if (hasRemovals) { if (indexType == 0) { h_.writeText("Removals"); } else { - h_.writeText("Removals"); + h_.writeText("Removals"); } } else { h_.writeText("Removals"); } -// h_.writeText(" "); h_.writeText("
"); -// h_.writeText(" "); + if (hasAdditions) { if (indexType == 1) { h_.writeText("Additions"); } else { - h_.writeText("Additions"); + h_.writeText("Additions"); } } else { h_.writeText("Additions"); } -// h_.writeText(" "); h_.writeText("
"); -// h_.writeText(" "); + if (hasChanges) { if (indexType == 2) { h_.writeText("Changes"); } else { - h_.writeText("Changes"); + h_.writeText("Changes"); } } else { h_.writeText("Changes"); } -// h_.writeText(" "); -// h_.writeText(" "); + h_.writeText("
"); - h_.writeText("Bold indicates New; Strike indicates deleted"); - h_.writeText("
"); + h_.writeText("
"); + h_.writeText("Listed as: Added, Removed, Changed"); + h_.writeText("
"); } @@ -281,14 +276,15 @@ public class HTMLIndexes { // Package names are unique, so no need to check for duplicates. iter = packageNames.iterator(); char oldsw = '\0'; + h_.writeText("
"); while (iter.hasNext()) { Index pkg = (Index)(iter.next()); oldsw = emitPackageIndexEntry(pkg, oldsw); } } - /** - * Emit an index entry for a package. + /** + * Emit an index entry for a package. * Package names are unique, so no need to check for duplicates. */ public char emitPackageIndexEntry(Index pkg, char oldsw) { @@ -497,7 +493,7 @@ public class HTMLIndexes { // Add the named anchor for this new letter h_.writeText(""); if (sw == '_') - h_.writeText("
underscore "); + h_.writeText("
_ "); else h_.writeText("
" + Character.toUpperCase(sw) + " "); generateLetterIndex(classNames, sw, false); @@ -600,7 +596,7 @@ public class HTMLIndexes { // Add the named anchor for this new letter h_.writeText(""); if (sw == '_') - h_.writeText("
underscore "); + h_.writeText("
_ "); else h_.writeText("
" + Character.toUpperCase(sw) + " "); generateLetterIndex(ctorNames, sw, false); @@ -700,7 +696,7 @@ public class HTMLIndexes { // Add the named anchor for this new letter h_.writeText(""); if (sw == '_') - h_.writeText("
underscore "); + h_.writeText("
_ "); else h_.writeText("
" + Character.toUpperCase(sw) + " "); generateLetterIndex(methNames, sw, false); @@ -816,7 +812,7 @@ public class HTMLIndexes { // Add the named anchor for this new letter h_.writeText(""); if (sw == '_') - h_.writeText("
underscore "); + h_.writeText("
_ "); else h_.writeText("
" + Character.toUpperCase(sw) + " "); generateLetterIndex(fieldNames, sw, false); @@ -826,42 +822,41 @@ public class HTMLIndexes { h_.writeText("" + fld.name_ + "
"); } if (multipleMarker != 0) { -// More context than this is helpful here: h_.indent(INDENT_SIZE); - h_.writeText(" in "); + h_.writeText(" in "); } // Deal with each type of difference if (fld.changeType_ == 0) { - String commentID = className + "." + fld.name_; - if (multipleMarker == 0) { + String commentID = className + "." + fld.name_; + if (multipleMarker == 0) { h_.writeText("" + fld.name_ + ""); h_.writeText("
"); } else { - h_.writeText("" + className + ""); + h_.writeText("" + className + ""); h_.writeText("
"); } } else if (fld.changeType_ == 1) { - String commentID = className + "." + fld.name_; - if (multipleMarker == 0) { + String commentID = className + "." + fld.name_; + if (multipleMarker == 0) { h_.writeText("" + fld.name_ + ""); h_.writeText("
"); } else { - h_.writeText("" + className + ""); + h_.writeText("" + className + ""); h_.writeText("
"); } } else if (fld.changeType_ == 2) { - String commentID = className + "." + fld.name_; - if (multipleMarker == 0) { + String commentID = className + "." + fld.name_; + if (multipleMarker == 0) { h_.writeText("" + fld.name_ + ""); h_.writeText("
"); } else { - h_.writeText("" + className + ""); + h_.writeText("" + className + ""); h_.writeText("
"); } } return res; } - /** + /** * Emit the index of all changes, which appears in the bottom left frame. * Has to be run after all the other indexes have been written, since it * uses data from when they are generated. diff --git a/src/jdiff/HTMLReportGenerator.java b/src/jdiff/HTMLReportGenerator.java index c896525..5ba10a6 100755 --- a/src/jdiff/HTMLReportGenerator.java +++ b/src/jdiff/HTMLReportGenerator.java @@ -87,42 +87,38 @@ public class HTMLReportGenerator { // writeText("
"); // Add the nav bar for the summary page - writeNavigationBar(reportFileName + "-summary", null, null, + writeNavigationBar(reportFileName + "-summary", null, null, null, 0, true, - apiDiff.packagesRemoved.size() != 0, + apiDiff.packagesRemoved.size() != 0, apiDiff.packagesAdded.size() != 0, apiDiff.packagesChanged.size() != 0); - + + writeText("
"); // Write the title in the body with some formatting if (docTitle == null) { - //writeText("
"); - writeText("
"); - writeText("

API Differences Report

"); - writeText("
"); + //writeText("
"); + writeText("

Android API Differences Report

"); } else { - writeText("
"); - writeText("

" + docTitle + "

"); - writeText("
"); + writeText("

" + docTitle + "

"); } - writeText("

This document details the changes in the Android framework API. It shows "); - writeText("additions, modifications, and removals for packages, classes, methods, and "); - writeText("fields. Each reference to an API change includes a brief description of the "); - writeText("API and an explanation of the change and suggested workaround, where available.

"); + writeText("

This report details the changes in the core Android framework API between two API Level "); + writeText("specifications. It shows additions, modifications, and removals for packages, classes, methods, and fields. "); + writeText("The report also includes general statistics that characterize the extent and type of the differences.

"); - writeText("

The differences described in this report are based a comparison of the APIs "); - writeText("whose versions are specified in the upper-right corner of this page. It compares a "); - writeText("newer \"to\" API to an older \"from\" version, noting any changes relative to the "); - writeText("older API. So, for example, indicated API removals are no longer present in the \"to\" "); - writeText("API.

"); + writeText("

This report is based a comparison of the Android API specifications "); + writeText("whose API Level identifiers are given in the upper-right corner of this page. It compares a "); + writeText("newer \"to\" API to an older \"from\" API, noting all changes relative to the "); + writeText("older API. So, for example, API elements marked as removed are no longer present in the \"to\" "); + writeText("API specification.

"); writeText("

To navigate the report, use the \"Select a Diffs Index\" and \"Filter the Index\" "); writeText("controls on the left. The report uses text formatting to indicate interface names, "); - writeText("links to reference documentation, and links to change "); - writeText("description.

"); + writeText("links to reference documentation, and links to change "); + writeText("description. The statistics are accessible from the \"Statistics\" link in the upper-right corner.

"); writeText("

For more information about the Android framework API and SDK, "); - writeText("see the Android product site.

"); + writeText("see the Android Developers site.

"); // Write the contents and the other files as well writeReport(apiDiff); @@ -236,29 +232,29 @@ public class HTMLReportGenerator { reportChangedPackage(pkgDiffs, i); } } - writeText("
"); - writeText("
"); - writeText("
"); - writeText(" "); - writeText(" "); - writeText("
"); - writeText(" ©2008 Google - "); - writeText(" Code Home - "); - writeText(" Site Terms of Service - "); - writeText(" Privacy Policy "); - writeText(" "); - writeText("
"); - writeText(" Generated by JDiff
"); - writeText(" "); - writeText("
"); - writeText("
"); - writeText("
"); -} - - /** - * Write out the details of a changed package in a separate file. + writeText(" "); + writeText("
"); + writeText("
"); + writeText(" Except as noted, this content is licensed under "); + writeText(" Creative Commons Attribution 2.5."); + writeText(" For details and restrictions, see the Content License."); + writeText("
"); + writeText("
"); + writeText("

"); + writeText(" Site Terms of Service -"); + writeText(" Privacy Policy -"); + writeText(" Brand Guidelines"); + writeText("

"); + writeText("
"); + writeText("
"); + writeText(" "); + writeText(" "); + } + + + + /** + * Write out the details of a changed package in a separate file. */ public void reportChangedPackage(PackageDiff[] pkgDiffs, int pkgIndex) { PackageDiff pkgDiff = pkgDiffs[pkgIndex]; @@ -290,7 +286,7 @@ public class HTMLReportGenerator { pkgRef = pkgRef.replace('.', '/'); pkgRef = newDocPrefix + pkgRef + "/package-summary"; // A link to the package in the new API - String linkedPkgName = "" + pkgName + ""; + String linkedPkgName = "" + pkgName + ""; String prevPkgRef = null; if (pkgIndex != 0) { prevPkgRef = "pkg_" + pkgDiffs[pkgIndex-1].name_ + reportFileExt; @@ -300,7 +296,7 @@ public class HTMLReportGenerator { if (pkgIndex < pkgDiffs.length - 1) { nextPkgRef = "pkg_" + pkgDiffs[pkgIndex+1].name_ + reportFileExt; } - + writeSectionHeader("Package " + linkedPkgName, pkgName, prevPkgRef, nextPkgRef, null, 1, @@ -316,16 +312,16 @@ public class HTMLReportGenerator { String newPkgRef = pkgDocRef; if (oldDocPrefix != null) oldPkgRef = oldDocPrefix + oldPkgRef; - else + else oldPkgRef = null; newPkgRef = newDocPrefix + newPkgRef; - if (oldPkgRef != null) + if (oldPkgRef != null) pkgDiff.documentationChange_ += "old to "; + ".html#package_description\" target=\"_self\">old to "; else - pkgDiff.documentationChange_ += "old to "; - pkgDiff.documentationChange_ += "new. "; + pkgDiff.documentationChange_ += "old to "; + pkgDiff.documentationChange_ += "new. "; writeText(pkgDiff.documentationChange_); } @@ -469,7 +465,7 @@ public class HTMLReportGenerator { classRef = newDocPrefix + classRef; } // A link to the class in the new API - String linkedClassName = "" + className + ""; + String linkedClassName = "" + className + ""; String lcn = pkgName + "." + linkedClassName; //Links to the previous and next classes String prevClassRef = null; @@ -516,13 +512,13 @@ public class HTMLReportGenerator { oldClassRef = oldDocPrefix + oldClassRef; } } - if (oldDocPrefix != null) + if (oldDocPrefix != null) classDiff.documentationChange_ += "old to "; + ".html\" target=\"_self\">old to "; else - classDiff.documentationChange_ += "old to "; - classDiff.documentationChange_ += "new. "; + classDiff.documentationChange_ += "old to "; + classDiff.documentationChange_ += "new. "; writeText(classDiff.documentationChange_); } @@ -704,8 +700,8 @@ public class HTMLReportGenerator { /** Write the start of the HTML header. */ public void writeStartHTMLHeader(boolean addDate) { - writeText(""); - writeText(""); + writeText(""); + writeText(""); writeText(""); writeText(""); writeText(""); @@ -730,61 +726,72 @@ public class HTMLReportGenerator { writeStyleSheetRef(false); } - /** + /** * Write the HTML style sheet reference. If inSameDir is set, don't add * "../" to the location. */ public void writeStyleSheetRef(boolean inSameDir) { if (inSameDir) { - writeText(""); - writeText(""); - writeText(""); - writeText(""); - writeText(""); - } - else { - writeText(""); - writeText(""); - writeText(""); - writeText(""); - writeText(""); - } -// This doesn't work in non-windows browsers, so have to change the stylesheet -// writeText(""); -// writeText(""); + writeText(""); + writeText(""); + writeText(""); + writeText(""); + } else { + writeText(""); + writeText(""); + writeText(""); + writeText(""); + } } /** Write the HTML footer. */ public void writeHTMLFooter() { - writeText(""); - writeText(""); - writeText(""); - writeText(""); + writeText(""); + writeText(""); + writeText(""); + writeText(""); } - /** - * Write a section header, which includes a navigation bar. - * + /** + * Write a section header, which includes a navigation bar. + * * @param title Title of the header. Contains any links necessary. - * @param packageName The name of the current package, with no slashes or + * @param packageName The name of the current package, with no slashes or * links in it. May be null - * @param prevElemLink An HTML link to the previous element (a package or + * @param prevElemLink An HTML link to the previous element (a package or * class). May be null. - * @param nextElemLink An HTML link to the next element (a package or + * @param nextElemLink An HTML link to the next element (a package or * class). May be null. - * @param className The name of the current class, with no slashes or + * @param className The name of the current class, with no slashes or * links in it. May be null. * @param level 0 = overview, 1 = package, 2 = class/interface */ @@ -817,45 +824,39 @@ public class HTMLReportGenerator { * links in it. May be null * @param level 0 = overview, 1 = package, 2 = class/interface */ - public void writeSectionFooter(String packageName, + public void writeSectionFooter(String packageName, String prevElemLink, String nextElemLink, String className, int level) { - writeText(""); - writeText("
"); - writeText(" "); - writeText(" "); - writeText("
"); - writeText(" ©2008 Google - "); - writeText(" Code Home - "); - writeText(" Site Terms of Service - "); - writeText(" Privacy Policy "); - writeText(" "); - writeText("
"); - writeText(" Generated by JDiff
"); - writeText(" "); - writeText("
"); - writeText("
"); - writeText(""); -/* - reportFile.println("
"); - writeNavigationBar(packageName, prevElemLink, nextElemLink, - className, level, false, - false, false, false); -*/ + writeText(" "); + writeText("
"); + writeText("
"); + writeText(" Except as noted, this content is licensed under "); + writeText(" Creative Commons Attribution 2.5."); + writeText(" For details and restrictions, see the Content License."); + writeText("
"); + writeText("
"); + writeText("

"); + writeText(" Site Terms of Service -"); + writeText(" Privacy Policy -"); + writeText(" Brand Guidelines"); + writeText("

"); + writeText("
"); + writeText("
"); + writeText(" "); + writeText(" "); + } - - /** - * Write a navigation bar section header. - * - * @param pkgName The name of the current package, with no slashes or + + /** + * Write a navigation bar section header. + * + * @param pkgName The name of the current package, with no slashes or * links in it. - * @param prevElemLink An HTML link to the previous element (a package or + * @param prevElemLink An HTML link to the previous element (a package or * class). May be null. - * @param nextElemLink An HTML link to the next element (a package or + * @param nextElemLink An HTML link to the next element (a package or * class). May be null. - * @param className The name of the current class, with no slashes or + * @param className The name of the current class, with no slashes or * links in it. May be null. * @param level 0 = overview, 1 = package, 2 = class/interface */ @@ -864,250 +865,70 @@ public class HTMLReportGenerator { String prevElemLink, String nextElemLink, String className, int level, boolean upperNavigationBar, - boolean hasRemovals, boolean hasAdditions, + boolean hasRemovals, boolean hasAdditions, boolean hasChanges) { - String oldAPIName = "Old API"; - if (apiDiff.oldAPIName_ != null) - oldAPIName = apiDiff.oldAPIName_; - String newAPIName = "New API"; - if (apiDiff.newAPIName_ != null) - newAPIName = apiDiff.newAPIName_; + String oldAPIName = "Old API"; + if (apiDiff.oldAPIName_ != null) + oldAPIName = apiDiff.oldAPIName_; + String newAPIName = "New API"; + if (apiDiff.newAPIName_ != null) + newAPIName = apiDiff.newAPIName_; - SimpleDateFormat formatter - = new SimpleDateFormat ("yyyy.MM.dd HH:mm"); - Date day = new Date(); + SimpleDateFormat formatter + = new SimpleDateFormat ("yyyy.MM.dd HH:mm"); + Date day = new Date(); reportFile.println(""); - reportFile.println("
"); reportFile.println(""); - reportFile.println("
"); - reportFile.println("
"); - reportFile.println(" "); - reportFile.println("
"); - reportFile.println("
"); - reportFile.println(" "); + reportFile.println("
"); + reportFile.println("
"); + reportFile.println("\"Android"); + reportFile.println("
"); + reportFile.println("
"); + reportFile.println("
"); + reportFile.println(""); + reportFile.println(""); + reportFile.println(""); + reportFile.println("Android Developers | Android.com"); + reportFile.println(""); + reportFile.println("
"); + reportFile.println("
"); + reportFile.println("
"); reportFile.println(" "); reportFile.println(" "); reportFile.println(" "); reportFile.println(" "); - reportFile.println(" "); + reportFile.println(" "); reportFile.println(" "); reportFile.println(" "); reportFile.println(" "); - reportFile.println(" "); + reportFile.println(" "); reportFile.println(" "); reportFile.println(" "); -// reportFile.println(" "); -// reportFile.println(" "); -// reportFile.println(" "); -// reportFile.println(" "); reportFile.println(" "); reportFile.println(" "); reportFile.println(" "); reportFile.println(" "); reportFile.println("
API Diff Specification
To Version:To Level:" + newAPIName + "
From Version:From Level:" + oldAPIName + "
Product Type:Generic
Generated" + formatter.format( day ) + "
"); - reportFile.println("
"); - - if (doStats) { - reportFile.println("
"); + reportFile.println("
"); + if (doStats) { + reportFile.println("
"); reportFile.println(" "); reportFile.println(" "); - reportFile.println(" "); reportFile.println("
Statistics"); + reportFile.println(" Statistics"); reportFile.println("
"); reportFile.println("
"); } - - reportFile.println("
"); - reportFile.println("
"); - -/* - reportFile.println(""); - reportFile.println(" "); - reportFile.println(" "); - - // The right hand side title, only added at the top - if (upperNavigationBar) { - reportFile.println(" "); - } else { - reportFile.println(" "); - } - reportFile.println(""); - - // Links for frames and no frames - reportFile.println(""); - - // All of the previous and next links, and the frames and non-frames - // links are in one table cell - reportFile.println(" "); - } else { - reportFile.println("  NO FRAMES"); - } - } else { - reportFile.println("  NO FRAMES"); - } - - // All of the details links are in one table cell - if (atClass) { - // Links to a class page's sections - // The meaning of these three variable is overloaded - boolean hasCtors = hasRemovals; - boolean hasMethods = hasAdditions; - boolean hasFields = hasChanges; - if (hasCtors || hasMethods || hasFields) { - reportFile.println(" "); - } else { - // Make the end of the table line match the length of the top - reportFile.println(""); - } - } else { - // Links to a package page's sections - if (hasRemovals || hasAdditions || hasChanges) { - reportFile.println(" "); - } else { - // Make the end of the table line match the length of the top - reportFile.println(""); - } - } - - reportFile.println(""); - reportFile.println("
"); - reportFile.println(" "); - reportFile.println(" "); - boolean atOverview = (level == 0); - boolean atPackage = (level == 1); - boolean atClass = (level == 2); - - // Always have a link to the Javadoc files - if (atOverview) { - reportFile.println(" "); - } else if (atPackage) { - String pkgRef = pkgName; - pkgRef = pkgRef.replace('.', '/'); - pkgRef = newDocPrefix + pkgRef + "/package-summary"; - reportFile.println(" "); - } else if (atClass) { - String classRef = pkgName + "." + className; - classRef = classRef.replace('.', '/'); - if (className.indexOf('.') != -1) { - classRef = pkgName + "."; - classRef = classRef.replace('.', '/'); - classRef = newDocPrefix + classRef + className; - } else { - classRef = newDocPrefix + classRef; - } - reportFile.println(" "); - } - - if (atOverview) { - reportFile.println(" "); - reportFile.println(" "); - reportFile.println(" "); - } - - String changesSummaryName = reportFileName + "-summary" + reportFileExt; - if (atPackage) { - reportFile.println(" "); - reportFile.println(" "); - reportFile.println(" "); - } - if (atClass) { - reportFile.println(" "); - reportFile.println(" "); - reportFile.println(" "); - } - - if (!Diff.noDocDiffs) { - if (atPackage) { - String id = (String)Diff.firstDiffOutput.get(pkgName + "!package"); - if (id != null) - reportFile.println(" "); - else - reportFile.println(" "); - } else if (atClass) { - String id = (String)Diff.firstDiffOutput.get(pkgName + "." + className + "!class"); - if (id != null) - reportFile.println(" "); - else - reportFile.println(" "); - } else { - reportFile.println(" "); - } - } - - if (doStats) { - reportFile.println(" "); - } - - // Always have a link to the JDiff help file - reportFile.println(" "); - reportFile.println(" "); - reportFile.println("
" + apiDiff.newAPIName_ + "  " + apiDiff.newAPIName_ + "  " + apiDiff.newAPIName_ + "   Overview   Package   Class  Overview   Package   Class  Overview  Package   Class  Text Changes  Text Changes  Text Changes  Text Changes  Text Changes  Statistics  Help 
"); - reportFile.println("
Generated by
JDiff
"); - // Display links to the previous and next packages or classes - if (atPackage || atClass) { - String elemName = "CLASS"; - if (className == null) { - elemName = "PACKAGE"; - } - if (prevElemLink == null) { - reportFile.println(" PREV " + elemName + " "); - } else { - reportFile.println(" PREV " + elemName + ""); - } - if (nextElemLink == null) { - reportFile.println(" NEXT " + elemName + " "); - } else { - reportFile.println(" NEXT " + elemName + ""); - } - reportFile.println("        "); - } else { - reportFile.println("   "); - } - // Links for frames and non-frames. - reportFile.println(" FRAMES  "); - if (className == null) { - if (level == 0) { - reportFile.println("  NO FRAMES DETAIL:  "); - if (hasCtors) { - reportFile.println("CONSTRUCTORS | "); - } else { - reportFile.println("CONSTRUCTORS | "); - } - if (hasMethods) { - reportFile.println("METHODS | "); - } else { - reportFile.println("METHODS | "); - } - if (hasFields) { - reportFile.println("FIELDS"); - } else { - reportFile.println("FIELDS"); - } - reportFile.println(" DETAIL:  "); - if (hasRemovals) { - reportFile.println("REMOVED | "); - } else { - reportFile.println("REMOVED | "); - } - if (hasAdditions) { - reportFile.println("ADDED | "); - } else { - reportFile.println("ADDED | "); - } - if (hasChanges) { - reportFile.println("CHANGED"); - } else { - reportFile.println("CHANGED"); - } - reportFile.println("
"); - reportFile.println("
"); - reportFile.println(""); -*/ + reportFile.println("
"); + reportFile.println("
"); + reportFile.println("
"); + reportFile.println("
"); + reportFile.println("
"); } - + /** Write the start of a table. */ public void writeTableStart(String title, int colSpan) { reportFile.println("

"); @@ -1169,10 +990,10 @@ public class HTMLReportGenerator { pkgRef = oldDocPrefix + pkgRef + "/package-summary"; else pkgRef = newDocPrefix + pkgRef + "/package-summary"; - reportFile.println(" " + pkgName + ""); + reportFile.println(" " + pkgName + ""); } else if (linkType == 2) { reportFile.println(" " + pkgName + ""); - } + } if (!useOld) { reportFile.println(" "); emitComment(pkgName, possibleComment, linkType); @@ -1225,12 +1046,12 @@ public class HTMLReportGenerator { else classRef = newDocPrefix + classRef; } - reportFile.print(" "); + reportFile.print(" "); if (isInterface) reportFile.print("" + shownClassName + ""); else reportFile.print(shownClassName); - reportFile.println(""); + reportFile.println(""); } else if (linkType == 2) { reportFile.print(" "); if (isInterface) @@ -1238,7 +1059,7 @@ public class HTMLReportGenerator { else reportFile.print(shownClassName); reportFile.println(""); - } + } if (!useOld) { reportFile.println(" "); emitComment(fqName, possibleComment, linkType); @@ -1269,12 +1090,12 @@ public class HTMLReportGenerator { if (linkType == 0) { if (oldDocPrefix == null) { // No link - reportFile.print(" " + pkgName); + reportFile.print(" " + className); emitTypeWithParens(shortType); reportFile.println(""); } else { - writeCtorTableEntry(pkgName, className, - type, 1, + writeCtorTableEntry(pkgName, className, + type, 1, possibleComment, true); } } else if (linkType == 1) { @@ -1299,7 +1120,7 @@ public class HTMLReportGenerator { } } reportFile.print(" " + shownClassName + ""); + "(" + type + ")\" target=\"_top\">" + shownClassName + ""); emitTypeWithParens(shortType); reportFile.println(""); } @@ -1338,13 +1159,13 @@ public class HTMLReportGenerator { newType = ""; String shortNewType = simpleName(memberDiff.newType_); // Constructors have the linked name, then the type in parentheses. - reportFile.print(" "); + reportFile.print(" "); reportFile.print(shownClassName); - reportFile.print(""); + reportFile.print(""); emitTypeWithParens(shortNewType); reportFile.println(" "); reportFile.println(" "); - + // Report changes in documentation if (reportDocChanges && memberDiff.documentationChange_ != null) { String oldMemberRef = null; @@ -1363,15 +1184,15 @@ public class HTMLReportGenerator { if (oldType.compareTo("void") == 0) oldType = ""; } - if (oldDocPrefix != null) - memberDiff.documentationChange_ += "old to "; + if (oldDocPrefix != null) + memberDiff.documentationChange_ += "old to "; else - memberDiff.documentationChange_ += "old to "; - memberDiff.documentationChange_ += "new.
"; + memberDiff.documentationChange_ += "old to "; + memberDiff.documentationChange_ += "new.
"; } emitChanges(memberDiff, 0); @@ -1380,8 +1201,8 @@ public class HTMLReportGenerator { reportFile.println(""); } - /** - * Write a table entry for a method. + /** + * Write a table entry for a method. * * linkType: 0 - no link by default, 1 = link to Javadoc HTML file */ @@ -1442,7 +1263,7 @@ public class HTMLReportGenerator { reportFile.print(" "); emitType(shortReturnType); reportFile.print(" " + methodName + ""); + "(" + signature + ")\" target=\"_top\">" + methodName + ""); emitTypeWithParens(shortSignature); reportFile.println(""); } @@ -1484,23 +1305,23 @@ public class HTMLReportGenerator { memberDiff.modifiersChange_ != null && memberDiff.modifiersChange_.indexOf("but is now inherited from") != -1) { memberRef = memberDiff.inheritedFrom_; - memberRef = memberRef.replace('.', '/'); + memberRef = memberRef.replace('.', '/'); memberRef = newDocPrefix + memberRef; } - + String newReturnType = memberDiff.newType_; - String shortReturnType = simpleName(newReturnType); - String shortSignature = simpleName(newSignature); + String shortReturnType = simpleName(newReturnType); + String shortSignature = simpleName(newSignature); reportFile.print(" "); - emitTypeWithNoParens(shortReturnType); - reportFile.print(" "); + emitTypeWithNoParens(shortReturnType); + reportFile.print(" "); reportFile.print(memberName); - reportFile.print(""); + reportFile.print(""); emitTypeWithParens(shortSignature); reportFile.println(" "); reportFile.println(" "); - + // Report changes in documentation if (reportDocChanges && memberDiff.documentationChange_ != null) { String oldMemberRef = null; @@ -1517,15 +1338,15 @@ public class HTMLReportGenerator { } oldSignature = memberDiff.oldSignature_; } - if (oldDocPrefix != null) - memberDiff.documentationChange_ += "old to "; + if (oldDocPrefix != null) + memberDiff.documentationChange_ += "old to "; else - memberDiff.documentationChange_ += "old to "; - memberDiff.documentationChange_ += "new.
"; + memberDiff.documentationChange_ += "old to "; + memberDiff.documentationChange_ += "new.
"; } emitChanges(memberDiff, 1); @@ -1534,7 +1355,7 @@ public class HTMLReportGenerator { int parentIdx = memberDiff.modifiersChange_.indexOf("now inherited from"); if (parentIdx != -1) { // Change the commentID to pick up the appropriate method - commentID = memberDiff.inheritedFrom_ + "." + memberName + + commentID = memberDiff.inheritedFrom_ + "." + memberName + "_changed(" + newSignature + ")"; } } @@ -1597,19 +1418,19 @@ public class HTMLReportGenerator { reportFile.print(" "); emitType(shortFieldType); reportFile.println(" " + fieldName + ""); + "\" target=\"_top\">" + fieldName + ""); } if (!useOld) { reportFile.println(" "); emitComment(commentID, possibleComment, linkType); reportFile.println(""); } - } + } - /** + /** * Write a table entry for a changed field. */ - public void writeFieldChangedTableEntry(String pkgName, String className, + public void writeFieldChangedTableEntry(String pkgName, String className, MemberDiff memberDiff) { String memberName = memberDiff.name_; // Generally nowhere to break a member name anyway @@ -1637,20 +1458,20 @@ public class HTMLReportGenerator { memberDiff.modifiersChange_ != null && memberDiff.modifiersChange_.indexOf("but is now inherited from") != -1) { memberRef = memberDiff.inheritedFrom_; - memberRef = memberRef.replace('.', '/'); + memberRef = memberRef.replace('.', '/'); memberRef = newDocPrefix + memberRef; } String newType = memberDiff.newType_; - String shortNewType = simpleName(newType); + String shortNewType = simpleName(newType); reportFile.print(" "); emitTypeWithNoParens(shortNewType); - reportFile.print(" "); + reportFile.print(" "); reportFile.print(memberName); - reportFile.print(""); + reportFile.print(""); reportFile.println(" "); - + // Report changes in documentation if (reportDocChanges && memberDiff.documentationChange_ != null) { String oldMemberRef = null; @@ -1665,13 +1486,13 @@ public class HTMLReportGenerator { oldMemberRef = oldDocPrefix + oldMemberRef; } } - if (oldDocPrefix != null) - memberDiff.documentationChange_ += "old to "; + if (oldDocPrefix != null) + memberDiff.documentationChange_ += "old to "; else - memberDiff.documentationChange_ += "old to "; - memberDiff.documentationChange_ += "new.
"; + memberDiff.documentationChange_ += "old to "; + memberDiff.documentationChange_ += "new.
"; } emitChanges(memberDiff, 2); @@ -1902,14 +1723,14 @@ public class HTMLReportGenerator { if (sepType == null) sepType = p; else - sepType += ", " + p + ""; + sepType += ", " + p + ""; } reportFile.print("(" + sepType + ")"); } } } - /** + /** * Emit a string which is a type by surrounding it with <code> tags. * Do not surround it with parentheses. Used to display methods' return * types and field types. @@ -2106,20 +1927,20 @@ public class HTMLReportGenerator { */ public static boolean noCommentsOnChanges = false; - /** - * If set, then report changes in documentation (Javadoc comments) + /** + * If set, then report changes in documentation (Javadoc comments) * between the old and the new API. The default is that this is not set. */ public static boolean reportDocChanges = false; - /** + /** * Define the prefix for HTML links to the existing set of Javadoc- * generated documentation for the new API. E.g. For J2SE1.3.x, use - * "http://java.sun.com/j2se/1.3/docs/api/" + * "https://java.sun.com/j2se/1.3/docs/api/" */ public static String newDocPrefix = "../"; - /** + /** * Define the prefix for HTML links to the existing set of Javadoc- * generated documentation for the old API. */ diff --git a/src/jdiff/HTMLStatistics.java b/src/jdiff/HTMLStatistics.java index 6dada5c..31fa213 100755 --- a/src/jdiff/HTMLStatistics.java +++ b/src/jdiff/HTMLStatistics.java @@ -46,8 +46,8 @@ public class HTMLStatistics { // writeText("

"); // Add the nav bar for the summary page - - + + // Write a customized navigation bar for the statistics page h_.writeText(""); @@ -55,113 +55,121 @@ public class HTMLStatistics { = new SimpleDateFormat ("yyyy.MM.dd HH:mm"); Date day = new Date(); - h_.writeText("
"); h_.writeText(""); - h_.writeText("
"); - h_.writeText("
"); - h_.writeText(" "); - h_.writeText("
"); - - h_.writeText("
"); - h_.writeText(""); - h_.writeText(""); - h_.writeText(" "); - h_.writeText(""); + h_.writeText("
"); + h_.writeText("
"); + h_.writeText("\"Android"); + h_.writeText("
"); + h_.writeText("
"); + h_.writeText("
"); + h_.writeText(""); + h_.writeText(""); + h_.writeText(""); + h_.writeText("Android Developers | Android.com"); + h_.writeText(""); + h_.writeText("
"); + h_.writeText("
"); + h_.writeText("
API Diff Specification
"); + h_.writeText(" "); + h_.writeText(" "); + h_.writeText(" "); h_.writeText(" "); - h_.writeText(" "); - h_.writeText(" "); + h_.writeText(" "); + h_.writeText(" "); h_.writeText(" "); h_.writeText(" "); - h_.writeText(" "); + h_.writeText(" "); h_.writeText(" "); h_.writeText(" "); - h_.writeText(""); - h_.writeText(" "); - h_.writeText(" "); - h_.writeText(""); - h_.writeText("
API Diff Specification
To Version:" + newAPIName + "To Level:" + newAPIName + "
From Version:From Level:" + oldAPIName + "
Generated" + formatter.format( day ) + "
"); - h_.writeText("
"); - - h_.writeText("
"); - h_.writeText(" "); h_.writeText(" "); - h_.writeText(" "); + h_.writeText(" "); h_.writeText(" "); h_.writeText("
Top of Report"); + h_.writeText(" Generated" + formatter.format( day ) + "
"); - h_.writeText("
"); + h_.writeText("
"); - h_.writeText("
"); - h_.writeText("
"); + h_.writeText("
"); + h_.writeText(" "); + h_.writeText(" "); + h_.writeText(" "); + h_.writeText("
Top of Report"); + h_.writeText("
"); + h_.writeText("
"); - // Write the title in the body with some formatting - h_.writeText("
"); - h_.writeText("

API Change Statistics

"); - h_.writeText("
"); + h_.writeText("
"); + h_.writeText("
"); + h_.writeText("
"); + h_.writeText("
"); + h_.writeText("
"); + h_.writeText("

API Change Statistics

"); - h_.writeText("

"); - h_.writeText("The percent change statistic reported for all elements in each API is defined recursively as follows:

"); - h_.writeText("
"); 
-            h_.writeText("Percentage difference = 100 * (added + removed + 2*changed)");
-            h_.writeText("                        -----------------------------------");
-            h_.writeText("                        sum of public elements in BOTH APIs");
-            h_.writeText("
"); - h_.writeText("

where added is the number of packages added, removed is the number of packages removed, and changed is the number of packages changed."); - h_.writeText("This definition is applied recursively for the classes and their program elements, so the value for a changed package will be less than 1, unless every class in that package has changed."); - h_.writeText("The definition ensures that if all packages are removed and all new packages are"); - h_.writeText("added, the change will be 100%. Values are rounded here, so a value of 0% indicates a percentage difference of less than 0.5%.

"); - h_.writeText("

The overall difference between the two APIs is approximately " + (int)(apiDiff.pdiff) + "%."); + DecimalFormat df2 = new DecimalFormat( "#,###,###,##0.00" ); + double dd = apiDiff.pdiff; + double dd2dec = new Double(df2.format(dd)).doubleValue(); + + h_.writeText("

The overall difference between API Levels " + oldAPIName + " and " + newAPIName + " is approximately " + dd2dec + "%."); + h_.writeText("

"); + + h_.writeText("
"); + h_.writeText(""); + h_.writeText("

Total of Differences, by Number and Type

"); + h_.writeText("

"); + h_.writeText("The table below lists the numbers of program elements (packages, classes, constructors, methods, and fields) that were added, changed, or removed. The table includes only the highest-level program elements — that is, if a class with two methods was added, the number of methods added does not include those two methods, but the number of classes added does include that class."); h_.writeText("

"); - h_.writeText("

Contents

"); - h_.writeText("
Changed Packages
Sorted by percentage difference
"); - h_.writeText("
Changed Classes and Interfaces
Sorted by percentage difference
"); - h_.writeText("
Total of Differences
Listed by number and type
"); + emitNumbersByElement(apiDiff); h_.writeText("
"); h_.writeText(""); - h_.writeText("

Changed Packages, Sorted by Percentage Difference

"); + h_.writeText("

Changed Packages, Sorted by Percentage Difference

"); emitPackagesByDiff(apiDiff); + h_.writeText("

* See Calculation of Change Percentages, below.

"); h_.writeText("
"); h_.writeText(""); - h_.writeText("

Changed Classes and Interfaces, Sorted by Percentage Difference

"); + h_.writeText("

Changed Classes and Interfaces, Sorted by Percentage Difference

"); emitClassesByDiff(apiDiff); + h_.writeText("

* See Calculation of Change Percentages, below.

"); h_.writeText("
"); - h_.writeText(""); - h_.writeText("

Total of Differences, by Number and Type

"); + h_.writeText("

Calculation of Change Percentages

"); h_.writeText("

"); - h_.writeText("The table below lists the numbers of program elements (packages, classes, constructors, methods, and fields) that were removed, added or changed. The table includes only the highest-level program elements — that is, if a class with two methods was added, the number of methods added does not include those two methods, but the number of classes added does include that class."); - h_.writeText("

"); - - emitNumbersByElement(apiDiff); - - h_.writeText("
"); - h_.writeText("
"); - h_.writeText(" "); - h_.writeText(" "); - h_.writeText("
"); - h_.writeText(" ©2008 Google - "); - h_.writeText(" Code Home - "); - h_.writeText(" Site Terms of Sservice - "); - h_.writeText(" Privacy Policy "); - h_.writeText(" "); - h_.writeText("
"); - h_.writeText(" Generated by JDiff
"); - h_.writeText(" "); - h_.writeText("
"); - h_.writeText("
"); - h_.writeText("
"); - - h_.writeText(""); h_.writeText("