Document Bazel's java_{binary,library,plugin,import} rules.

--
MOS_MIGRATED_REVID=88226575
diff --git a/src/main/java/com/google/devtools/build/lib/bazel/rules/java/BazelJavaBinaryRule.java b/src/main/java/com/google/devtools/build/lib/bazel/rules/java/BazelJavaBinaryRule.java
index 279cbdb..77bb218 100644
--- a/src/main/java/com/google/devtools/build/lib/bazel/rules/java/BazelJavaBinaryRule.java
+++ b/src/main/java/com/google/devtools/build/lib/bazel/rules/java/BazelJavaBinaryRule.java
@@ -31,13 +31,46 @@
  * Rule definition for the java_binary rule.
  */
 @BlazeRule(name = "java_binary",
-             ancestors = { BaseJavaBinaryRule.class,
-                           BazelBaseRuleClasses.BinaryBaseRule.class },
-             factoryClass = BazelJavaBinary.class)
+           ancestors = { BaseJavaBinaryRule.class,
+                         BazelBaseRuleClasses.BinaryBaseRule.class },
+           factoryClass = BazelJavaBinary.class)
 public final class BazelJavaBinaryRule implements RuleDefinition {
   @Override
   public RuleClass build(Builder builder, RuleDefinitionEnvironment env) {
+    /* <!-- #BLAZE_RULE(java_binary).NAME -->
+    <br/>It is good practice to use the name of the source file that is the main entry point of the
+    application (minus the extension). For example, if your entry point is called
+    <code>Main.java</code>, then your name could be <code>Main</code>.
+    <!-- #END_BLAZE_RULE.NAME --> */
     return builder
+        /* <!-- #BLAZE_RULE(java_binary).IMPLICIT_OUTPUTS -->
+        <ul>
+          <li><code><var>name</var>.jar</code>: A Java archive, containing the class files and other
+            resources corresponding to the binary's direct dependencies.</li>
+          <li><code><var>name</var>-src.jar</code>: An archive containing the sources ("source
+            jar").</li>
+          <li><code><var>name</var>_deploy.jar</code>: A Java archive suitable for deployment (only
+            built if explicitly requested).
+            <p>
+              Building the <code><var>name</var>&gt;_deploy.jar</code> target for your rule creates
+              a self-contained jar file with a manifest that allows it to be run with the <code>java
+              -jar</code> command or with the wrapper script's <code>--singlejar</code> option.
+              Using the wrapper script is preferred to <code>java -jar</code> because it also passes
+              the <a href="#java_binary.jvm_flags">JVM flags</a> and the options to load native
+              libraries.
+            </p>
+            <p>
+              The deploy jar contains all the classes that would be found by a classloader that
+              searched the classpath from the binary's wrapper script from beginning to end. It also
+              contains the native libraries needed for dependencies. These are automatically loaded
+              into the JVM at runtime.
+            </p>
+          </li>
+          <li><code><var>name</var>_deploy-src.jar</code>: An archive containing the sources
+            collected from the transitive closure of the target. These will match the classes in the
+            <code>deploy.jar</code> except where jars have no matching source jar.</li>
+        </ul>
+        <!-- #END_BLAZE_RULE.IMPLICIT_OUTPUTS --> */
         .setImplicitOutputsFunction(BazelJavaRuleClasses.JAVA_BINARY_IMPLICIT_OUTPUTS)
         .override(attr("$is_executable", BOOLEAN).nonconfigurable("automatic").value(
             new Attribute.ComputedDefault() {
@@ -49,3 +82,56 @@
         .build();
   }
 }
+
+/*<!-- #BLAZE_RULE (NAME = java_binary, TYPE = BINARY, FAMILY = Java) -->
+
+${ATTRIBUTE_SIGNATURE}
+
+<p>
+  Builds a Java archive ("jar file"), plus a wrapper shell script with the same name as the rule.
+  The wrapper shell script uses a classpath that includes, among other things, a jar file for each
+  library on which the binary depends.
+</p>
+<p>
+  The wrapper script accepts several unique flags. Refer to
+  <code>//src/main/java/com/google/devtools/build/lib/bazel/rules/java/java_stub_template.txt</code>
+  for a list of configurable flags and environment variables accepted by the wrapper.
+</p>
+
+${IMPLICIT_OUTPUTS}
+
+<p>
+  A <code>deps</code> attribute is not allowed in a <code>java_binary</code> rule without
+  <a href="#java_binary.srcs"><code>srcs</code></a>; such a rule requires a
+  <a href="#java_binary.main_class"><code>main_class</code></a> provided by
+  <a href="#java_binary.runtime_deps"><code>runtime_deps</code></a>.
+</p>
+
+<p>The following code snippet illustrates a common mistake:</p>
+
+<pre class="code">
+java_binary(
+    name = "DontDoThis",
+    srcs = [
+        <var>...</var>,
+        <code class="deprecated">"GeneratedJavaFile.java"</code>,  # a generated .java file
+    ],
+    deps = [<code class="deprecated">":generating_rule",</code>],  # rule that generates that file
+)
+</pre>
+
+<p>Do this instead:</p>
+
+<pre class="code">
+java_binary(
+    name = "DoThisInstead",
+    srcs = [
+        <var>...</var>,
+        ":generating_rule",
+    ],
+)
+</pre>
+
+${ATTRIBUTE_DEFINITION}
+
+<!-- #END_BLAZE_RULE -->*/
diff --git a/src/main/java/com/google/devtools/build/lib/bazel/rules/java/BazelJavaImportRule.java b/src/main/java/com/google/devtools/build/lib/bazel/rules/java/BazelJavaImportRule.java
index 132df23..4f6a585 100644
--- a/src/main/java/com/google/devtools/build/lib/bazel/rules/java/BazelJavaImportRule.java
+++ b/src/main/java/com/google/devtools/build/lib/bazel/rules/java/BazelJavaImportRule.java
@@ -51,3 +51,29 @@
 
   }
 }
+
+/*<!-- #BLAZE_RULE (NAME = java_import, TYPE = LIBRARY, FAMILY = Java) -->
+
+${ATTRIBUTE_SIGNATURE}
+
+<p>
+  This rule allows the use of precompiled JAR files as libraries for
+  <code><a href="#java_library">java_library</a></code> rules.
+</p>
+
+${ATTRIBUTE_DEFINITION}
+
+<h4 id="java_import_examples">Examples</h4>
+
+<pre class="code">
+    java_import(
+        name = "maven_model",
+        jars = [
+            "maven_model/maven-aether-provider-3.2.3.jar",
+            "maven_model/maven-model-3.2.3.jar",
+            "maven_model/maven-model-builder-3.2.3.jar",
+        ],
+    )
+</pre>
+
+<!-- #END_BLAZE_RULE -->*/
diff --git a/src/main/java/com/google/devtools/build/lib/bazel/rules/java/BazelJavaLibraryRule.java b/src/main/java/com/google/devtools/build/lib/bazel/rules/java/BazelJavaLibraryRule.java
index 04c8a0f..0c340de 100644
--- a/src/main/java/com/google/devtools/build/lib/bazel/rules/java/BazelJavaLibraryRule.java
+++ b/src/main/java/com/google/devtools/build/lib/bazel/rules/java/BazelJavaLibraryRule.java
@@ -38,14 +38,126 @@
   public RuleClass build(Builder builder, final RuleDefinitionEnvironment env) {
 
     return builder
+        /* <!-- #BLAZE_RULE(java_library).IMPLICIT_OUTPUTS -->
+        <ul>
+          <li><code>lib<var>name</var>.jar</code>: A Java archive containing the class files.</li>
+          <li><code>lib<var>name</var>-src.jar</code>: An archive containing the sources ("source
+            jar").</li>
+        </ul>
+        <!-- #END_BLAZE_RULE.IMPLICIT_OUTPUTS --> */
         .setImplicitOutputsFunction(BazelJavaRuleClasses.JAVA_LIBRARY_IMPLICIT_OUTPUTS)
+
+        /* <!-- #BLAZE_RULE(java_library).ATTRIBUTE(data) -->
+        The list of files needed by this library at runtime.
+        ${SYNOPSIS}
+        See general comments about <code>data</code> at <a href="#common-attributes">Attributes
+        common to all build rules</a>.
+        <p>
+          When building a <code>java_library</code>, Bazel doesn't put these files anywhere; if the
+          <code>data</code> files are generated files then Bazel generates them. When building a
+          test that depends on this <code>java_library</code> Bazel copies or links the
+          <code>data</code> files into the runfiles area.
+        </p>
+        <!-- #END_BLAZE_RULE.ATTRIBUTE --> */
+
+        /* <!-- #BLAZE_RULE(java_library).ATTRIBUTE(deps) -->
+        The list of libraries to link into this library.
+        ${SYNOPSIS}
+        See general comments about <code>deps</code> at <a href="#common-attributes">Attributes
+        common to all build rules</a>.
+        <p>
+          The jars built by <code>java_library</code> rules listed in <code>deps</code> will be on
+          the compile-time classpath of this rule. Furthermore the transitive closure of their
+          <code>deps</code>, <code>runtime_deps</code> and <code>exports</code> will be on the
+          runtime classpath.
+        </p>
+        <p>
+          By contrast, targets in the <code>data</code> attribute are included in the runfiles but
+          on neither the compile-time nor runtime classpath.
+        </p>
+        <!-- #END_BLAZE_RULE.ATTRIBUTE --> */
+
+        /* <!-- #BLAZE_RULE(java_library).ATTRIBUTE(exports) -->
+        Exported libraries.
+        ${SYNOPSIS}
+        <p>
+          Listing rules here will make them available to parent rules, as if the parents explicitly
+          depended on these rules. This is not true for regular (non-exported) <code>deps</code>.
+        </p>
+        <p>
+          Summary: a rule <i>X</i> can access the code in <i>Y</i> if there exists a dependency
+          path between them that begins with a <code>deps</code> edge followed by zero or more
+          <code>exports</code> edges. Let's see some examples to illustrate this.
+        </p>
+        <p>
+          Assume <i>A</i> depends on <i>B</i> and <i>B</i> depends on <i>C</i>. In this case
+          C is a <em>transitive</em> dependency of A, so changing C's sources and rebuilding A will
+          correctly rebuild everything. However A will not be able to use classes in C. To allow
+          that, either A has to declare C in its <code>deps</code>, or B can make it easier for A
+          (and anything that may depend on A) by declaring C in its (B's) <code>exports</code>
+          attribute.
+        </p>
+        <p>
+          The closure of exported libraries is available to all direct parent rules. Take a slightly
+          different example: A depends on B, B depends on C and D, and also exports C but not D.
+          Now A has access to C but not to D. Now, if C and D exported some libraries, C' and D'
+          respectively, A could only access C' but not D'.
+        </p>
+        <p>
+          Important: an exported rule is not a regular dependency. Sticking to the previous example,
+          if B exports C and wants to also use C, it has to also list it in its own
+          <code>deps</code>.
+        </p>
+        <!-- #END_BLAZE_RULE.ATTRIBUTE --> */
         .add(attr("exports", LABEL_LIST)
             .allowedRuleClasses(BazelJavaRuleClasses.ALLOWED_RULES_IN_DEPS)
             .allowedFileTypes(/*May not have files in exports!*/))
+
+        /* <!-- #BLAZE_RULE(java_library).ATTRIBUTE(neverlink) -->
+        Whether this library should only be used for compilation and not at runtime.
+        ${SYNOPSIS}
+        Useful if the library will be provided by the runtime environment during execution. Examples
+        of such libraries are the IDE APIs for IDE plug-ins or <code>tools.jar</code> for anything
+        running on a standard JDK.
+        <p>
+          Note that <code>neverlink = 1</code> does not prevent the compiler from inlining material
+          from this library into compilation targets that depend on it, as permitted by the Java
+          Language Specification (e.g., <code>static final</code> constants of <code>String</code>
+          or of primitive types). The preferred use case is therefore when the runtime library is
+          identical to the compilation library.
+        </p>
+        <p>
+          If the runtime library differs from the compilation library then you must ensure that it
+          differs only in places that the JLS forbids compilers to inline (and that must hold for
+          all future versions of the JLS).
+        </p>
+        <!-- #END_BLAZE_RULE.ATTRIBUTE --> */
         .add(attr("neverlink", BOOLEAN).value(false))
         .override(attr("javacopts", STRING_LIST))
+        /* <!-- #BLAZE_RULE(java_library).ATTRIBUTE(exported_plugins) -->
+        The list of <code><a href="#java_plugin">java_plugin</a></code>s (e.g. annotation
+        processors) to export to libraries that directly depend on this library.
+        ${SYNOPSIS}
+        <p>
+          The specified list of <code>java_plugin</code>s will be applied to any library which
+          directly depends on this library, just as if that library had explicitly declared these
+          labels in <code><a href="#java_library.plugins">plugins</a></code>.
+        </p>
+        <!-- #END_BLAZE_RULE.ATTRIBUTE --> */
         .add(attr("exported_plugins", LABEL_LIST).cfg(HOST).allowedRuleClasses("java_plugin")
             .legacyAllowAnyFileType())
         .build();
   }
 }
+
+/*<!-- #BLAZE_RULE (NAME = java_library, TYPE = LIBRARY, FAMILY = Java) -->
+
+${ATTRIBUTE_SIGNATURE}
+
+<p>This rule compiles and links sources into a <code>.jar</code> file.</p>
+
+${IMPLICIT_OUTPUTS}
+
+${ATTRIBUTE_DEFINITION}
+
+<!-- #END_BLAZE_RULE -->*/
diff --git a/src/main/java/com/google/devtools/build/lib/bazel/rules/java/BazelJavaPluginRule.java b/src/main/java/com/google/devtools/build/lib/bazel/rules/java/BazelJavaPluginRule.java
index cbb9411..cef463b 100644
--- a/src/main/java/com/google/devtools/build/lib/bazel/rules/java/BazelJavaPluginRule.java
+++ b/src/main/java/com/google/devtools/build/lib/bazel/rules/java/BazelJavaPluginRule.java
@@ -34,9 +34,24 @@
   @Override
   public RuleClass build(Builder builder, RuleDefinitionEnvironment env) {
     return builder
+        /* <!-- #BLAZE_RULE(java_plugin).IMPLICIT_OUTPUTS -->
+        <ul>
+          <li><code><var>libname</var>.jar</code>: A Java archive.</li>
+        </ul>
+        <!-- #END_BLAZE_RULE.IMPLICIT_OUTPUTS --> */
         .setImplicitOutputsFunction(BazelJavaRuleClasses.JAVA_LIBRARY_IMPLICIT_OUTPUTS)
         .override(builder.copy("deps").validityPredicate(Attribute.ANY_EDGE))
         .override(builder.copy("srcs").validityPredicate(Attribute.ANY_EDGE))
+        /* <!-- #BLAZE_RULE(java_plugin).ATTRIBUTE(processor_class) -->
+        ${SYNOPSIS}
+        The processor class is the fully qualified type of the class that the Java compiler should
+        use as entry point to the annotation processor. If not specified, this rule will not
+        contribute an annotation processor to the Java compiler's annotation processing, but its
+        runtime classpath will still be included on the compiler's annotation processor path. (This
+        is primarily intended for use by <a href="http://errorprone.info/">Error Prone plugins</a>,
+        which are loaded from the annotation processor path using <code>META-INF/services</code>
+        files.)
+        <!-- #END_BLAZE_RULE.ATTRIBUTE --> */
         .add(attr("processor_class", STRING))
         .removeAttribute("runtime_deps")
         .removeAttribute("exports")
@@ -45,3 +60,26 @@
   }
 }
 
+/*<!-- #BLAZE_RULE (NAME = java_plugin, TYPE = OTHER, FAMILY = Java) -->
+
+${ATTRIBUTE_SIGNATURE}
+
+<p>
+  <code>java_plugin</code> defines plugins for the Java compiler run by Bazel. At the moment, the
+  only supported kind of plugins are annotation processors. A <code>java_library</code> or
+  <code>java_binary</code> rule can run plugins by depending on them via the <code>plugins</code>
+  attribute. A <code>java_library</code> can also automatically export plugins to libraries that
+  directly depend on it using
+  <code><a href="#java_library.exported_plugins">exported_plugins</a></code>.
+</p>
+
+${IMPLICIT_OUTPUTS}
+
+${ATTRIBUTE_DEFINITION}
+
+<p>
+  Arguments are identical to <a href="#java_library"><code>java_library</code></a>, except for the
+  addition of the <code>processor_class</code> argument.
+</p>
+
+<!-- #END_BLAZE_RULE -->*/
diff --git a/src/main/java/com/google/devtools/build/lib/bazel/rules/java/BazelJavaRuleClasses.java b/src/main/java/com/google/devtools/build/lib/bazel/rules/java/BazelJavaRuleClasses.java
index f5d928d..2f634f6 100644
--- a/src/main/java/com/google/devtools/build/lib/bazel/rules/java/BazelJavaRuleClasses.java
+++ b/src/main/java/com/google/devtools/build/lib/bazel/rules/java/BazelJavaRuleClasses.java
@@ -120,21 +120,88 @@
     @Override
     public RuleClass build(Builder builder, RuleDefinitionEnvironment env) {
       return builder
+          /* <!-- #BLAZE_RULE($java_rule).ATTRIBUTE(deps) -->
+          The list of other libraries to be linked in to the target.
+          ${SYNOPSIS}
+          See general comments about <code>deps</code> at <a href="#common-attributes">Attributes
+          common to all build rules</a>.
+          <!-- #END_BLAZE_RULE.ATTRIBUTE --> */
           .override(builder.copy("deps")
               .allowedFileTypes(JavaSemantics.JAR)
               .allowedRuleClasses(ALLOWED_RULES_IN_DEPS)
               .skipAnalysisTimeFileTypeCheck())
+          /* <!-- #BLAZE_RULE($java_rule).ATTRIBUTE(runtime_deps) -->
+          Libraries to make available to the final binary or test at runtime only.
+          ${SYNOPSIS}
+          Like ordinary <code>deps</code>, these will appear on the runtime classpath, but unlike
+          them, not on the compile-time classpath. Dependencies needed only at runtime should be
+          listed here. Dependency-analysis tools should ignore targets that appear in both
+          <code>runtime_deps</code> and <code>deps</code>.
+          <!-- #END_BLAZE_RULE.ATTRIBUTE --> */
           .add(attr("runtime_deps", LABEL_LIST)
               .allowedFileTypes(JavaSemantics.JAR)
               .allowedRuleClasses(ALLOWED_RULES_IN_DEPS)
               .skipAnalysisTimeFileTypeCheck())
+
+          /* <!-- #BLAZE_RULE($java_rule).ATTRIBUTE(srcs) -->
+          The list of source files that are processed to create the target.
+          ${SYNOPSIS}
+          This attribute is almost always required; see exceptions below.
+          <p>
+            Source files of type <code>.java</code> are compiled. In case of generated
+            <code>.java</code> files it is generally advisable to put the generating rule's name
+            here instead of the name of the file itself. This not only improves readability but
+            makes the rule more resilient to future changes: if the generating rule generates
+            different files in the future, you only need to fix one place: the <code>outs</code> of
+            the generating rule. You should not list the generating rule in <code>deps</code>
+            because it is a no-op.
+          </p>
+          <p>
+            Source files of type <code>.srcjar</code> are unpacked and compiled. (This is useful if
+            you need to generate a set of <code>.java</code> files with a genrule.)
+          </p>
+          <p>
+            Source files of type <code>.jar</code> are linked in. <em class="harmful">This is
+            discouraged, use <a href="#java_import"><code>java_import</code></a></em> if you need to
+            link against existing (or generated) jar files (which is useful if you have a
+            <code>.jar</code> file without sources).
+          </p>
+          <p>
+            Rules: if the rule (typically <code>genrule</code> or <code>filegroup</code>) generates
+            any of the files listed above, they will be used the same way as described for source
+            files.
+          </p>
+
+          <p>
+            This argument is almost always required, except if a
+            <a href="#java_binary.main_class"><code>main_class</code></a> attribute specifies a
+            class on the runtime classpath or you specify the <code>runtime_deps</code> argument.
+          </p>
+          <!-- #END_BLAZE_RULE.ATTRIBUTE --> */
           .add(attr("srcs", LABEL_LIST)
               .orderIndependent()
               .direct_compile_time_input()
               .allowedFileTypes(JavaSemantics.JAVA_SOURCE, JavaSemantics.JAR,
                   JavaSemantics.SOURCE_JAR, JavaSemantics.PROPERTIES))
+          /* <!-- #BLAZE_RULE($java_rule).ATTRIBUTE(resources) -->
+          A list of data files to include in a Java jar.
+          ${SYNOPSIS}
+          If resources are specified, they will be bundled in the jar along with the usual
+          <code>.class</code> files produced by compilation. The location of the resources inside of
+          the jar file is determined using a heuristic, but it's often in a directory corresponding
+          to the build package name. Resources may be source files or generated files.
+          <!-- #END_BLAZE_RULE.ATTRIBUTE --> */
+          // TODO(bazel-team): be more specific about this heuristic.
           .add(attr("resources", LABEL_LIST).orderIndependent()
               .allowedFileTypes(FileTypeSet.ANY_FILE))
+          /* <!-- #BLAZE_RULE($java_rule).ATTRIBUTE(plugins) -->
+          Java compiler plugins to run at compile-time.
+          ${SYNOPSIS}
+          Every <code>java_plugin</code> specified in this attribute will be run whenever this rule
+          is built. A library may also inherit plugins from dependencies that use
+          <code><a href="#java_library.exported_plugins">exported_plugins</a></code>. Resources
+          generated by the plugin will be included in the resulting jar of this rule.
+          <!-- #END_BLAZE_RULE.ATTRIBUTE --> */
           .add(attr("plugins", LABEL_LIST).cfg(HOST).allowedRuleClasses("java_plugin")
               .legacyAllowAnyFileType())
           .add(attr(":java_plugins", LABEL_LIST)
@@ -142,6 +209,13 @@
               .allowedRuleClasses("java_plugin")
               .silentRuleClassFilter()
               .value(JavaSemantics.JAVA_PLUGINS))
+          /* <!-- #BLAZE_RULE($java_rule).ATTRIBUTE(javacopts) -->
+          Extra compiler options for this library.
+          ${SYNOPSIS}
+          Subject to <a href="#make_variables">"Make variable"</a> substitution and
+          <a href="#sh-tokenization">Bourne shell tokenization</a>.
+          <p>These compiler options are passed to javac after the global compiler options.</p>
+          <!-- #END_BLAZE_RULE.ATTRIBUTE --> */
           .add(attr("javacopts", STRING_LIST))
           .build();
     }
@@ -161,11 +235,77 @@
     @Override
     public RuleClass build(Builder builder, final RuleDefinitionEnvironment env) {
       return builder
+          /* <!-- #BLAZE_RULE($base_java_binary).ATTRIBUTE(classpath_resources) -->
+          (optional; <em class="harmful">DO NOT USE THIS OPTION UNLESS THERE IS NO OTHER WAY)</em>
+          <p>
+            A list of resources that must be located at the root of the java tree. This attribute's
+            only purpose is to support third-party libraries that require that their resources be
+            found on the classpath as exactly <code>"myconfig.xml"</code>. It is only allowed on
+            binaries and not libraries, due to the danger of namespace conflicts.
+          </p>
+          <!-- #END_BLAZE_RULE.ATTRIBUTE --> */
           .add(attr("classpath_resources", LABEL_LIST).legacyAllowAnyFileType())
+          /* <!-- #BLAZE_RULE($base_java_binary).ATTRIBUTE(jvm_flags) -->
+          A list of flags to embed in the wrapper script generated for running this binary.
+          ${SYNOPSIS}
+          Subject to <a href="#make_variables">"Make variable"</a> substitution and
+          <a href="#sh-tokenization">Bourne shell tokenization</a>.
+          <p>
+            The wrapper script for a Java binary includes a <code>CLASSPATH</code> definition (to
+            find all the dependent jars) and invokes the right Java interpreter. The command line
+            generated by the wrapper script includes the name of the main class followed by a
+            <code>"$@"</code> so you can pass along other arguments after the classname.  However,
+            arguments intended for parsing by the JVM must be specified <i>before</i> the classname
+            on the command line. The contents of <code>jvm_flags</code> are added to the wrapper
+            script before the classname is listed.
+          </p>
+          <!-- #END_BLAZE_RULE.ATTRIBUTE --> */
           .add(attr("jvm_flags", STRING_LIST))
+          /* <!-- #BLAZE_RULE($base_java_binary).ATTRIBUTE(main_class) -->
+          Name of class with <code>main()</code> method to use as entry point.
+          ${SYNOPSIS}
+          If a rule uses this option, it does not need a <code>srcs=[...]</code> list.
+          Thus, with this attribute one can make an executable from a Java library that already
+          contains one or more <code>main()</code> methods.
+          <p>
+            The value of this attribute is a class name, not a source file. The class must be
+            available at runtime: it may be compiled by this rule (from <code>srcs</code>) or
+            provided by direct or transitive dependencies (through <code>runtime_deps</code> or
+            <code>deps</code>). If the class is unavailable, the binary will fail at runtime; there
+            is no build-time check.
+          </p>
+          <!-- #END_BLAZE_RULE.ATTRIBUTE --> */
           .add(attr("main_class", STRING))
-          .add(attr("create_executable", BOOLEAN).nonconfigurable("internal").value(true))
+          /* <!-- #BLAZE_RULE($base_java_binary).ATTRIBUTE(create_executable) -->
+          Whether to build the executable wrapper script or not.
+          ${SYNOPSIS}
+          If this option is present, no executable wrapper script is built around the
+          <code>.jar</code> file. Incompatible with <code>main_class</code> attribute.
+          <!-- #END_BLAZE_RULE.ATTRIBUTE --> */
+          .add(attr("create_executable", BOOLEAN)
+              .nonconfigurable("internal")
+              .value(true))
+          /* <!-- #BLAZE_RULE($base_java_binary).ATTRIBUTE(deploy_manifest_lines) -->
+          A list of lines to add to the <code>META-INF/manifest.mf</code> file generated for the
+          <code>*_deploy.jar</code> target. The contents of this attribute are <em>not</em> subject
+          to <a href="#make_variables">"Make variable"</a> substitution.
+          <!-- #END_BLAZE_RULE.ATTRIBUTE --> */
           .add(attr("deploy_manifest_lines", STRING_LIST))
+          /* <!-- #BLAZE_RULE($base_java_binary).ATTRIBUTE(stamp) -->
+          Enable link stamping.
+          ${SYNOPSIS}
+          Whether to encode build information into the binary. Possible values:
+          <ul>
+            <li><code>stamp = 1</code>: Stamp the build information into the binary. Stamped
+              binaries are only rebuilt when their dependencies change. Use this if there are tests
+              that depend on the build information.</li>
+            <li><code>stamp = 0</code>: Always replace build information by constant values. This
+              gives good build result caching.</li>
+            <li><code>stamp = -1</code>: Embedding of build information is controlled by the
+              <a href="blaze-user-manual.html#flag--stamp">--[no]stamp</a> flag.</li>
+          </ul>
+          <!-- #END_BLAZE_RULE.ATTRIBUTE --> */
+          // TODO(bazel-team): describe how to access this data at runtime
           .add(attr("stamp", TRISTATE).value(TriState.AUTO))
           .add(attr(":java_launcher", LABEL).value(JavaSemantics.JAVA_LAUNCHER))  // blaze flag
           .build();