diff options
author | 2015-03-05 11:38:50 +0000 | |
---|---|---|
committer | 2015-03-05 18:31:31 +0000 | |
commit | 695b4c8dd3543d12fa7400b8bb0ffa5f2490ead5 (patch) | |
tree | 0d7fb2d60440804acb0f9d906677b6352fadebd7 /src | |
parent | f014b3c574b1a70942dac1a2dcdf9e86b8df5555 (diff) |
Removed unsupported common attributes documentation
--
MOS_MIGRATED_REVID=87809723
Diffstat (limited to 'src')
5 files changed, 49 insertions, 16 deletions
diff --git a/src/main/java/BUILD b/src/main/java/BUILD index 49989899d8..a729cbf15b 100644 --- a/src/main/java/BUILD +++ b/src/main/java/BUILD @@ -92,7 +92,7 @@ java_binary( srcs = glob(["com/google/devtools/build/docgen/*.java"]), main_class = "com.google.devtools.build.docgen.BuildEncyclopediaGenerator", resources = glob( - ["com/google/devtools/build/docgen/templates/*.html"], + ["com/google/devtools/build/docgen/templates/**/*.html"], ), deps = [ ":bazel-core", diff --git a/src/main/java/com/google/devtools/build/docgen/PredefinedAttributes.java b/src/main/java/com/google/devtools/build/docgen/PredefinedAttributes.java index 1d2b35e4cb..bc81f6772a 100644 --- a/src/main/java/com/google/devtools/build/docgen/PredefinedAttributes.java +++ b/src/main/java/com/google/devtools/build/docgen/PredefinedAttributes.java @@ -13,9 +13,12 @@ // limitations under the License. package com.google.devtools.build.docgen; +import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap.Builder; import com.google.common.io.ByteStreams; +import com.google.common.io.Files; +import com.google.devtools.build.lib.Constants; import java.io.IOException; import java.io.InputStream; @@ -25,38 +28,38 @@ import java.util.Map; /** * A class to contain the base definition of common BUILD rule attributes. * - * <p>It looks for the {@code {common,binary,test}} directory of the attributes template directory. - * Each file in that directory should be named after the attribute name and contains the HTML - * description of the attribute. + * <p>See {@link Constants#COMMON_ATTRIBUTES_DOCFILES}, {@link Constants#BINARY_ATTRIBUTES_DOCFILES} + * and {@link Constants#TEST_ATTRIBUTES_DOCFILES} for the list of files containing the attributes + * description. */ public class PredefinedAttributes { private static ImmutableMap<String, RuleDocumentationAttribute> generateAttributeMap( - String commonType, String... names) { + String commonType, ImmutableList<String> filenames) { Builder<String, RuleDocumentationAttribute> builder = ImmutableMap.<String, RuleDocumentationAttribute>builder(); - for (String name : names) { - String filename = "templates/attributes/" + commonType + "/" + name + ".html"; + for (String filename : filenames) { + String name = Files.getNameWithoutExtension(filename); try { InputStream stream = PredefinedAttributes.class.getResourceAsStream(filename); + if (stream == null) { + throw new IllegalStateException("Resource " + filename + " not found"); + } String content = new String(ByteStreams.toByteArray(stream), StandardCharsets.UTF_8); builder.put(name, RuleDocumentationAttribute.create(name, commonType, content)); } catch (IOException e) { - System.err.println("Exception while reading " + filename + ", skipping!"); - e.printStackTrace(); + throw new IllegalStateException("Exception while reading " + filename, e); } } return builder.build(); } public static final Map<String, RuleDocumentationAttribute> COMMON_ATTRIBUTES = - generateAttributeMap(DocgenConsts.COMMON_ATTRIBUTES, "deps", "data", "licenses", - "distribs", "deprecation", "obsolete", "testonly", "tags", "visibility"); + generateAttributeMap(DocgenConsts.COMMON_ATTRIBUTES, Constants.COMMON_ATTRIBUTES_DOCFILES); public static final Map<String, RuleDocumentationAttribute> BINARY_ATTRIBUTES = - generateAttributeMap(DocgenConsts.BINARY_ATTRIBUTES, "args", "output_licenses"); + generateAttributeMap(DocgenConsts.BINARY_ATTRIBUTES, Constants.BINARY_ATTRIBUTES_DOCFILES); public static final Map<String, RuleDocumentationAttribute> TEST_ATTRIBUTES = - generateAttributeMap(DocgenConsts.TEST_ATTRIBUTES, "args", "size", "timeout", "flaky", - "shard_count", "local"); + generateAttributeMap(DocgenConsts.TEST_ATTRIBUTES, Constants.TEST_ATTRIBUTES_DOCFILES); } diff --git a/src/main/java/com/google/devtools/build/docgen/templates/attributes/test/local.html b/src/main/java/com/google/devtools/build/docgen/templates/attributes/test/local.html deleted file mode 100644 index 7c89b545c5..0000000000 --- a/src/main/java/com/google/devtools/build/docgen/templates/attributes/test/local.html +++ /dev/null @@ -1 +0,0 @@ -<div></div> diff --git a/src/main/java/com/google/devtools/build/docgen/templates/attributes/test/shard_count.html b/src/main/java/com/google/devtools/build/docgen/templates/attributes/test/shard_count.html deleted file mode 100644 index 7c89b545c5..0000000000 --- a/src/main/java/com/google/devtools/build/docgen/templates/attributes/test/shard_count.html +++ /dev/null @@ -1 +0,0 @@ -<div></div> diff --git a/src/main/java/com/google/devtools/build/lib/Constants.java b/src/main/java/com/google/devtools/build/lib/Constants.java index e71b1cf4ce..efc39ee2a5 100644 --- a/src/main/java/com/google/devtools/build/lib/Constants.java +++ b/src/main/java/com/google/devtools/build/lib/Constants.java @@ -33,4 +33,36 @@ public class Constants { public static final ImmutableList<String> WATCHFS_BLACKLIST = ImmutableList.of(); public static final String PRELUDE_FILE_DEPOT_RELATIVE_PATH = "tools/build_rules/prelude_bazel"; + + /** + * List of common attributes documentation, relative to {@link com.google.devtools.build.docgen}. + */ + public static final ImmutableList<String> COMMON_ATTRIBUTES_DOCFILES = ImmutableList.of( + "templates/attributes/common/deps.html", + "templates/attributes/common/data.html", + "templates/attributes/common/licenses.html", + "templates/attributes/common/distribs.html", + "templates/attributes/common/deprecation.html", + "templates/attributes/common/obsolete.html", + "templates/attributes/common/testonly.html", + "templates/attributes/common/tags.html", + "templates/attributes/common/visibility.html"); + + /** + * List of documentation for common attributes of *_binary rules, relative to + * {@link com.google.devtools.build.docgen}. + */ + public static final ImmutableList<String> BINARY_ATTRIBUTES_DOCFILES = ImmutableList.of( + "templates/attributes/binary/args.html", + "templates/attributes/binary/output_licenses.html"); + + /** + * List of documentation for common attributes of *_test rules, relative to + * {@link com.google.devtools.build.docgen}. + */ + public static final ImmutableList<String> TEST_ATTRIBUTES_DOCFILES = ImmutableList.of( + "templates/attributes/test/args.html", + "templates/attributes/test/size.html", + "templates/attributes/test/timeout.html", + "templates/attributes/test/flaky.html"); } |