Browse files

Merge remote-tracking branch 'origin/master' into jellybean

  • Loading branch information...
2 parents 16ff3ed + c60a46c commit 5f74e82fdea6e7a3fae520253b6c96c678abb642 D4rKn3sSyS committed Nov 18, 2012
View
36 res/assets/templates/macros.cs
@@ -6,6 +6,8 @@
<?cs # A link to a type, or not if it's a primitive type
link: whether to create a link at the top level, always creates links in
recursive invocations.
+ Overloaded version to support use of 'nav' parameter, which when true,
+ will not include the generics in the class name (good for sidenav lists)
Expects the following fields:
.name
.link
@@ -14,14 +16,16 @@ recursive invocations.
.extendsBounds.N.(more links) (... extends ... & ...)
.typeArguments.N.(more links) (< ... >)
?><?cs
-def:type_link_impl(type, link) ?><?cs
+def:type_link_impl(type, link) ?><?cs call:type_link_impl2(type, link, "false") ?><?cs /def ?><?cs
+def:type_link_impl2(type, link, nav) ?><?cs
if:type.link && link=="true" ?><?cs
if:type.federated ?><a href="<?cs var:type.link ?>"><?cs
var:type.label ?></a><?cs
else ?><a href="<?cs var:toroot ?><?cs var:type.link ?>"><?cs var:type.label ?></a><?cs
/if ?><?cs
else ?><?cs var:type.label ?><?cs
- /if ?><?cs if:subcount(type.extendsBounds) ?><?cs
+ /if ?><?cs
+ if:subcount(type.extendsBounds) ?><?cs
each:t=type.extendsBounds ?><?cs
if:first(t) ?>&nbsp;extends&nbsp;<?cs else ?>&nbsp;&amp;&nbsp;<?cs /if ?><?cs
call:type_link_impl(t, "true") ?><?cs
@@ -33,15 +37,16 @@ recursive invocations.
call:type_link_impl(t, "true") ?><?cs
/each ?><?cs
/if ?><?cs
- if:subcount(type.typeArguments)
+ if:subcount(type.typeArguments) && nav=="false"
?>&lt;<?cs each:t=type.typeArguments ?><?cs call:type_link_impl(t, "true") ?><?cs
if:!last(t) ?>,&nbsp;<?cs /if ?><?cs
/each ?>&gt;<?cs
/if ?><?cs
/def ?>
<?cs def:class_name(type) ?><?cs call:type_link_impl(type, "false") ?><?cs /def ?>
-<?cs def:type_link(type) ?><?cs call:type_link_impl(type, "true") ?><?cs /def ?>
+<?cs def:type_link2(type,nav) ?><?cs call:type_link_impl2(type, "true", nav) ?><?cs /def ?>
+<?cs def:type_link(type) ?><?cs call:type_link2(type, "false") ?><?cs /def ?>
<?cs # a conditional link.
if the "condition" parameter evals to true then the link is displayed
@@ -93,15 +98,11 @@ recursive invocations.
/each ?><?cs
/def ?>
-<?cs # The message about This xxx is deprecated. ?><?cs
-def:deprecated_text(kind) ?>
- This <?cs var:kind ?> is deprecated.<?cs
-/def ?>
-
<?cs # Show the short-form description of something. These come from shortDescr and deprecated ?><?cs
def:short_descr(obj) ?><?cs
if:subcount(obj.deprecated) ?>
- <em><?cs call:deprecated_text(obj.kind) ?>
+ <em>This <?cs var:obj.kind ?> was deprecated
+ in API level <?cs var:obj.deprecatedsince ?>.
<?cs call:tag_list(obj.deprecated) ?></em><?cs
else ?><?cs call:tag_list(obj.shortDescr) ?><?cs
/if ?><?cs
@@ -111,7 +112,8 @@ recursive invocations.
def:deprecated_warning(obj) ?><?cs
if:subcount(obj.deprecated) ?><p>
<p class="caution">
- <strong><?cs call:deprecated_text(obj.kind) ?></strong><br/> <?cs
+ <strong>This <?cs var:obj.kind ?> was deprecated
+ in API level <?cs var:obj.deprecatedsince ?></strong>.<br/> <?cs
call:tag_list(obj.deprecated) ?>
</p><?cs
/if ?><?cs
@@ -137,11 +139,11 @@ recursive invocations.
<?cs /def ?>
<?cs # print the API Level ?><?cs
-def:since_tags(obj) ?>
-<?cs if:reference.apilevels && obj.since ?>
- Since: <a href="<?cs var:toroot ?>guide/topics/manifest/uses-sdk-element.html#ApiLevels">API Level <?cs var:obj.since ?></a>
-<?cs /if ?>
-<?cs /def ?>
+def:since_tags(obj) ?><?cs
+if:reference.apilevels && obj.since ?>
+ Added in <a href="<?cs var:toroot ?>guide/topics/manifest/uses-sdk-element.html#ApiLevels">API level <?cs var:obj.since ?></a><?cs
+/if ?><?cs
+/def ?>
<?cs def:federated_refs(obj) ?>
<?cs if:subcount(obj.federated) ?>
<div>
@@ -236,7 +238,7 @@ recursive invocations.
<li><h2><?cs var:label ?></h2>
<ul><?cs
each:cl=classes ?>
- <li class="<?cs if:class.name == cl.label?>selected <?cs /if ?>api apilevel-<?cs var:cl.since ?>"><?cs call:type_link(cl) ?></li><?cs
+ <li class="<?cs if:class.name == cl.label?>selected <?cs /if ?>api apilevel-<?cs var:cl.since ?>"><?cs call:type_link2(cl,"true") ?></li><?cs
/each ?>
</ul>
</li><?cs
View
40 res/assets/templates/yaml_navtree.cs
@@ -0,0 +1,40 @@
+<?cs
+
+# walk the children pages and print them nested below the parent
+page: the node to insert a label, link and check for children
+whitespace: Whitespace to insert before any text in the structure, which helps
+ with nesting children on recursion.
+isRoot: treat this node as if it has children and insert a section node.
+
+?><?cs
+def:write_child_nodes(page,whitespace,isRoot) ?>
+<?cs var:whitespace ?>- title: "<?cs var:page.label ?>"
+<?cs var:whitespace ?> path: <?cs var:page.link ?><?cs
+ if:subcount(page.children) || isRoot ?>
+<?cs var:whitespace ?> section: <?cs
+ /if?><?cs
+ each:child = page.children?>
+<?cs var:whitespace ?> - title: "<?cs var:child.label ?>"
+<?cs var:whitespace ?> path: <?cs var:child.link ?><?cs
+ if:subcount(child.children) ?>
+<?cs var:whitespace ?> section:<?cs
+ call:write_child_nodes(child) ?><?cs
+ /if ?><?cs
+ /each ?><?cs
+/def ?><?cs
+
+
+
+# print out the yaml nav starting with the toc entry and using the first item,
+which is generally the package summary as the root element with the rest of the
+pages as children beneath the package summary.
+
+?>
+toc:<?cs each:page = docs.pages?><?cs
+ if:page.type == "package"?><?cs
+ call:write_child_nodes(page,"",1) ?><?cs
+ else?>
+ <?cs
+ call:write_child_nodes(page," ",0) ?><?cs
+ /if?><?cs
+/each ?>
View
6 src/com/google/doclava/ClassInfo.java
@@ -852,6 +852,9 @@ public void makeShortDescrHDF(Data data, String base) {
TagInfo.makeHDF(data, base + ".shortDescr", this.firstSentenceTags());
TagInfo.makeHDF(data, base + ".deprecated", deprecatedTags());
data.setValue(base + ".since", getSince());
+ if (isDeprecated()) {
+ data.setValue(base + ".deprecatedsince", getDeprecatedSince());
+ }
setFederatedReferences(data, base);
}
@@ -895,6 +898,9 @@ public void makeHDF(Data data) {
data.setValue("class.kind", kind);
}
data.setValue("class.since", getSince());
+ if (isDeprecated()) {
+ data.setValue("class.deprecatedsince", getDeprecatedSince());
+ }
setFederatedReferences(data, "class");
// the containing package -- note that this can be passed to type_link,
View
9 src/com/google/doclava/DocInfo.java
@@ -85,6 +85,14 @@ public String getSince() {
return mSince;
}
+ public void setDeprecatedSince(String since) {
+ mDeprecatedSince = since;
+ }
+
+ public String getDeprecatedSince() {
+ return mDeprecatedSince;
+ }
+
public final void addFederatedReference(FederatedSite source) {
mFederatedReferences.add(source);
}
@@ -106,5 +114,6 @@ public final void setFederatedReferences(Data data, String base) {
Comment mComment;
SourcePositionInfo mPosition;
private String mSince;
+ private String mDeprecatedSince;
private Set<FederatedSite> mFederatedReferences = new LinkedHashSet<FederatedSite>();
}
View
37 src/com/google/doclava/Doclava.java
@@ -76,6 +76,7 @@
public static FederationTagger federationTagger = new FederationTagger();
private static boolean generateDocs = true;
private static boolean parseComments = false;
+ private static String yamlNavFile = null;
public static JSilver jSilver = null;
@@ -119,6 +120,7 @@ public static void main(String[] args) {
public static boolean start(RootDoc r) {
long startTime = System.nanoTime();
String keepListFile = null;
+ String proguardFile = null;
String proofreadFile = null;
String todoFile = null;
String sdkValuePath = null;
@@ -170,6 +172,8 @@ public static boolean start(RootDoc r) {
}
} else if (a[0].equals("-keeplist")) {
keepListFile = a[1];
+ } else if (a[0].equals("-proguard")) {
+ proguardFile = a[1];
} else if (a[0].equals("-proofread")) {
proofreadFile = a[1];
} else if (a[0].equals("-todo")) {
@@ -207,11 +211,17 @@ public static boolean start(RootDoc r) {
try {
String name = a[1];
URL federationURL = new URL(a[2]);
- federationTagger.addSite(name, federationURL);
+ federationTagger.addSiteUrl(name, federationURL);
} catch (MalformedURLException e) {
System.err.println("Could not parse URL for federation: " + a[1]);
return false;
}
+ } else if (a[0].equals("-federationapi")) {
+ String name = a[1];
+ String file = a[2];
+ federationTagger.addSiteApi(name, file);
+ } else if (a[0].equals("-yaml")) {
+ yamlNavFile = a[1];
}
}
@@ -272,6 +282,11 @@ public static boolean start(RootDoc r) {
// Navigation tree
NavTree.writeNavTree(javadocDir);
+ // Write yaml tree.
+ if (yamlNavFile != null){
+ NavTree.writeYamlTree(javadocDir, yamlNavFile);
+ }
+
// Packages Pages
writePackages(javadocDir + "packages" + htmlExtension);
@@ -303,8 +318,8 @@ public static boolean start(RootDoc r) {
}
// Stubs
- if (stubsDir != null || apiFile != null) {
- Stubs.writeStubsAndApi(stubsDir, apiFile, stubPackages);
+ if (stubsDir != null || apiFile != null || proguardFile != null) {
+ Stubs.writeStubsAndApi(stubsDir, apiFile, proguardFile, stubPackages);
}
Errors.printErrors();
@@ -478,6 +493,9 @@ public static int optionLength(String option) {
if (option.equals("-keeplist")) {
return 2;
}
+ if (option.equals("-proguard")) {
+ return 2;
+ }
if (option.equals("-proofread")) {
return 2;
}
@@ -526,6 +544,12 @@ public static int optionLength(String option) {
if (option.equals("-federate")) {
return 3;
}
+ if (option.equals("-federationapi")) {
+ return 3;
+ }
+ if (option.equals("-yaml")) {
+ return 2;
+ }
return 0;
}
@@ -1439,4 +1463,11 @@ private static int checkInheritance(ClassInfo clazz) {
return TYPE_NONE;
}
+
+ /**
+ * Ensures a trailing '/' at the end of a string.
+ */
+ static String ensureSlash(String path) {
+ return path.endsWith("/") ? path : path + "/";
+ }
}
View
10 src/com/google/doclava/FederatedSite.java
@@ -45,6 +45,16 @@ public FederatedSite(String name, URL baseUrl) throws ApiParseException {
}
}
+ /**
+ * Constructs a federated site using an api file not contained on
+ * the site itself.
+ */
+ public FederatedSite(String name, URL baseUrl, String api) throws ApiParseException {
+ this.name = name;
+ this.baseUrl = baseUrl;
+ this.apiInfo = new ApiCheck().parseApi(api);
+ }
+
public String linkFor(String htmlPage) {
return baseUrl + "/" + htmlPage;
}
View
65 src/com/google/doclava/FederationTagger.java
@@ -16,45 +16,80 @@
package com.google.doclava;
-import com.google.doclava.apicheck.ApiCheck;
-import com.google.doclava.apicheck.ApiInfo;
import com.google.doclava.apicheck.ApiParseException;
-
-import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
/**
* Cross-references documentation among different libraries. A FederationTagger
* is populated with a list of {@link FederatedSite} objects which are linked
* against when overlapping content is discovered.
*/
public final class FederationTagger {
+ private final Map<String, URL> federatedUrls = new HashMap<String, URL>();
+ private final Map<String, String> federatedXmls = new HashMap<String, String>();
private final List<FederatedSite> federatedSites = new ArrayList<FederatedSite>();
-
+ private boolean initialized = false;
/**
* Adds a Doclava documentation site for federation. Accepts the base URL of
* the remote API.
*/
- public void addSite(String name, URL site) {
- try {
- federatedSites.add(new FederatedSite(name, site));
- } catch (ApiParseException e) {
- String error = "Could not add site for federation: " + site;
- if (e.getMessage() != null) {
- error += ": " + e.getMessage();
- }
- Errors.error(Errors.NO_FEDERATION_DATA, null, error);
- }
+ public void addSiteUrl(String name, URL site) {
+ federatedUrls.put(name, site);
+ }
+
+ public void addSiteApi(String name, String file) {
+ federatedXmls.put(name, file);
}
+ public void tag(ClassInfo classDoc) {
+ initialize();
+ for (FederatedSite site : federatedSites) {
+ applyFederation(site, new ClassInfo[] { classDoc });
+ }
+ }
+
public void tagAll(ClassInfo[] classDocs) {
+ initialize();
for (FederatedSite site : federatedSites) {
applyFederation(site, classDocs);
}
}
+ private void initialize() {
+ if (initialized) {
+ return;
+ }
+
+ for (String name : federatedXmls.keySet()) {
+ if (!federatedUrls.containsKey(name)) {
+ Errors.error(Errors.NO_FEDERATION_DATA, null, "Unknown documentation site for " + name);
+ }
+ }
+
+ for (String name : federatedUrls.keySet()) {
+ try {
+ if (federatedXmls.containsKey(name)) {
+ federatedSites.add(new FederatedSite(name, federatedUrls.get(name),
+ federatedXmls.get(name)));
+ } else {
+ federatedSites.add(new FederatedSite(name, federatedUrls.get(name)));
+ }
+ } catch (ApiParseException e) {
+ String error = "Could not add site for federation: " + name;
+ if (e.getMessage() != null) {
+ error += ": " + e.getMessage();
+ }
+ Errors.error(Errors.NO_FEDERATION_DATA, null, error);
+ }
+ }
+
+ initialized = true;
+ }
+
private void applyFederation(FederatedSite federationSource, ClassInfo[] classDocs) {
for (ClassInfo classDoc : classDocs) {
PackageInfo packageSpec
View
3 src/com/google/doclava/FieldInfo.java
@@ -326,6 +326,9 @@ public void makeHDF(Data data, String base) {
TagInfo.makeHDF(data, base + ".deprecated", comment().deprecatedTags());
TagInfo.makeHDF(data, base + ".seeAlso", comment().seeTags());
data.setValue(base + ".since", getSince());
+ if (isDeprecated()) {
+ data.setValue(base + ".deprecatedsince", getDeprecatedSince());
+ }
data.setValue(base + ".final", isFinal() ? "final" : "");
data.setValue(base + ".static", isStatic() ? "static" : "");
if (isPublic()) {
View
53 src/com/google/doclava/LinkReference.java
@@ -26,6 +26,8 @@
*/
public class LinkReference {
+ private static final boolean DBG = false;
+
/** The original text. */
public String text;
@@ -38,6 +40,9 @@
/** The link. */
public String href;
+ /** Non-null for federated links */
+ public String federatedSite;
+
/** The {@link PackageInfo} if any. */
public PackageInfo packageInfo;
@@ -232,32 +237,53 @@ public static LinkReference parse(String text, ContainerInfo base, SourcePositio
ClassInfo cl = null;
if (base instanceof ClassInfo) {
cl = (ClassInfo) base;
+ if (DBG) System.out.println("-- chose base as classinfo");
}
if (ref == null) {
+ if (DBG) System.out.println("-- ref == null");
// no class or package was provided, assume it's this class
if (cl != null) {
+ if (DBG) System.out.println("-- assumed to be cl");
result.classInfo = cl;
}
} else {
+ if (DBG) System.out.println("-- they provided ref = " + ref);
// they provided something, maybe it's a class or a package
if (cl != null) {
+ if (DBG) System.out.println("-- cl non-null");
result.classInfo = cl.extendedFindClass(ref);
if (result.classInfo == null) {
+ if (DBG) System.out.println("-- cl.extendedFindClass was null");
result.classInfo = cl.findClass(ref);
}
if (result.classInfo == null) {
+ if (DBG) System.out.println("-- cl.findClass was null");
result.classInfo = cl.findInnerClass(ref);
+ if (DBG) if (result.classInfo == null) System.out.println("-- cl.findInnerClass was null");
}
}
if (result.classInfo == null) {
+ if (DBG) System.out.println("-- hitting up the Converter.obtainclass");
result.classInfo = Converter.obtainClass(ref);
}
if (result.classInfo == null) {
+ if (DBG) System.out.println("-- Converter.obtainClass was null");
result.packageInfo = Converter.obtainPackage(ref);
}
}
+ if (result.classInfo == null) {
+ if (DBG) System.out.println("-- NO CLASS INFO");
+ } else {
+ Doclava.federationTagger.tag(result.classInfo);
+ for (FederatedSite site : result.classInfo.getFederatedReferences()) {
+ if (DBG) System.out.println("-- reg link = " + result.classInfo.htmlPage());
+ if (DBG) System.out.println("-- fed link = " +
+ site.linkFor(result.classInfo.htmlPage()));
+ }
+ }
+
if (result.classInfo != null && mem != null) {
// it's either a field or a method, prefer a field
if (params == null) {
@@ -322,6 +348,7 @@ public static LinkReference parse(String text, ContainerInfo base, SourcePositio
method = (MethodInfo) result.memberInfo;
}
+ if (DBG) System.out.println("----- label = " + result.label + ", text = '" + text + "'");
if (text.startsWith("\"")) {
// literal quoted reference (e.g., a book title)
Matcher matcher = QUOTE_PATTERN.matcher(text);
@@ -333,6 +360,7 @@ public static LinkReference parse(String text, ContainerInfo base, SourcePositio
skipHref = true;
result.label = matcher.group(1);
result.kind = "@seeJustLabel";
+ if (DBG) System.out.println(" ---- literal quoted reference");
} else if (text.startsWith("<")) {
// explicit "<a href" form
Matcher matcher = HREF_PATTERN.matcher(text);
@@ -344,18 +372,21 @@ public static LinkReference parse(String text, ContainerInfo base, SourcePositio
result.href = matcher.group(1);
result.label = matcher.group(2);
result.kind = "@seeHref";
+ if (DBG) System.out.println(" ---- explicit href reference");
} else if (result.packageInfo != null) {
result.href = result.packageInfo.htmlPage();
if (result.label.length() == 0) {
result.href = result.packageInfo.htmlPage();
result.label = result.packageInfo.name();
}
+ if (DBG) System.out.println(" ---- packge reference");
} else if (result.classInfo != null && result.referencedMemberName == null) {
// class reference
if (result.label.length() == 0) {
result.label = result.classInfo.name();
}
- result.href = result.classInfo.htmlPage();
+ setHref(result, result.classInfo, null);
+ if (DBG) System.out.println(" ---- class reference");
} else if (result.memberInfo != null) {
// member reference
ClassInfo containing = result.memberInfo.containingClass();
@@ -367,8 +398,10 @@ public static LinkReference parse(String text, ContainerInfo base, SourcePositio
if (result.label.length() == 0) {
result.label = result.referencedMemberName;
}
- result.href = containing.htmlPage() + '#' + result.memberInfo.anchor();
+ setHref(result, containing, result.memberInfo.anchor());
+ if (DBG) System.out.println(" ---- member reference");
}
+ if (DBG) System.out.println(" --- href = '" + result.href + "'");
if (result.href == null && !skipHref) {
if (printOnErrors && (base == null || base.checkLevel())) {
@@ -425,6 +458,22 @@ private void makeError() {
this.label = "ERROR(" + this.label + "/" + text.trim() + ")";
}
+ static private void setHref(LinkReference reference, ClassInfo info, String member) {
+ String htmlPage = info.htmlPage();
+ if (member != null) {
+ htmlPage = htmlPage + "#" + member;
+ }
+
+ Doclava.federationTagger.tag(info);
+ if (!info.getFederatedReferences().isEmpty()) {
+ FederatedSite site = info.getFederatedReferences().iterator().next();
+ reference.href = site.linkFor(htmlPage);
+ reference.federatedSite = site.name();
+ } else {
+ reference.href = htmlPage;
+ }
+ }
+
/** private. **/
private LinkReference() {}
}
View
3 src/com/google/doclava/MethodInfo.java
@@ -557,6 +557,9 @@ public void makeHDF(Data data, String base) {
TagInfo.makeHDF(data, base + ".deprecated", deprecatedTags());
TagInfo.makeHDF(data, base + ".seeAlso", seeTags());
data.setValue(base + ".since", getSince());
+ if (isDeprecated()) {
+ data.setValue(base + ".deprecatedsince", getDeprecatedSince());
+ }
ParamTagInfo.makeHDF(data, base + ".paramTags", paramTags());
AttrTagInfo.makeReferenceHDF(data, base + ".attrRefs", comment().attrTags());
ThrowsTagInfo.makeHDF(data, base + ".throws", throwsTags());
View
78 src/com/google/doclava/NavTree.java
@@ -20,6 +20,8 @@
import java.util.ArrayList;
import java.util.List;
+import java.util.SortedMap;
+import java.util.TreeMap;
public class NavTree {
@@ -46,6 +48,82 @@ public static void writeNavTree(String dir) {
ClearPage.write(data, "navtree_data.cs", "navtree_data.js");
}
+ /**
+ * Write the YAML formatted navigation tree.
+ * @see "http://yaml.org/"
+ */
+ public static void writeYamlTree(String dir, String fileName){
+ Data data = Doclava.makeHDF();
+ ClassInfo[] classes = Converter.rootClasses();
+
+ SortedMap<String, Object> sorted = new TreeMap<String, Object>();
+ for (ClassInfo cl : classes) {
+ if (cl.isHidden()) {
+ continue;
+ }
+ sorted.put(cl.qualifiedName(), cl);
+
+ PackageInfo pkg = cl.containingPackage();
+ String name;
+ if (pkg == null) {
+ name = "";
+ } else {
+ name = pkg.name();
+ }
+ sorted.put(name, pkg);
+ }
+
+ data = makeYamlHDF(sorted, "docs.pages", data);
+ ClearPage.write(data, "yaml_navtree.cs", Doclava.ensureSlash(dir) + fileName);
+ }
+
+ public static Data makeYamlHDF(SortedMap<String, Object> sorted, String base, Data data) {
+
+ String key = "docs.pages.";
+ int i = 0;
+ for (String s : sorted.keySet()) {
+ Object o = sorted.get(s);
+
+ if (o instanceof PackageInfo) {
+ PackageInfo pkg = (PackageInfo) o;
+
+ data.setValue("docs.pages." + i + ".id", "" + i);
+ data.setValue("docs.pages." + i + ".label", pkg.name());
+ data.setValue("docs.pages." + i + ".shortname", "API");
+ data.setValue("docs.pages." + i + ".link", pkg.htmlPage());
+ data.setValue("docs.pages." + i + ".type", "package");
+ } else if (o instanceof ClassInfo) {
+ ClassInfo cl = (ClassInfo) o;
+
+ // skip classes that are the child of another class, recursion will handle those.
+ if (cl.containingClass() == null){
+
+ data.setValue("docs.pages." + i + ".id", "" + i);
+ data = makeYamlHDF(cl, "docs.pages."+i, data);
+ }
+ }
+
+ i++;
+ }
+ return data;
+ }
+
+ public static Data makeYamlHDF(ClassInfo cl, String base, Data data) {
+ data.setValue(base + ".label", cl.name());
+ data.setValue(base + ".shortname", cl.name().substring(cl.name().lastIndexOf(".")+1));
+ data.setValue(base + ".link", cl.htmlPage());
+ data.setValue(base + ".type", cl.kind());
+
+ if (cl.innerClasses().size() > 0){
+ int j = 0;
+ for (ClassInfo cl2 : cl.innerClasses()){
+ data = makeYamlHDF(cl2, base + ".children." + j, data);
+ j++;
+ }
+ }
+
+ return data;
+ }
private static Node makePackageNode(PackageInfo pkg) {
List<Node> children = new ArrayList<Node>();
View
8 src/com/google/doclava/SeeTagInfo.java
@@ -55,6 +55,14 @@ public void makeHDF(Data data, String base) {
if (linkRef.href != null) {
data.setValue(base + ".href", linkRef.href);
}
+
+ if (ClearPage.toroot != null) {
+ data.setValue("toroot", ClearPage.toroot);
+ }
+
+ if (linkRef.federatedSite != null) {
+ data.setValue("federated", linkRef.federatedSite);
+ }
}
public boolean checkLevel() {
View
45 src/com/google/doclava/SinceTagger.java
@@ -118,7 +118,7 @@ private void applyVersionsFromSpec(String versionName, ApiInfo specApi, ClassInf
}
versionPackage(versionName, classDoc.containingPackage());
- versionClass(versionName, classDoc);
+ versionClass(versionName, classSpec, classDoc);
versionConstructors(versionName, classSpec, classDoc);
versionFields(versionName, classSpec, classDoc);
versionMethods(versionName, classSpec, classDoc);
@@ -137,10 +137,17 @@ private void versionPackage(String versionName, PackageInfo doc) {
/**
* Applies version information to {@code doc} where not already present.
*/
- private void versionClass(String versionName, ClassInfo doc) {
+ private void versionClass(String versionName, ClassInfo spec, ClassInfo doc) {
if (doc.getSince() == null) {
doc.setSince(versionName);
}
+
+ // Set deprecated version
+ if (doc.isDeprecated() && doc.getDeprecatedSince() == null) {
+ if (spec.isDeprecated()) {
+ doc.setDeprecatedSince(versionName);
+ }
+ }
}
/**
@@ -152,6 +159,17 @@ private void versionConstructors(String versionName, ClassInfo spec, ClassInfo d
&& spec.hasConstructor(constructor)) {
constructor.setSince(versionName);
}
+
+ // Set deprecated version
+ if (constructor.isDeprecated() && constructor.getDeprecatedSince() == null) {
+ // Find matching field from API spec
+ if (spec.allConstructorsMap().containsKey(constructor.getHashableName())) {
+ MethodInfo specConstructor = spec.allConstructorsMap().get(constructor.getHashableName());
+ if (specConstructor.isDeprecated()) {
+ constructor.setDeprecatedSince(versionName);
+ }
+ }
+ }
}
}
@@ -163,6 +181,17 @@ private void versionFields(String versionName, ClassInfo spec, ClassInfo doc) {
if (field.getSince() == null && spec.allFields().containsKey(field.name())) {
field.setSince(versionName);
}
+
+ // Set deprecated version
+ if (field.isDeprecated() && field.getDeprecatedSince() == null) {
+ // Find matching field from API spec
+ if (spec.allFields().containsKey(field.name())) {
+ FieldInfo specField = spec.allFields().get(field.name());
+ if (specField.isDeprecated()) {
+ field.setDeprecatedSince(versionName);
+ }
+ }
+ }
}
}
@@ -171,6 +200,18 @@ private void versionFields(String versionName, ClassInfo spec, ClassInfo doc) {
*/
private void versionMethods(String versionName, ClassInfo spec, ClassInfo doc) {
for (MethodInfo method : doc.methods()) {
+
+ // Set deprecated version
+ if (method.isDeprecated() && method.getDeprecatedSince() == null) {
+ // Find matching method from API spec
+ if (spec.allMethods().containsKey(method.getHashableName())) {
+ MethodInfo specMethod = spec.allMethods().get(method.getHashableName());
+ if (specMethod.isDeprecated()) {
+ method.setDeprecatedSince(versionName);
+ }
+ }
+ }
+
if (method.getSince() != null) {
continue;
}
View
181 src/com/google/doclava/Stubs.java
@@ -31,12 +31,13 @@
import java.util.Set;
public class Stubs {
- public static void writeStubsAndApi(String stubsDir, String apiFile,
+ public static void writeStubsAndApi(String stubsDir, String apiFile, String keepListFile,
HashSet<String> stubPackages) {
// figure out which classes we need
final HashSet<ClassInfo> notStrippable = new HashSet<ClassInfo>();
ClassInfo[] all = Converter.allClasses();
PrintStream apiWriter = null;
+ PrintStream keepListWriter = null;
if (apiFile != null) {
try {
File xml = new File(apiFile);
@@ -47,6 +48,16 @@ public static void writeStubsAndApi(String stubsDir, String apiFile,
"Cannot open file for write.");
}
}
+ if (keepListFile != null) {
+ try {
+ File keepList = new File(keepListFile);
+ keepList.getParentFile().mkdirs();
+ keepListWriter = new PrintStream(new BufferedOutputStream(new FileOutputStream(keepList)));
+ } catch (FileNotFoundException e) {
+ Errors.error(Errors.IO_ERROR, new SourcePositionInfo(keepListFile, 0, 0),
+ "Cannot open file for write.");
+ }
+ }
// If a class is public or protected, not hidden, and marked as included,
// then we can't strip it
for (ClassInfo cl : all) {
@@ -126,8 +137,8 @@ public static void writeStubsAndApi(String stubsDir, String apiFile,
if (stubsDir != null) {
writeClassFile(stubsDir, notStrippable, cl);
}
- // build class list for xml file
- if (apiWriter != null) {
+ // build class list for api file or keep list file
+ if (apiWriter != null || keepListWriter != null) {
if (packages.containsKey(cl.containingPackage())) {
packages.get(cl.containingPackage()).add(cl);
} else {
@@ -145,6 +156,12 @@ public static void writeStubsAndApi(String stubsDir, String apiFile,
writeApi(apiWriter, packages, notStrippable);
apiWriter.close();
}
+
+ // write out the keep list
+ if (keepListWriter != null) {
+ writeKeepList(keepListWriter, packages, notStrippable);
+ keepListWriter.close();
+ }
}
public static void cantStripThis(ClassInfo cl, HashSet<ClassInfo> notStrippable, String why) {
@@ -1238,6 +1255,147 @@ static void writeFieldApi(PrintStream apiWriter, FieldInfo fi, String label) {
apiWriter.print("\n");
}
+ static void writeKeepList(PrintStream keepListWriter,
+ HashMap<PackageInfo, List<ClassInfo>> allClasses, HashSet<ClassInfo> notStrippable) {
+ // extract the set of packages, sort them by name, and write them out in that order
+ Set<PackageInfo> allClassKeys = allClasses.keySet();
+ PackageInfo[] allPackages = allClassKeys.toArray(new PackageInfo[allClassKeys.size()]);
+ Arrays.sort(allPackages, PackageInfo.comparator);
+
+ for (PackageInfo pack : allPackages) {
+ writePackageKeepList(keepListWriter, pack, allClasses.get(pack), notStrippable);
+ }
+ }
+
+ static void writePackageKeepList(PrintStream keepListWriter, PackageInfo pack,
+ Collection<ClassInfo> classList, HashSet<ClassInfo> notStrippable) {
+ // Work around the bogus "Array" class we invent for
+ // Arrays.copyOf's Class<? extends T[]> newType parameter. (http://b/2715505)
+ if (pack.name().equals(PackageInfo.DEFAULT_PACKAGE)) {
+ return;
+ }
+
+ ClassInfo[] classes = classList.toArray(new ClassInfo[classList.size()]);
+ Arrays.sort(classes, ClassInfo.comparator);
+ for (ClassInfo cl : classes) {
+ writeClassKeepList(keepListWriter, cl, notStrippable);
+ }
+ }
+
+ static void writeClassKeepList(PrintStream keepListWriter, ClassInfo cl,
+ HashSet<ClassInfo> notStrippable) {
+ keepListWriter.print("-keep class ");
+ keepListWriter.print(to$Class(cl.qualifiedName()));
+
+ keepListWriter.print(" {\n");
+
+ ArrayList<MethodInfo> constructors = cl.constructors();
+ Collections.sort(constructors, MethodInfo.comparator);
+ for (MethodInfo mi : constructors) {
+ writeConstructorKeepList(keepListWriter, mi);
+ }
+
+ keepListWriter.print("\n");
+
+ ArrayList<MethodInfo> methods = cl.allSelfMethods();
+ Collections.sort(methods, MethodInfo.comparator);
+ for (MethodInfo mi : methods) {
+ if (!methodIsOverride(notStrippable, mi)) {
+ writeMethodKeepList(keepListWriter, mi);
+ }
+ }
+
+ keepListWriter.print("\n");
+
+ ArrayList<FieldInfo> enums = cl.enumConstants();
+ Collections.sort(enums, FieldInfo.comparator);
+ for (FieldInfo fi : enums) {
+ writeFieldKeepList(keepListWriter, fi);
+ }
+
+ keepListWriter.print("\n");
+
+ ArrayList<FieldInfo> fields = cl.allSelfFields();
+ Collections.sort(fields, FieldInfo.comparator);
+ for (FieldInfo fi : fields) {
+ writeFieldKeepList(keepListWriter, fi);
+ }
+
+ keepListWriter.print("}\n\n");
+ }
+
+ static void writeConstructorKeepList(PrintStream keepListWriter, MethodInfo mi) {
+ keepListWriter.print(" ");
+ String name = mi.name();
+ name = name.replace(".", "$");
+ keepListWriter.print(name);
+
+ writeParametersKeepList(keepListWriter, mi, mi.parameters());
+ keepListWriter.print(";\n");
+ }
+
+ static void writeMethodKeepList(PrintStream keepListWriter, MethodInfo mi) {
+ keepListWriter.print(" ");
+ keepListWriter.print(mi.scope());
+ if (mi.isStatic()) {
+ keepListWriter.print(" static");
+ }
+ if (mi.isAbstract()) {
+ keepListWriter.print(" abstract");
+ }
+ if (mi.isSynchronized()) {
+ keepListWriter.print(" synchronized");
+ }
+ keepListWriter.print(" ");
+ if (mi.returnType() == null) {
+ keepListWriter.print("void");
+ } else {
+ keepListWriter.print(getCleanTypeName(mi.returnType()));
+ }
+ keepListWriter.print(" ");
+ keepListWriter.print(mi.name());
+
+ writeParametersKeepList(keepListWriter, mi, mi.parameters());
+
+ keepListWriter.print(";\n");
+ }
+
+ static void writeParametersKeepList(PrintStream keepListWriter, MethodInfo method,
+ ArrayList<ParameterInfo> params) {
+ keepListWriter.print("(");
+
+ for (ParameterInfo pi : params) {
+ if (pi != params.get(0)) {
+ keepListWriter.print(", ");
+ }
+ keepListWriter.print(getCleanTypeName(pi.type()));
+ }
+
+ keepListWriter.print(")");
+ }
+
+ static void writeFieldKeepList(PrintStream keepListWriter, FieldInfo fi) {
+ keepListWriter.print(" ");
+ keepListWriter.print(fi.scope());
+ if (fi.isStatic()) {
+ keepListWriter.print(" static");
+ }
+ if (fi.isTransient()) {
+ keepListWriter.print(" transient");
+ }
+ if (fi.isVolatile()) {
+ keepListWriter.print(" volatile");
+ }
+
+ keepListWriter.print(" ");
+ keepListWriter.print(getCleanTypeName(fi.type()) + fi.type().dimension());
+
+ keepListWriter.print(" ");
+ keepListWriter.print(fi.name());
+
+ keepListWriter.print(";\n");
+ }
+
static String fullParameterTypeName(MethodInfo method, TypeInfo type, boolean isLast) {
String fullTypeName = type.fullName(method.typeVariables());
if (isLast && method.isVarArgs()) {
@@ -1248,4 +1406,21 @@ static String fullParameterTypeName(MethodInfo method, TypeInfo type, boolean is
}
return fullTypeName;
}
+
+ static String to$Class(String name) {
+ int pos = 0;
+ while ((pos = name.indexOf('.', pos)) > 0) {
+ String n = name.substring(0, pos);
+ if (Converter.obtainClass(n) != null) {
+ return n + (name.substring(pos).replace('.', '$'));
+ }
+ pos = pos + 1;
+ }
+ return name;
+ }
+
+ static String getCleanTypeName(TypeInfo t) {
+ return t.isPrimitive() ? t.simpleTypeName() + t.dimension() :
+ to$Class(t.asClassInfo().qualifiedName() + t.dimension());
+ }
}
View
2 src/com/google/doclava/TypeInfo.java
@@ -219,7 +219,7 @@ private void makeHDFRecursive(Data data, String base, boolean qualified, boolean
data.setValue(base + ".link", mClass.htmlPage());
data.setValue(base + ".since", mClass.getSince());
} else {
- Doclava.federationTagger.tagAll(new ClassInfo[] {mClass});
+ Doclava.federationTagger.tag(mClass);
if (!mClass.getFederatedReferences().isEmpty()) {
FederatedSite site = mClass.getFederatedReferences().iterator().next();
data.setValue(base + ".link", site.linkFor(mClass.htmlPage()));
View
12 src/com/google/doclava/apicheck/ApiFile.java
@@ -432,21 +432,21 @@ public static Object parseValue(String type, String val) throws ApiParseExceptio
} else if ("long".equals(type)) {
return Long.valueOf(val.substring(0, val.length()-1));
} else if ("float".equals(type)) {
- if ("(1.0f/0.0f)".equals(val)) {
+ if ("(1.0f/0.0f)".equals(val) || "(1.0f / 0.0f)".equals(val)) {
return Float.POSITIVE_INFINITY;
- } else if ("(-1.0f/0.0f)".equals(val)) {
+ } else if ("(-1.0f/0.0f)".equals(val) || "(-1.0f / 0.0f)".equals(val)) {
return Float.NEGATIVE_INFINITY;
- } else if ("(0.0f/0.0f)".equals(val)) {
+ } else if ("(0.0f/0.0f)".equals(val) || "(0.0f / 0.0f)".equals(val)) {
return Float.NaN;
} else {
return Float.valueOf(val);
}
} else if ("double".equals(type)) {
- if ("(1.0/0.0)".equals(val)) {
+ if ("(1.0/0.0)".equals(val) || "(1.0 / 0.0)".equals(val)) {
return Double.POSITIVE_INFINITY;
- } else if ("(-1.0/0.0)".equals(val)) {
+ } else if ("(-1.0/0.0)".equals(val) || "(-1.0 / 0.0)".equals(val)) {
return Double.NEGATIVE_INFINITY;
- } else if ("(0.0/0.0)".equals(val)) {
+ } else if ("(0.0/0.0)".equals(val) || "(0.0 / 0.0)".equals(val)) {
return Double.NaN;
} else {
return Double.valueOf(val);

0 comments on commit 5f74e82

Please sign in to comment.