Drop BLAZE_RULE.EXAMPLE annotation support Never really took off. PiperOrigin-RevId: 389862254
diff --git a/src/main/java/com/google/devtools/build/docgen/DocgenConsts.java b/src/main/java/com/google/devtools/build/docgen/DocgenConsts.java index c8f821e..e3c5411 100644 --- a/src/main/java/com/google/devtools/build/docgen/DocgenConsts.java +++ b/src/main/java/com/google/devtools/build/docgen/DocgenConsts.java
@@ -135,16 +135,6 @@ public static final Pattern BLAZE_RULE_END = Pattern.compile( "^[\\s]*\\<!\\-\\-[\\s]*#END_BLAZE_RULE[\\s]*\\-\\-\\>[\\s]*\\*/"); /** - * i.e. <!-- #BLAZE_RULE.EXAMPLE --> - */ - public static final Pattern BLAZE_RULE_EXAMPLE_START = Pattern.compile( - "[\\s]*\\<!--[\\s]*#BLAZE_RULE.EXAMPLE[\\s]*--\\>[\\s]*"); - /** - * i.e. <!-- #BLAZE_RULE.END_EXAMPLE --> - */ - public static final Pattern BLAZE_RULE_EXAMPLE_END = Pattern.compile( - "[\\s]*\\<!--[\\s]*#BLAZE_RULE.END_EXAMPLE[\\s]*--\\>[\\s]*"); - /** * i.e. <!-- #BLAZE_RULE(RULE_NAME).VARIABLE_NAME --> */ public static final Pattern BLAZE_RULE_VAR_START = Pattern.compile(
diff --git a/src/main/java/com/google/devtools/build/docgen/RuleDocumentation.java b/src/main/java/com/google/devtools/build/docgen/RuleDocumentation.java index dc4bebb..e061133 100644 --- a/src/main/java/com/google/devtools/build/docgen/RuleDocumentation.java +++ b/src/main/java/com/google/devtools/build/docgen/RuleDocumentation.java
@@ -18,7 +18,6 @@ import com.google.common.collect.ImmutableSet; import com.google.devtools.build.docgen.DocgenConsts.RuleType; import java.util.HashMap; -import java.util.HashSet; import java.util.Map; import java.util.Set; import java.util.TreeSet; @@ -315,42 +314,6 @@ } /** - * Returns a set of examples based on markups which can be used as BUILD file - * contents for testing. - */ - Set<String> extractExamples() throws BuildEncyclopediaDocException { - String[] lines = htmlDocumentation.split(DocgenConsts.LS); - Set<String> examples = new HashSet<>(); - StringBuilder sb = null; - boolean inExampleCode = false; - int lineCount = 0; - for (String line : lines) { - if (!inExampleCode) { - if (DocgenConsts.BLAZE_RULE_EXAMPLE_START.matcher(line).matches()) { - inExampleCode = true; - sb = new StringBuilder(); - } else if (DocgenConsts.BLAZE_RULE_EXAMPLE_END.matcher(line).matches()) { - throw new BuildEncyclopediaDocException(fileName, startLineCount + lineCount, - "No matching start example tag (#BLAZE_RULE.EXAMPLE) for end example tag."); - } - } else { - if (DocgenConsts.BLAZE_RULE_EXAMPLE_END.matcher(line).matches()) { - inExampleCode = false; - examples.add(sb.toString()); - sb = null; - } else if (DocgenConsts.BLAZE_RULE_EXAMPLE_START.matcher(line).matches()) { - throw new BuildEncyclopediaDocException(fileName, startLineCount + lineCount, - "No start example tags (#BLAZE_RULE.EXAMPLE) in a row."); - } else { - sb.append(line + DocgenConsts.LS); - } - } - lineCount++; - } - return examples; - } - - /** * Creates a BuildEncyclopediaDocException with the file containing this rule doc and * the number of the first line (where the rule doc is defined). Can be used to create * general BuildEncyclopediaDocExceptions about this rule.
diff --git a/src/test/java/com/google/devtools/build/docgen/RuleDocumentationTest.java b/src/test/java/com/google/devtools/build/docgen/RuleDocumentationTest.java index 533b1cb..0c556bb 100644 --- a/src/test/java/com/google/devtools/build/docgen/RuleDocumentationTest.java +++ b/src/test/java/com/google/devtools/build/docgen/RuleDocumentationTest.java
@@ -123,32 +123,6 @@ } @Test - public void testExtractExamples() throws BuildEncyclopediaDocException { - RuleDocumentation ruleDoc = - new RuleDocumentation( - "rule", - "OTHER", - "FOO", - Joiner.on("\n") - .join( - new String[] { - "x", - "<!-- #BLAZE_RULE.EXAMPLE -->", - "a", - "<!-- #BLAZE_RULE.END_EXAMPLE -->", - "y", - "<!-- #BLAZE_RULE.EXAMPLE -->", - "b", - "<!-- #BLAZE_RULE.END_EXAMPLE -->", - "z" - }), - 0, - "", - ImmutableSet.<String>of()); - assertThat(ruleDoc.extractExamples()).isEqualTo(ImmutableSet.<String>of("a\n", "b\n")); - } - - @Test public void testCreateExceptions() throws BuildEncyclopediaDocException { RuleDocumentation ruleDoc = new RuleDocumentation("foo_binary", "OTHER", "FOO", "", 10, "foo.txt", NO_FLAGS);