From 58c23abe0632f28f3e729942d80e0eb2fd6c8ca1 Mon Sep 17 00:00:00 2001 From: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> Date: Thu, 14 Nov 2024 20:08:03 +1100 Subject: [PATCH] [8.x] [ES|QL] Adds tech preview label in the docs (#199730) (#200118) # Backport This will backport the following commits from `main` to `8.x`: - [[ES|QL] Adds tech preview label in the docs (#199730)](https://github.com/elastic/kibana/pull/199730) ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) Co-authored-by: Stratoula Kalafateli --- .../scripts/generate_esql_docs.ts | 24 +++- .../src/components/shared/documentation.scss | 4 + .../shared/documentation_content.tsx | 22 +++- .../generated/aggregation_functions.tsx | 13 +++ .../sections/generated/scalar_functions.tsx | 104 +++++++++++++++++- 5 files changed, 158 insertions(+), 9 deletions(-) diff --git a/packages/kbn-language-documentation/scripts/generate_esql_docs.ts b/packages/kbn-language-documentation/scripts/generate_esql_docs.ts index 072d53a02753a..da42dc7a44480 100644 --- a/packages/kbn-language-documentation/scripts/generate_esql_docs.ts +++ b/packages/kbn-language-documentation/scripts/generate_esql_docs.ts @@ -13,6 +13,11 @@ import fs from 'fs'; import path from 'path'; import { functions } from '../src/sections/generated/scalar_functions'; +interface DocsSectionContent { + description: string; + preview?: boolean; +} + (function () { const pathToElasticsearch = process.argv[2]; const { scalarFunctions, aggregationFunctions } = loadFunctionDocs(pathToElasticsearch); @@ -41,8 +46,8 @@ function loadFunctionDocs(pathToElasticsearch: string) { .readdirSync(definitionsPath) .map((file) => JSON.parse(fs.readFileSync(`${definitionsPath}/${file}`, 'utf-8'))); - const scalarFunctions = new Map(); - const aggregationFunctions = new Map(); + const scalarFunctions = new Map(); + const aggregationFunctions = new Map(); // Iterate over each file in the directory for (const file of docsFiles) { @@ -64,10 +69,16 @@ function loadFunctionDocs(pathToElasticsearch: string) { // Add the function name and content to the map if (functionDefinition.type === 'eval') { - scalarFunctions.set(functionName, content); + scalarFunctions.set(functionName, { + description: content, + preview: functionDefinition.preview, + }); } if (functionDefinition.type === 'agg') { - aggregationFunctions.set(functionName, content); + aggregationFunctions.set(functionName, { + description: content, + preview: functionDefinition.preview, + }); } } } @@ -75,10 +86,10 @@ function loadFunctionDocs(pathToElasticsearch: string) { return { scalarFunctions, aggregationFunctions }; } -function writeFunctionDocs(functionDocs: Map, pathToDocsFile: string) { +function writeFunctionDocs(functionDocs: Map, pathToDocsFile: string) { const codeStrings = Array.from(functionDocs.entries()).map(([name, doc]) => { const docWithoutLinks = removeAsciiDocInternalCrossReferences( - doc, + doc.description, Array.from(functionDocs.keys()) ); return ` @@ -91,6 +102,7 @@ function writeFunctionDocs(functionDocs: Map, pathToDocsFile: st defaultMessage: '${name.toUpperCase()}', } ), + preview: ${doc.preview || false}, description: ( ; + options: Array<{ label: string; description?: JSX.Element | undefined; preview?: boolean }>; }>; sections?: LanguageDocumentationSections; } @@ -76,6 +77,23 @@ function DocumentationContent({ } }} > + {helpItem.preview && ( + + )} {helpItem.description} ); diff --git a/packages/kbn-language-documentation/src/sections/generated/aggregation_functions.tsx b/packages/kbn-language-documentation/src/sections/generated/aggregation_functions.tsx index 14a824c3183ee..6fe761e489c04 100644 --- a/packages/kbn-language-documentation/src/sections/generated/aggregation_functions.tsx +++ b/packages/kbn-language-documentation/src/sections/generated/aggregation_functions.tsx @@ -29,6 +29,7 @@ export const functions = { label: i18n.translate('languageDocumentation.documentationESQL.avg', { defaultMessage: 'AVG', }), + preview: false, description: (