am 0901a614: another fix to remove generics info from sidenav. they were still appearing in the nav while viewing a package page. bug: 7242415
* commit '0901a614686e63ca81e0c790f22de1fae09c2c0c':
another fix to remove generics info from sidenav. they were still appearing in the nav while viewing a package page. bug: 7242415
diff --git a/android-changes.txt b/android-changes.txt
index 025bcd8..a62b071 100644
--- a/android-changes.txt
+++ b/android-changes.txt
@@ -1,6 +1,12 @@
Changes in this version relative to http://doclava.googlecode.com/
------------------------------------------------------------------
+* Added a new command line option -showAnnotation <@interface classname>,
+ which takes in a fully qualified annotation classname. The specified
+ annotation will override any @hide annotations within the javadoc. To
+ specify multiple annotations to override @hide, use multiple
+ -showAnnotation options.
+
* Modified the Java stub generator code to write out annotations for
methods and fields as well, not just classes. This meant adding a
writeAnnotations call to writeMethod and to writeField
diff --git a/src/com/google/doclava/ClassInfo.java b/src/com/google/doclava/ClassInfo.java
index f4f2853..6e5aab2 100644
--- a/src/com/google/doclava/ClassInfo.java
+++ b/src/com/google/doclava/ClassInfo.java
@@ -44,13 +44,13 @@
return a.qualifiedName().compareTo(b.qualifiedName());
}
};
-
+
/**
* Constructs a stub representation of a class.
*/
public ClassInfo(String qualifiedName) {
super("", SourcePositionInfo.UNKNOWN);
-
+
mQualifiedName = qualifiedName;
if (qualifiedName.lastIndexOf('.') != -1) {
mName = qualifiedName.substring(qualifiedName.lastIndexOf('.') + 1);
@@ -1195,6 +1195,13 @@
if (pkg != null && pkg.isHidden()) {
return true;
}
+ if (cl.annotations() != null) {
+ for (AnnotationInstanceInfo info : cl.annotations()) {
+ if (Doclava.showAnnotations.contains(info.type().qualifiedName())) {
+ return false;
+ }
+ }
+ }
if (cl.comment().isHidden()) {
return true;
}
@@ -1244,7 +1251,7 @@
return null;
}
-
+
public boolean supportsMethod(MethodInfo method) {
for (MethodInfo m : methods()) {
if (m.getHashableName().equals(method.getHashableName())) {
@@ -1373,7 +1380,7 @@
}
return null;
}
-
+
public String scope() {
if (isPublic()) {
return "public";
@@ -1467,7 +1474,7 @@
private String mReasonIncluded;
private ArrayList<MethodInfo> mNonWrittenConstructors;
private boolean mIsDeprecated;
-
+
// TODO: Temporary members from apicheck migration.
private HashMap<String, MethodInfo> mApiCheckConstructors = new HashMap<String, MethodInfo>();
private HashMap<String, MethodInfo> mApiCheckMethods = new HashMap<String, MethodInfo>();
@@ -1476,7 +1483,7 @@
// Resolutions
private ArrayList<Resolution> mResolutions;
-
+
/**
* Returns true if {@code cl} implements the interface {@code iface} either by either being that
* interface, implementing that interface or extending a type that implements the interface.
@@ -1538,7 +1545,7 @@
* Returns all methods defined directly in this class. For a list of all
* methods supported by this class, see {@link #methods()}.
*/
-
+
public Map<String, MethodInfo> allMethods() {
return mApiCheckMethods;
}
@@ -1553,7 +1560,7 @@
}
return result;
}
-
+
public String superclassName() {
if (mSuperclass == null) {
if (mQualifiedName.equals("java.lang.Object")) {
@@ -1563,11 +1570,11 @@
}
return mSuperclass.mQualifiedName;
}
-
+
public void setAnnotations(ArrayList<AnnotationInstanceInfo> annotations) {
mAnnotations = annotations;
}
-
+
public boolean isConsistent(ClassInfo cl) {
boolean consistent = true;
@@ -1727,7 +1734,7 @@
return consistent;
}
-
+
// Find a superclass implementation of the given method.
public static MethodInfo overriddenMethod(MethodInfo candidate, ClassInfo newClassObj) {
if (newClassObj == null) {
@@ -1758,7 +1765,7 @@
}
return ClassInfo.interfaceMethod(candidate, newClassObj.mSuperclass);
}
-
+
public boolean hasConstructor(MethodInfo constructor) {
String name = constructor.getHashableName();
for (MethodInfo ctor : mApiCheckConstructors.values()) {
diff --git a/src/com/google/doclava/Doclava.java b/src/com/google/doclava/Doclava.java
index 4bdf245..26759c3 100644
--- a/src/com/google/doclava/Doclava.java
+++ b/src/com/google/doclava/Doclava.java
@@ -74,6 +74,7 @@
public static SinceTagger sinceTagger = new SinceTagger();
public static HashSet<String> knownTags = new HashSet<String>();
public static FederationTagger federationTagger = new FederationTagger();
+ public static Set<String> showAnnotations = new HashSet<String>();
private static boolean generateDocs = true;
private static boolean parseComments = false;
private static String yamlNavFile = null;
@@ -175,6 +176,8 @@
}
} else if (a[0].equals("-keeplist")) {
keepListFile = a[1];
+ } else if (a[0].equals("-showAnnotation")) {
+ showAnnotations.add(a[1]);
} else if (a[0].equals("-proguard")) {
proguardFile = a[1];
} else if (a[0].equals("-proofread")) {
@@ -502,6 +505,9 @@
if (option.equals("-keeplist")) {
return 2;
}
+ if (option.equals("-showAnnotation")) {
+ return 2;
+ }
if (option.equals("-proguard")) {
return 2;
}
diff --git a/src/com/google/doclava/MemberInfo.java b/src/com/google/doclava/MemberInfo.java
index 5600749..e5cc7a2 100644
--- a/src/com/google/doclava/MemberInfo.java
+++ b/src/com/google/doclava/MemberInfo.java
@@ -42,6 +42,18 @@
public abstract boolean isExecutable();
+ @Override
+ public boolean isHidden() {
+ if (mAnnotations != null) {
+ for (AnnotationInstanceInfo info : mAnnotations) {
+ if (Doclava.showAnnotations.contains(info.type().qualifiedName())) {
+ return false;
+ }
+ }
+ }
+ return super.isHidden();
+ }
+
public String anchor() {
if (mSignature != null) {
return mName + mSignature;