소스 검색

ESQL: Add README.md to docs (#106698)

This explains how to run the tests that build the docs. I tried to add
it in #106577 but the sync code deleted it. So I fixed that too.
Nik Everett 1 년 전
부모
커밋
35fcc9a29d

+ 21 - 0
docs/reference/esql/functions/README.md

@@ -0,0 +1,21 @@
+The files in these subdirectories and generated by ESQL's test suite:
+* `description` - description of each function scraped from `@FunctionInfo#description`
+* `examples` - examples of each function scraped from `@FunctionInfo#examples`
+* `parameters` - description of each function's parameters scraped from `@Param`
+* `signature` - railroad diagram of the syntax to invoke each function
+* `types` - a table of each combination of support type for each parameter. These are generated from tests.
+* `layout` - a fully generated description for each function
+
+Most functions can use the generated docs generated in the `layout` directory.
+If we need something more custom for the function we can make a file in this
+directory that can `include::` any parts of the files above.
+
+To regenerate the files for a function run its tests using gradle:
+```
+./gradlew :x-pack:plugin:esql:tests -Dtests.class='*SinTests'
+```
+
+To regenerate the files for all functions run all of ESQL's tests using gradle:
+```
+./gradlew :x-pack:plugin:esql:tests
+```

+ 1 - 1
x-pack/plugin/esql/build.gradle

@@ -88,7 +88,7 @@ tasks.named("test").configure {
           into "${rootDir}/docs/reference/esql/functions"
           include '**/*.asciidoc', '**/*.svg'
           preserve {
-            include '/*.asciidoc'
+            include '/*.asciidoc', 'README.md'
           }
         }
       }

+ 2 - 1
x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/AbstractFunctionTestCase.java

@@ -10,6 +10,7 @@ package org.elasticsearch.xpack.esql.expression.function;
 import org.apache.lucene.document.InetAddressPoint;
 import org.apache.lucene.sandbox.document.HalfFloatPoint;
 import org.apache.lucene.util.BytesRef;
+import org.elasticsearch.common.Strings;
 import org.elasticsearch.common.breaker.CircuitBreaker;
 import org.elasticsearch.common.breaker.CircuitBreakingException;
 import org.elasticsearch.common.bytes.BytesReference;
@@ -1161,7 +1162,7 @@ public abstract class AbstractFunctionTestCase extends ESTestCase {
             *Description*
 
             """ + description + "\n";
-        if (note != null) {
+        if (Strings.isNullOrEmpty(note) == false) {
             rendered += "\nNOTE: " + note + "\n";
         }
         LogManager.getLogger(getTestClass()).info("Writing description for [{}]:\n{}", functionName(), rendered);