diff options
author | Andrew Sapperstein <asapperstein@google.com> | 2020-05-01 13:46:35 -0700 |
---|---|---|
committer | Andrew Sapperstein <asapperstein@google.com> | 2020-05-05 00:25:09 +0000 |
commit | f906f9c65a92149df0168cb8b2ec155c11e5857b (patch) | |
tree | f2e3ddd0adab33443a36facab5fb48d0c81bef52 | |
parent | 0b7f6c6aaab2934e7ca6dfc5938bbd4849f4ae99 (diff) | |
download | doclava-f906f9c65a92149df0168cb8b2ec155c11e5857b.tar.gz |
Add workaround for androidx prebuilt references
androidx generates some of their docs against prebuilts, which
can't be updated in sync with the doclava changes to inner class
constructor references. This change adds a flag that is off by default
that will enable us to conditionally use the old workaround for
referring to inner class contructor references.
This was an attempt to scope the workaround to the smallest possible
applications to the workaround.
Once we have updated prebuilts, this workaround can be removed.
Bug: 6963924
Test: ./gradlew publicDocsTask and ./gradlew disttipOfTreeDocs
Change-Id: I87098a7497e6de51b93baae97a8ca8fdefc6129d
Merged-In: I87098a7497e6de51b93baae97a8ca8fdefc6129d
-rw-r--r-- | src/com/google/doclava/Converter.java | 22 | ||||
-rw-r--r-- | src/com/google/doclava/Doclava.java | 7 |
2 files changed, 28 insertions, 1 deletions
diff --git a/src/com/google/doclava/Converter.java b/src/com/google/doclava/Converter.java index cf14237..0e1a4dd 100644 --- a/src/com/google/doclava/Converter.java +++ b/src/com/google/doclava/Converter.java @@ -501,9 +501,29 @@ public class Converter { return result; } else { ConstructorDoc m = (ConstructorDoc) o; + String name = m.name(); + if (Doclava.SUPPRESS_REFERENCE_ERRORS) { + // Workaround for a JavaDoc behavior change introduced in OpenJDK 8 that breaks + // links in documentation and the content of API files like current.txt. + // http://b/18051133. + ClassDoc containingClass = m.containingClass(); + if (containingClass.containingClass() != null) { + // This should detect the new behavior and be bypassed otherwise. + String qualName = containingClass.qualifiedName(); + if (!name.contains(".") + && ("androidx.core.app.NotificationCompat.MessagingStyle.Message".equals(qualName) + || "androidx.leanback.widget.GuidedAction.Builder".equals(qualName) + || "androidx.leanback.widget.RowHeaderPresenter.ViewHolder".equals(qualName))) { + // Constructors of inner classes do not contain the name of the enclosing class + // with OpenJDK 8. This simulates the old behavior: + name = containingClass.name(); + } + } + } + // End of workaround. MethodInfo result = new MethodInfo(m.getRawCommentText(), new ArrayList<TypeInfo>(Arrays.asList(Converter.convertTypes(m.typeParameters()))), - m.name(), m.signature(), Converter.obtainClass(m.containingClass()), Converter + name, m.signature(), Converter.obtainClass(m.containingClass()), Converter .obtainClass(m.containingClass()), m.isPublic(), m.isProtected(), m .isPackagePrivate(), m.isPrivate(), m.isFinal(), m.isStatic(), m.isSynthetic(), false, m.isSynchronized(), m.isNative(), false/*isDefault*/, false, "constructor", m.flatSignature(), diff --git a/src/com/google/doclava/Doclava.java b/src/com/google/doclava/Doclava.java index 049e93e..493676c 100644 --- a/src/com/google/doclava/Doclava.java +++ b/src/com/google/doclava/Doclava.java @@ -80,6 +80,8 @@ public class Doclava { public static boolean USE_DEVSITE_LOCALE_OUTPUT_PATHS = false; /* generate navtree.js without other docs */ public static boolean NAVTREE_ONLY = false; + /* Suppress errors in LinkReference.parse (@see/@link) errors. */ + public static boolean SUPPRESS_REFERENCE_ERRORS = false; /* Generate reference navtree.js with all inherited members */ public static boolean AT_LINKS_NAVTREE = false; public static boolean METALAVA_API_SINCE = false; @@ -406,6 +408,8 @@ public class Doclava { manifestFile = a[1]; } else if (a[0].equals("-compatconfig")) { compatConfig = a[1]; + } else if (a[0].equals("-suppressReferenceErrors")) { + SUPPRESS_REFERENCE_ERRORS = true; } } @@ -969,6 +973,9 @@ public class Doclava { if (option.equals("-compatconfig")) { return 2; } + if (option.equals("-suppressReferenceErrors")) { + return 1; + } return 0; } public static boolean validOptions(String[][] options, DocErrorReporter r) { |