Skip to content

Commit 959469a

Browse files
committed
Rewrite Kibana docs asciidoc links to be MD links (elastic#125155)
Did a few things: * Rewrite Kibana docs asciidoc links to be MD links * Make kibana docs links absolute to planned publication path * Clarify which operators are generated and which are static * Removed the trailing .md from kibana docs links
1 parent 3a542dc commit 959469a

File tree

4 files changed

+13
-8
lines changed

4 files changed

+13
-8
lines changed

docs/reference/query-languages/esql/_snippets/operators/examples/cast.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
% This is generated by ESQL's AbstractFunctionTestCase. Do no edit it. See ../README.md for how to regenerate it.
2-
31
**Example**
42

53
```esql

docs/reference/query-languages/esql/_snippets/operators/examples/predicates.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
% This is generated by ESQL's AbstractFunctionTestCase. Do no edit it. See ../README.md for how to regenerate it.
2-
31
**Examples**
42

53
```esql

x-pack/plugin/esql/build.gradle

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,13 @@ tasks.named("test").configure {
167167

168168
List kibana = kibanaTree.files.collect { it.name }
169169
int countKibana = kibana.size()
170+
Closure replaceLinks = line -> {
171+
// The kibana docs are not deployed to the normal docs location, so need absolute paths for internal references
172+
line.replaceAll(
173+
/\]\(\/reference\/([^)\s]+)\.md(#\S+)?\)/,
174+
'](https://www.elastic.co/docs/reference/elasticsearch/$1$2)'
175+
)
176+
}
170177
if (countKibana == 0) {
171178
logger.quiet("ESQL Docs: No function/operator kibana docs created. Skipping sync.")
172179
} else {
@@ -181,6 +188,7 @@ tasks.named("test").configure {
181188
include '**/*.md', '**/*.json'
182189
}
183190
}
191+
filter replaceLinks
184192
}
185193
}
186194
}

x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/DocsV3Support.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,8 @@ public static void renderNegatedOperator(
142142
entry("esql-time-spans", "esql/esql-time-spans.md"),
143143
entry("esql-limitations", "esql/limitations.md"),
144144
entry("esql-function-named-params", "esql/esql-syntax.md"),
145-
entry("query-dsl-query-string-query", "query-dsl/query-dsl-query-string-query.md")
145+
entry("query-dsl-query-string-query", "query-dsl/query-dsl-query-string-query.md"),
146+
entry("regexp-syntax", "query-dsl/regexp-syntax.md")
146147
);
147148
// Static links to the commands file
148149
knownCommands = Map.ofEntries(entry("where", "where"), entry("stats-by", "stats"));
@@ -626,7 +627,7 @@ void renderDetailedDescription(String detailedDescription, String note) throws I
626627
StringBuilder rendered = new StringBuilder();
627628
if (Strings.isNullOrEmpty(detailedDescription) == false) {
628629
detailedDescription = replaceLinks(detailedDescription.trim());
629-
rendered.append("\n").append(detailedDescription).append("\n");
630+
rendered.append(DOCS_WARNING).append(detailedDescription).append("\n");
630631
}
631632

632633
if (Strings.isNullOrEmpty(note) == false) {
@@ -770,7 +771,7 @@ void renderKibanaInlineDocs(String name, FunctionInfo info) throws IOException {
770771
771772
""");
772773
builder.append("### ").append(name.toUpperCase(Locale.ROOT)).append("\n");
773-
builder.append(removeAsciidocLinks(info.description())).append("\n\n");
774+
builder.append(replaceLinks(info.description())).append("\n\n");
774775

775776
if (info.examples().length > 0) {
776777
Example example = info.examples()[0];
@@ -779,7 +780,7 @@ void renderKibanaInlineDocs(String name, FunctionInfo info) throws IOException {
779780
builder.append("\n```\n");
780781
}
781782
if (Strings.isNullOrEmpty(info.note()) == false) {
782-
builder.append("Note: ").append(removeAsciidocLinks(info.note())).append("\n");
783+
builder.append("Note: ").append(replaceLinks(info.note())).append("\n");
783784
}
784785
String rendered = builder.toString();
785786
logger.info("Writing kibana inline docs for [{}]:\n{}", name, rendered);

0 commit comments

Comments
 (0)