|
4 月之前 | |
---|---|---|
.. | ||
_snippets | 5 月之前 | |
commands | 6 月之前 | |
functions-operators | 6 月之前 | |
images | 5 月之前 | |
kibana | 5 月之前 | |
README.md | 6 月之前 | |
esql-advanced.md | 5 月之前 | |
esql-commands.md | 6 月之前 | |
esql-enrich-data.md | 5 月之前 | |
esql-examples.md | 7 月之前 | |
esql-functions-operators.md | 4 月之前 | |
esql-implicit-casting.md | 6 月之前 | |
esql-lookup-join.md | 5 月之前 | |
esql-metadata-fields.md | 6 月之前 | |
esql-multivalued-fields.md | 5 月之前 | |
esql-process-data-with-dissect-grok.md | 4 月之前 | |
esql-syntax-reference.md | 5 月之前 | |
esql-syntax.md | 5 月之前 | |
esql-time-spans.md | 5 月之前 | |
esql-types-and-fields.md | 5 月之前 | |
limitations.md | 5 月之前 |
The ES|QL documentation is composed of static content and generated content.
The static content exists in this directory and can be edited by hand.
However, the subdirectories _snippets
, images
and kibana
contain a mix
of static and generated content, and so updating them is a bit more involved.
The root esql
directory and the following two subdirectories contain static content:
commands
- contains the static content for the ES|QL commands.
This content will typically contain mostly include
directives for content in the _snippets
or images
directories.functions-operators
- contains the static content for the ES|QL functions and operators.
Again this will contain mostly include
directives for content in the _snippets
or images
directories.Generated content is created by running the ESQL tests in the x-pack/plugin/esql
module.
It will be written into three subdirectories of the esql
directory:
In _snippets
there are files that can be included within other files using the
File Inclusion
feature of the Elastic Docs V3 system.
Most, but not all, files in this directory are generated.
In particular the directories _snippets/functions/*
and _snippets/operators/*
contain subdirectories that are mostly generated:
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 functiontypes
- a table of each combination of support type for each parameter. These are generated from tests.layout
- a fully generated description for each functionMost 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.
For example to generate docs for the CASE
function:
./gradlew :x-pack:plugin:esql:test -Dtests.class='CaseTests'
To regenerate the files for all functions run all of ESQL's tests using gradle:
./gradlew :x-pack:plugin:esql:test
The _snippets/lists
directory contains re-usable content for lists of commands, functions or operators.
Whenever adding a command, function or operator, you usually need to add it to one of these lists.
The lists should also match natural groupings of the commands, functions or operators.
For example, when adding an aggregation function, add to the aggregation-functions.md
file.
The _snippets/commands
directory contains the content for the ES|QL commands.
There are two subdirectories, one static and one generated:
layout
- contains the static content for the ES|QL commands.
The files in this directory are the main content for the documentation for the commands.
They are not generated, and so this is the primary place to edit the content, or add new commands.examples
- contains the generated content for the ES|QL commands.
The files in this directory are generated from the test CommandDocsTests
in the x-pack/plugin/esql
module.
The structure of the subdirectories mimics the csv-spec files and test tags used in the tests.Including generated examples in the command documentation is done by using the include directive.
The images
directory contains functions
and operators
subdirectories with
the *.svg
files used to describe the syntax of each function or operator.
These are all generated by the same tests that generate the functions and operators docs above.
The kibana
directory contains definition
and docs
subdirectories that are generated:
kibana/definition
- function definitions for kibana's ESQL editorkibana/docs
- the inline docs for kibanaThese are also generated as part of the unit tests described above.
There are three overlapping mechanisms for generating the content:
AbstractFunctionTestCase
class generates the content for all the functions and most operators.
This class makes use of the DocsV3Support
class to generate the content.
It uses the @FunctionInfo
and @Param
annotations on function and operator classes to know what content should be generated.
All tests that extend this class will automatically generate the content for the functions they test.AbstractOperatorTestCase
class. See, for example, operators such as Cast ::
,
which uses CastOperatorTests
to call directly into the DocsV3Support
class to generate the content.CommandDocsTests
class.
Currently, this only covers tested examples used in the documentation, and all other commands
content is static.
Since there are no annotations to mark which examples to use, the command documentation
relies on the docs author providing the knowledge of which examples to use by creating subdirectories
and examples files that match the csv-spec files and tags to include.To help differentiate between the static and generated content, the generated content is prefixed with a comment:
% This is generated by ESQL's AbstractFunctionTestCase. Do no edit it. See ../README.md for how to regenerate it.
When adding a new command, for example adding the CHANGE_POINT
command, do the following:
_snippets/commands/layout
directory with the name of the command, for example change_point.md
._snippets/lists/processing-commands.md
.commands/processing-commands.md
file to include the new command._snippets/commands/examples
directory. See below for details.When adding tested examples to a command, for example adding an example to the CHANGE_POINT
command, do the following:
x-pack/plugin/esql/qa/testFixtures/src/main/resources/
directory.-result
._snippets/commands/examples
directory. While you could add the content to that file, it is not necessary, merely that the file existsCommandDocsTests
in the x-pack/plugin/esql
module to generate the content.For example, we tag the following test in change_point.csv-spec:
example for docs
required_capability: change_point
// tag::changePointForDocs[]
ROW key=[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25]
| MV_EXPAND key
| EVAL value = CASE(key<13, 0, 42)
| CHANGE_POINT value ON key
| WHERE type IS NOT NULL
// end::changePointForDocs[]
;
// tag::changePointForDocs-result[]
key:integer | value:integer | type:keyword | pvalue:double
13 | 42 | step_change | 0.0
// end::changePointForDocs-result[]
;
Then we create the file _snippets/commands/examples/change_point.csv-spec/changePointForDocs.md
with the content:
This should be overwritten
Then we run the test CommandDocsTests
in the x-pack/plugin/esql
module to generate the content.
Now the content of the changePointForDocs.md file should have been updated:
% This is generated by ESQL's AbstractFunctionTestCase. Do no edit it. See ../README.md for how to regenerate it.
\```esql
ROW key=[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25]
| MV_EXPAND key
| EVAL value = CASE(key<13, 0, 42)
| CHANGE_POINT value ON key
| WHERE type IS NOT NULL
\```
| key:integer | value:integer | type:keyword | pvalue:double |
| --- | --- | --- | --- |
| 13 | 42 | step_change | 0.0 |
Finally include this file in the CHANGE_POINT
command file _snippets/commands/layout/change_point.md
:
**Examples**
The following example shows the detection of a step change:
:::{include} ../examples/change_point.csv-spec/changePointForDocs.md
:::