From 1fce95d0d3256253723fe87322d38f5ce63a2e88 Mon Sep 17 00:00:00 2001 From: Florian Weikert Date: Thu, 16 Mar 2017 15:55:19 +0000 Subject: No longer crash when running "bazel help ". Fixes #2270. -- PiperOrigin-RevId: 150324978 MOS_MIGRATED_REVID=150324978 --- .../google/devtools/build/docgen/BlazeRuleHelpPrinter.java | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/google/devtools/build/docgen/BlazeRuleHelpPrinter.java b/src/main/java/com/google/devtools/build/docgen/BlazeRuleHelpPrinter.java index e262aa4267..789554f312 100644 --- a/src/main/java/com/google/devtools/build/docgen/BlazeRuleHelpPrinter.java +++ b/src/main/java/com/google/devtools/build/docgen/BlazeRuleHelpPrinter.java @@ -13,10 +13,8 @@ // limitations under the License. package com.google.devtools.build.docgen; -import com.google.common.base.Preconditions; import com.google.common.collect.ImmutableList; import com.google.devtools.build.lib.analysis.ConfiguredRuleClassProvider; - import java.io.IOException; import java.util.HashMap; import java.util.Map; @@ -50,10 +48,13 @@ public class BlazeRuleHelpPrinter { return e.getMessage(); } } - // Every rule should be documented and this method should be called only - // for existing rules (a check is performed in HelpCommand). - Preconditions.checkState(ruleDocMap.containsKey(ruleName), String.format( - "ERROR: Documentation of rule %s does not exist.", ruleName)); + // TODO(fwe): generate the rule documentation when building the Bazel binary and ship + // the text documentation with the binary. + // The Bazel binary may not contain the rule sources, which means that the documentation + // retrieval step would fail with an exception. + if (!ruleDocMap.containsKey(ruleName)) { + return String.format("Documentation for rule %s is not part of the binary.\n", ruleName); + } return "Rule " + ruleName + ":" + ruleDocMap.get(ruleName).getCommandLineDocumentation() + "\n"; } -- cgit v1.2.3