summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--build.gradle7
-rw-r--r--res/assets/templates-sdk/assets/css/default.css17
-rw-r--r--res/assets/templates-sdk/class.cs25
-rw-r--r--src/com/google/doclava/Doclava.java45
-rw-r--r--src/com/google/doclava/NavTree.java1
-rw-r--r--src/com/google/doclava/Stubs.java49
6 files changed, 75 insertions, 69 deletions
diff --git a/build.gradle b/build.gradle
index cf0c9d4..3096e0e 100644
--- a/build.gradle
+++ b/build.gradle
@@ -22,6 +22,13 @@ apply plugin: 'maven'
group = 'com.android'
version = '1.0.6'
+def currentJvmVersion = org.gradle.api.JavaVersion.current()
+if (currentJvmVersion.getMajorVersion() != "8") {
+ throw new Exception("Unsupported java version '" + currentJvmVersion.toString() + "'. Please install java 8.\n" +
+"\n" +
+"If you have already installed java 8, you can instruct Gradle to use it by setting the environment variable JAVA_HOME equal to its file path.")
+}
+
/*
* With the build server you are given two env variables:
* 1. The OUT_DIR is a temporary directory you can use to put things during the build.
diff --git a/res/assets/templates-sdk/assets/css/default.css b/res/assets/templates-sdk/assets/css/default.css
index 65d7fde..2abfe73 100644
--- a/res/assets/templates-sdk/assets/css/default.css
+++ b/res/assets/templates-sdk/assets/css/default.css
@@ -2552,25 +2552,10 @@ div.design-announce p {
}
.expandable {
- height:34px;
+ height:auto;
padding-left:20px;
position:relative;
}
-.expandable:before {
- content: '';
- background-image: url(../images/styles/disclosure_down.png);
- background-repeat:no-repeat;
- background-position: -12px -9px;
- width: 20px;
- height: 20px;
- display: inline-block;
- position: absolute;
- top: 0;
- left: 0; }
-}
-.expandable.expanded:before {
- background-image: url(../images/styles/disclosure_up.png);
-}
/* notice box for cross links between Design/Develop docs */
a.notice-developers-video,
diff --git a/res/assets/templates-sdk/class.cs b/res/assets/templates-sdk/class.cs
index 9b5a370..5fb2a9d 100644
--- a/res/assets/templates-sdk/class.cs
+++ b/res/assets/templates-sdk/class.cs
@@ -685,31 +685,6 @@ if:subcount(class.subclasses.direct) && !class.subclasses.hidden ?>
</div><!-- end jd-content -->
-<?cs if:devsite ?>
-
-<div class="data-reference-resources-wrapper">
- <?cs if:subcount(class.package) ?>
- <ul data-reference-resources>
- <?cs call:list("Annotations", class.package.annotations) ?>
- <?cs call:list("Interfaces", class.package.interfaces) ?>
- <?cs call:list("Classes", class.package.classes) ?>
- <?cs call:list("Enums", class.package.enums) ?>
- <?cs call:list("Exceptions", class.package.exceptions) ?>
- <?cs call:list("Errors", class.package.errors) ?>
- </ul>
- <?cs elif:subcount(package) ?>
- <ul data-reference-resources>
- <?cs call:class_link_list("Annotations", package.annotations) ?>
- <?cs call:class_link_list("Interfaces", package.interfaces) ?>
- <?cs call:class_link_list("Classes", package.classes) ?>
- <?cs call:class_link_list("Enums", package.enums) ?>
- <?cs call:class_link_list("Exceptions", package.exceptions) ?>
- <?cs call:class_link_list("Errors", package.errors) ?>
- </ul>
- <?cs /if ?>
-</div>
-<?cs /if ?>
-
<?cs if:!devsite ?>
<?cs include:"footer.cs" ?>
<?cs include:"trailer.cs" ?>
diff --git a/src/com/google/doclava/Doclava.java b/src/com/google/doclava/Doclava.java
index 53afe55..564f104 100644
--- a/src/com/google/doclava/Doclava.java
+++ b/src/com/google/doclava/Doclava.java
@@ -121,6 +121,7 @@ public class Doclava {
public static boolean referenceOnly = false;
public static boolean staticOnly = false;
public static boolean yamlV2 = false; /* whether to build the new version of the yaml file */
+ public static boolean devsite = false; /* whether to build docs for devsite */
public static AuxSource auxSource = new EmptyAuxSource();
public static Linter linter = new EmptyLinter();
public static boolean android = false;
@@ -193,6 +194,7 @@ public class Doclava {
HashSet<String> stubPackages = null;
HashSet<String> stubImportPackages = null;
boolean stubSourceOnly = false;
+ boolean keepStubComments = false;
ArrayList<String> knownTagsFiles = new ArrayList<String>();
root = r;
@@ -301,6 +303,8 @@ public class Doclava {
}
} else if (a[0].equals("-stubsourceonly")) {
stubSourceOnly = true;
+ } else if (a[0].equals("-keepstubcomments")) {
+ keepStubComments = true;
} else if (a[0].equals("-sdkvalues")) {
sdkValuePath = a[1];
} else if (a[0].equals("-api")) {
@@ -377,6 +381,7 @@ public class Doclava {
} else if (a[0].equals("-yamlV2")) {
yamlV2 = true;
} else if (a[0].equals("-devsite")) {
+ devsite = true;
// Don't copy any assets to devsite output
includeAssets = false;
USE_DEVSITE_LOCALE_OUTPUT_PATHS = true;
@@ -386,7 +391,8 @@ public class Doclava {
System.out.println(" ... Generating static html only for devsite");
}
if (yamlNavFile == null) {
- yamlNavFile = "_book.yaml";
+ // Use _toc.yaml as default to avoid clobbering possible manual _book.yaml files
+ yamlNavFile = "_toc.yaml";
}
} else if (a[0].equals("-android")) {
auxSource = new AndroidAuxSource();
@@ -424,9 +430,8 @@ public class Doclava {
}
// If no custom template path is provided, and this is a devsite build,
// then use the bundled templates-sdk/ files by default
- if (templates.isEmpty() && USE_DEVSITE_LOCALE_OUTPUT_PATHS) {
+ if (templates.isEmpty() && devsite) {
resourceLoaders.add(new ClassResourceLoader(Doclava.class, "/assets/templates-sdk"));
- System.out.println("\n######### OK, Using templates-sdk ############\n");
}
templates = ClearPage.getBundledTemplateDirs();
@@ -447,7 +452,11 @@ public class Doclava {
if (NAVTREE_ONLY) {
if (AT_LINKS_NAVTREE) {
AtLinksNavTree.writeAtLinksNavTree(javadocDir);
+ } else if (yamlV2) {
+ // Generate DAC-formatted left-nav for devsite
+ NavTree.writeYamlTree2(javadocDir, yamlNavFile);
} else {
+ // This shouldn't happen; this is the legacy DAC left nav file
NavTree.writeNavTree(javadocDir, "");
}
return true;
@@ -518,17 +527,19 @@ public class Doclava {
} else if(gcmRef){
refPrefix = "gcm-";
}
- NavTree.writeNavTree(javadocDir, refPrefix);
// Write yaml tree.
- if (yamlNavFile != null){
- NavTree.writeYamlTree(javadocDir, yamlNavFile);
+ if (yamlNavFile != null) {
if (yamlV2) {
- // Generate both for good measure, to make transitions easier, but change the filename
- // for the new one so there's yet another explicit opt-in required by fixing the name.
- yamlNavFile = "_NEW" + yamlNavFile;
+ // Generate DAC-formatted left-nav for devsite
NavTree.writeYamlTree2(javadocDir, yamlNavFile);
+ } else {
+ // Generate legacy devsite left-nav (shows sub-classes nested under parent class)
+ NavTree.writeYamlTree(javadocDir, yamlNavFile);
}
+ } else {
+ // This shouldn't happen; this is the legacy DAC left nav file
+ NavTree.writeNavTree(javadocDir, refPrefix);
}
// Packages Pages
@@ -556,7 +567,7 @@ public class Doclava {
if (!sTaglist.isEmpty()) {
PageMetadata.WriteListByLang(sTaglist);
// For devsite (ds) reference only, write samples_metadata to out dir
- if ((USE_DEVSITE_LOCALE_OUTPUT_PATHS) && (!DEVSITE_STATIC_ONLY)) {
+ if ((devsite) && (!DEVSITE_STATIC_ONLY)) {
PageMetadata.WriteSamplesListByLang(sTaglist);
}
}
@@ -568,7 +579,7 @@ public class Doclava {
|| privateApiFile != null || privateDexApiFile != null || apiMappingFile != null) {
Stubs.writeStubsAndApi(stubsDir, apiFile, dexApiFile, proguardFile, removedApiFile,
removedDexApiFile, exactApiFile, privateApiFile, privateDexApiFile, apiMappingFile,
- stubPackages, stubImportPackages, stubSourceOnly);
+ stubPackages, stubImportPackages, stubSourceOnly, keepStubComments);
}
Errors.printErrors();
@@ -853,6 +864,9 @@ public class Doclava {
if (option.equals("-stubsourceonly")) {
return 1;
}
+ if (option.equals("-keepstubcomments")) {
+ return 1;
+ }
if (option.equals("-sdkvalues")) {
return 2;
}
@@ -1201,7 +1215,7 @@ public class Doclava {
// Write the lists for JD documents (if there are HTML directories to process)
// Skip this for devsite builds
- if ((inputPathHtmlDirs.size() > 0) && (!USE_DEVSITE_LOCALE_OUTPUT_PATHS)) {
+ if ((inputPathHtmlDirs.size() > 0) && (!devsite)) {
Data jddata = makeHDF();
Iterator counter = new Iterator();
for (String htmlDir : inputPathHtmlDirs) {
@@ -1563,8 +1577,11 @@ public class Doclava {
setPageTitle(data, "Class Index");
ClearPage.write(data, "classes.cs", packageDir + "classes" + htmlExtension);
- // Index page redirects to the classes.html page, so use the same directory
- writeIndex(packageDir);
+ if (!devsite) {
+ // Index page redirects to the classes.html page, so use the same directory
+ // This page is not needed for devsite builds, which should instead use _redirects.yaml
+ writeIndex(packageDir);
+ }
}
// we use the word keywords because "index" means something else in html land
diff --git a/src/com/google/doclava/NavTree.java b/src/com/google/doclava/NavTree.java
index b4861c8..3375df5 100644
--- a/src/com/google/doclava/NavTree.java
+++ b/src/com/google/doclava/NavTree.java
@@ -26,6 +26,7 @@ import java.util.TreeMap;
public class NavTree {
+ /* @deprecated This method was used for an older version of DAC, circa 2012, retired May 2018 */
public static void writeNavTree(String dir, String refPrefix) {
List<Node> children = new ArrayList<Node>();
for (PackageInfo pkg : Doclava.choosePackages()) {
diff --git a/src/com/google/doclava/Stubs.java b/src/com/google/doclava/Stubs.java
index 0ef3749..930d52c 100644
--- a/src/com/google/doclava/Stubs.java
+++ b/src/com/google/doclava/Stubs.java
@@ -49,7 +49,8 @@ public class Stubs {
public static void writeStubsAndApi(String stubsDir, String apiFile, String dexApiFile,
String keepListFile, String removedApiFile, String removedDexApiFile, String exactApiFile,
String privateApiFile, String privateDexApiFile, String apiMappingFile,
- HashSet<String> stubPackages, HashSet<String> stubImportPackages, boolean stubSourceOnly) {
+ HashSet<String> stubPackages, HashSet<String> stubImportPackages, boolean stubSourceOnly,
+ boolean keepStubComments) {
// figure out which classes we need
final HashSet<ClassInfo> notStrippable = new HashSet<ClassInfo>();
Collection<ClassInfo> all = Converter.allClasses();
@@ -259,7 +260,7 @@ public class Stubs {
if (shouldWriteStub(cl.containingPackage().name(), stubPackages, stubPackageWildcards)) {
// write out the stubs
if (stubsDir != null) {
- writeClassFile(stubsDir, notStrippable, cl);
+ writeClassFile(stubsDir, notStrippable, cl, keepStubComments);
}
// build class list for api file or keep list file
if (apiWriter != null || dexApiWriter != null || keepListWriter != null) {
@@ -588,7 +589,7 @@ public class Stubs {
return dir + cl.name() + ".java";
}
- static void writeClassFile(String stubsDir, HashSet<ClassInfo> notStrippable, ClassInfo cl) {
+ static void writeClassFile(String stubsDir, HashSet<ClassInfo> notStrippable, ClassInfo cl, boolean keepStubComments) {
// inner classes are written by their containing class
if (cl.containingClass() != null) {
return;
@@ -608,7 +609,7 @@ public class Stubs {
PrintStream stream = null;
try {
stream = new PrintStream(new BufferedOutputStream(new FileOutputStream(file)));
- writeClassFile(stream, notStrippable, cl);
+ writeClassFile(stream, notStrippable, cl, keepStubComments);
} catch (FileNotFoundException e) {
System.err.println("error writing file: " + filename);
} finally {
@@ -618,7 +619,7 @@ public class Stubs {
}
}
- static void writeClassFile(PrintStream stream, HashSet<ClassInfo> notStrippable, ClassInfo cl) {
+ static void writeClassFile(PrintStream stream, HashSet<ClassInfo> notStrippable, ClassInfo cl, boolean keepStubComments) {
PackageInfo pkg = cl.containingPackage();
if (cl.containingClass() == null) {
stream.print(parseLicenseHeader(cl.position()));
@@ -626,7 +627,7 @@ public class Stubs {
if (pkg != null) {
stream.println("package " + pkg.name() + ";");
}
- writeClass(stream, notStrippable, cl);
+ writeClass(stream, notStrippable, cl, keepStubComments);
}
private static String parseLicenseHeader(/* @Nonnull */ SourcePositionInfo positionInfo) {
@@ -677,7 +678,11 @@ public class Stubs {
return builder.toString();
}
- static void writeClass(PrintStream stream, HashSet<ClassInfo> notStrippable, ClassInfo cl) {
+ static void writeClass(PrintStream stream, HashSet<ClassInfo> notStrippable, ClassInfo cl, boolean keepStubComments) {
+ if (keepStubComments) {
+ writeComment(stream, cl);
+ }
+
writeAnnotations(stream, cl.annotations(), cl.isDeprecated());
stream.print(cl.scope() + " ");
@@ -752,14 +757,14 @@ public class Stubs {
for (ClassInfo inner : cl.getRealInnerClasses()) {
if (notStrippable.contains(inner) && !inner.isDocOnly()) {
- writeClass(stream, notStrippable, inner);
+ writeClass(stream, notStrippable, inner, keepStubComments);
}
}
for (MethodInfo method : cl.constructors()) {
if (!method.isDocOnly()) {
- writeMethod(stream, method, true);
+ writeMethod(stream, method, true, keepStubComments);
}
}
@@ -806,7 +811,7 @@ public class Stubs {
}
}
if (!method.isDocOnly()) {
- writeMethod(stream, method, false);
+ writeMethod(stream, method, false, keepStubComments);
}
}
// Write all methods that are hidden or removed, but override abstract methods or interface methods.
@@ -823,7 +828,7 @@ public class Stubs {
(overriddenMethod.isAbstract() || overriddenMethod.containingClass().isInterface())) {
method.setReason("1:" + classContainingMethod.qualifiedName());
cl.addMethod(method);
- writeMethod(stream, method, false);
+ writeMethod(stream, method, false, keepStubComments);
}
}
@@ -835,7 +840,7 @@ public class Stubs {
for (FieldInfo field : cl.selfFields()) {
if (!field.isDocOnly()) {
- writeField(stream, field);
+ writeField(stream, field, keepStubComments);
}
}
@@ -853,7 +858,10 @@ public class Stubs {
stream.println("}");
}
- static void writeMethod(PrintStream stream, MethodInfo method, boolean isConstructor) {
+ static void writeMethod(PrintStream stream, MethodInfo method, boolean isConstructor, boolean keepStubComments) {
+ if (keepStubComments) {
+ writeComment(stream, method);
+ }
String comma;
writeAnnotations(stream, method.annotations(), method.isDeprecated());
@@ -924,7 +932,10 @@ public class Stubs {
}
}
- static void writeField(PrintStream stream, FieldInfo field) {
+ static void writeField(PrintStream stream, FieldInfo field, boolean keepStubComments) {
+ if (keepStubComments) {
+ writeComment(stream, field);
+ }
writeAnnotations(stream, field.annotations(), field.isDeprecated());
stream.print(field.scope() + " ");
@@ -1090,6 +1101,16 @@ public class Stubs {
stream.println(";");
}
+ static void writeComment(PrintStream stream, DocInfo doc) {
+ if (!doc.isHiddenOrRemoved() && !doc.comment().isDocOnly() && !"".equals(doc.getRawCommentText())) {
+ String newLineSeparator = System.getProperty("line.separator");
+ stream.println("/**");
+ stream.print(" * ");
+ stream.println(doc.getRawCommentText().replace(newLineSeparator, newLineSeparator + " *"));
+ stream.println(" */");
+ }
+ }
+
public static void writeXml(PrintStream xmlWriter, Collection<PackageInfo> pkgs, boolean strip) {
if (strip) {
Stubs.writeXml(xmlWriter, pkgs);