소스 검색

Enhance the SnippetsTask to support the new styles added for ESQL (#97752)

This commit enhances the SnippetsTask's source matching to support the new styles added for ESQL.
Chris Hegarty 2 년 전
부모
커밋
632854a4e3

+ 1 - 1
build-tools-internal/src/main/groovy/org/elasticsearch/gradle/internal/doc/SnippetsTask.groovy

@@ -304,7 +304,7 @@ class SnippetsTask extends DefaultTask {
     }
 
     static Source matchSource(String line) {
-        def matcher = line =~ /\["?source"?,\s*"?([-\w]+)"?(,((?!id=).)*(id="?([-\w]+)"?)?(.*))?].*/
+        def matcher = line =~ /\["?source"?(?:\.[^,]+)?,\s*"?([-\w]+)"?(,((?!id=).)*(id="?([-\w]+)"?)?(.*))?].*/
         if(matcher.matches()){
             return new Source(matches: true, language: matcher.group(1),  name: matcher.group(5))
         }

+ 8 - 0
build-tools-internal/src/test/java/org/elasticsearch/gradle/internal/doc/SnippetsTaskTests.java

@@ -51,5 +51,13 @@ public class SnippetsTaskTests {
         assertTrue(source.getMatches());
         assertEquals("console", source.getLanguage());
         assertEquals("snippet-name-1", source.getName());
+
+        source = SnippetsTask.matchSource("[source.merge.styled,esql]");
+        assertTrue(source.getMatches());
+        assertEquals("esql", source.getLanguage());
+
+        source = SnippetsTask.matchSource("[source.merge.styled,foo-bar]");
+        assertTrue(source.getMatches());
+        assertEquals("foo-bar", source.getLanguage());
     }
 }