From 695b4c8dd3543d12fa7400b8bb0ffa5f2490ead5 Mon Sep 17 00:00:00 2001 From: Damien Martin-Guillerez Date: Thu, 5 Mar 2015 11:38:50 +0000 Subject: Removed unsupported common attributes documentation -- MOS_MIGRATED_REVID=87809723 --- src/main/java/BUILD | 2 +- .../build/docgen/PredefinedAttributes.java | 29 +++++++++++--------- .../docgen/templates/attributes/test/local.html | 1 - .../templates/attributes/test/shard_count.html | 1 - .../com/google/devtools/build/lib/Constants.java | 32 ++++++++++++++++++++++ 5 files changed, 49 insertions(+), 16 deletions(-) delete mode 100644 src/main/java/com/google/devtools/build/docgen/templates/attributes/test/local.html delete mode 100644 src/main/java/com/google/devtools/build/docgen/templates/attributes/test/shard_count.html (limited to 'src') 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. * - *

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. + *

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 generateAttributeMap( - String commonType, String... names) { + String commonType, ImmutableList filenames) { Builder builder = ImmutableMap.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 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 BINARY_ATTRIBUTES = - generateAttributeMap(DocgenConsts.BINARY_ATTRIBUTES, "args", "output_licenses"); + generateAttributeMap(DocgenConsts.BINARY_ATTRIBUTES, Constants.BINARY_ATTRIBUTES_DOCFILES); public static final Map 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 @@ -

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 @@ -
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 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 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 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 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"); } -- cgit v1.2.3