Skip to content

Commit 322bdee

Browse files
committed
Merge branch 'main' into feature/redirect_extensions
2 parents 3389216 + df31b39 commit 322bdee

File tree

26 files changed

+594
-162
lines changed

26 files changed

+594
-162
lines changed

Directory.Packages.props

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
<PackageVersion Include="AWSSDK.Core" Version="4.0.0.2" />
1717
<PackageVersion Include="AWSSDK.SQS" Version="4.0.0.1" />
1818
<PackageVersion Include="AWSSDK.S3" Version="4.0.0.1" />
19+
<PackageVersion Include="Elastic.Ingest.Elasticsearch" Version="0.11.3" />
1920
</ItemGroup>
2021
<!-- Build -->
2122
<ItemGroup>
@@ -63,4 +64,4 @@
6364
<PackageVersion Include="xunit.runner.visualstudio" Version="3.0.2" />
6465
<PackageVersion Include="xunit.v3" Version="1.1.0" />
6566
</ItemGroup>
66-
</Project>
67+
</Project>

install.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ ARCH=$(uname -m)
77

88
# Map architecture naming
99
if [ "$ARCH" = "x86_64" ]; then
10-
ARCH="amd64"
10+
ARCH="x64"
1111
elif [ "$ARCH" = "aarch64" ] || [ "$ARCH" = "arm64" ]; then
1212
ARCH="arm64"
1313
fi
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFramework>net9.0</TargetFramework>
5+
<ImplicitUsings>enable</ImplicitUsings>
6+
<Nullable>enable</Nullable>
7+
</PropertyGroup>
8+
9+
<ItemGroup>
10+
<PackageReference Include="Elastic.Ingest.Elasticsearch" />
11+
</ItemGroup>
12+
13+
<ItemGroup>
14+
<ProjectReference Include="..\Elastic.Documentation\Elastic.Documentation.csproj"/>
15+
</ItemGroup>
16+
17+
</Project>

src/Elastic.Documentation/Diagnostics/IDiagnosticsCollector.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,18 @@ public static void EmitWarning(this IDiagnosticsCollector collector, IFileInfo f
3535

3636
public static void EmitHint(this IDiagnosticsCollector collector, IFileInfo file, string message) =>
3737
collector.EmitHint(file.FullName, message);
38+
39+
/// Emit an error not associated with a file
40+
public static void EmitGlobalError(this IDiagnosticsCollector collector, string message, Exception? e = null) =>
41+
collector.EmitError(string.Empty, message, e);
42+
43+
/// Emit a warning not associated with a file
44+
public static void EmitGlobalWarning(this IDiagnosticsCollector collector, string message) =>
45+
collector.EmitWarning(string.Empty, message);
46+
47+
/// Emit a hint not associated with a file
48+
public static void EmitGlobalHint(this IDiagnosticsCollector collector, string message) =>
49+
collector.EmitHint(string.Empty, message);
3850
}
3951

4052

src/Elastic.Documentation/Links/LinkRegistry.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
33
// See the LICENSE file in the project root for more information
44

5+
using System.Diagnostics.CodeAnalysis;
56
using System.Text.Json;
67
using System.Text.Json.Serialization;
78
using Elastic.Documentation.Serialization;
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// Licensed to Elasticsearch B.V under one or more agreements.
2+
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
3+
// See the LICENSE file in the project root for more information
4+
5+
using System.Text.Json.Serialization;
6+
7+
namespace Elastic.Documentation.Search;
8+
9+
public record DocumentationDocument
10+
{
11+
[JsonPropertyName("title")]
12+
public string? Title { get; set; }
13+
14+
[JsonPropertyName("body")]
15+
public string? Body { get; set; }
16+
17+
[JsonPropertyName("abstract")]
18+
public string? Abstract { get; set; }
19+
20+
[JsonPropertyName("headings")]
21+
public string[] Headings { get; set; } = [];
22+
23+
[JsonPropertyName("links")]
24+
public string[] Links { get; set; } = [];
25+
26+
[JsonPropertyName("url")]
27+
public string? Url { get; set; }
28+
}
29+

src/Elastic.Documentation/Serialization/SourceGenerationContext.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
using System.Text.Json.Serialization;
66
using Elastic.Documentation.Links;
7+
using Elastic.Documentation.Search;
78
using Elastic.Documentation.State;
89

910
namespace Elastic.Documentation.Serialization;
@@ -16,4 +17,5 @@ namespace Elastic.Documentation.Serialization;
1617
[JsonSerializable(typeof(GitCheckoutInformation))]
1718
[JsonSerializable(typeof(LinkRegistry))]
1819
[JsonSerializable(typeof(LinkRegistryEntry))]
20+
[JsonSerializable(typeof(DocumentationDocument))]
1921
public sealed partial class SourceGenerationContext : JsonSerializerContext;

src/Elastic.Markdown/Assets/hljs.ts

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ hljs.registerLanguage('esql', function () {
168168
case_insensitive: true, // language is case-insensitive
169169
keywords: {
170170
keyword:
171-
'FROM ROW SHOW DISSECT DROP ENRICH EVAL GROK KEEP LIMIT RENAME SORT STATS WHERE METADATA',
171+
'FROM ROW SHOW DISSECT DROP ENRICH EVAL GROK KEEP LIMIT LOOKUP JOIN MV_EXPAND RENAME SORT STATS WHERE METADATA CHANGE_POINT',
172172
literal: ['false', 'true', 'null'],
173173
function: [
174174
// aggregate
@@ -180,30 +180,31 @@ hljs.registerLanguage('esql', function () {
180180
'MEDIAN_ABSOLUTE_DEVIATION',
181181
'MIN',
182182
'PERCENTILE',
183+
'ST_CENTROID_AGG',
184+
'ST_EXTENT_AGG',
185+
'STD_DEV',
183186
'SUM',
184187
'TOP',
185188
'VALUES',
186189
'WEIGHTED_AVG',
190+
// grouping
187191
'BUCKET',
188-
192+
'CATEGORIZE',
189193
// conditional
190194
'CASE',
191195
'COALESCE',
192196
'GREATEST',
193197
'LEAST',
194-
195198
//Date
196199
'DATE_DIFF',
197200
'DATE_EXTRACT',
198201
'DATE_FORMAT',
199202
'DATE_PARSE',
200203
'DATE_TRUNC',
201204
'NOW',
202-
203205
//ip
204206
'CIDR_MATCH',
205207
'IP_PREFIX',
206-
207208
//math
208209
'ABS',
209210
'ACOS',
@@ -223,18 +224,19 @@ hljs.registerLanguage('esql', function () {
223224
'PI',
224225
'POW',
225226
'ROUND',
227+
'ROUND_TO',
228+
'SCALB',
226229
'SIGNUM',
227230
'SIN',
228231
'SINH',
229232
'SQRT',
230233
'TAN',
231234
'TANH',
232235
'TAU',
233-
234236
//search
237+
'KQL',
235238
'MATCH',
236239
'QSTR',
237-
238240
//spatial
239241
'ST_DISTANCE',
240242
'ST_INTERSECTS',
@@ -243,23 +245,30 @@ hljs.registerLanguage('esql', function () {
243245
'ST_WITHIN',
244246
'ST_X',
245247
'ST_Y',
246-
248+
'ST_ENVELOPE',
249+
'ST_XMAX',
250+
'ST_XMIN',
251+
'ST_YMAX',
252+
'ST_YMIN',
247253
//string
248-
249254
'BIT_LENGTH',
250255
'BYTE_LENGTH',
251256
'CONCAT',
252257
'ENDS_WITH',
253258
'FROM_BASE64',
259+
'HASH',
254260
'LEFT',
255261
'LENGTH',
256262
'LOCATE',
257263
'LTRIM',
264+
'MD5',
258265
'REPEAT',
259266
'REPLACE',
260267
'REVERSE',
261268
'RIGHT',
262269
'RTRIM',
270+
'SHA1',
271+
'SHA256',
263272
'SPACE',
264273
'SPLIT',
265274
'STARTS_WITH',
@@ -268,12 +277,13 @@ hljs.registerLanguage('esql', function () {
268277
'TO_LOWER',
269278
'TO_UPPER',
270279
'TRIM',
271-
272280
//type conversion
273281
'TO_BOOLEAN',
274282
'TO_CARTESIANPOINT',
275283
'TO_CARTESIANSHAPE',
284+
'TO_DATEPERIOD',
276285
'TO_DATETIME',
286+
'TO_DATE_NANOS',
277287
'TO_DEGREES',
278288
'TO_DOUBLE',
279289
'TO_GEOPOINT',
@@ -283,8 +293,9 @@ hljs.registerLanguage('esql', function () {
283293
'TO_LONG',
284294
'TO_RADIANS',
285295
'TO_STRING',
296+
'TO_TIMEDURATION',
297+
'TO_UNSIGNED_LONG',
286298
'TO_VERSION',
287-
288299
//multivalued
289300
'MV_APPEND',
290301
'MV_AVG',
@@ -303,8 +314,6 @@ hljs.registerLanguage('esql', function () {
303314
'MV_SLICE',
304315
'MV_SUM',
305316
'MV_ZIP',
306-
307-
'KQL',
308317
],
309318
},
310319
contains: [

src/Elastic.Markdown/DocumentationGenerator.cs

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
namespace Elastic.Markdown;
2020

21+
/// Used primarily for testing, do not use in production paths since it might keep references alive to long
2122
public interface IConversionCollector
2223
{
2324
void Collect(MarkdownFile file, MarkdownDocument document, string html);
@@ -40,6 +41,7 @@ public class DocumentationGenerator
4041
private readonly ILogger _logger;
4142
private readonly IFileSystem _writeFileSystem;
4243
private readonly IDocumentationFileExporter _documentationFileExporter;
44+
private readonly IMarkdownExporter[] _markdownExporters;
4345
private HtmlWriter HtmlWriter { get; }
4446

4547
public DocumentationSet DocumentationSet { get; }
@@ -51,12 +53,14 @@ public DocumentationGenerator(
5153
ILoggerFactory logger,
5254
INavigationHtmlWriter? navigationHtmlWriter = null,
5355
IDocumentationFileOutputProvider? documentationFileOutputProvider = null,
56+
IMarkdownExporter[]? markdownExporters = null,
5457
IDocumentationFileExporter? documentationExporter = null,
5558
IConversionCollector? conversionCollector = null,
5659
ILegacyUrlMapper? legacyUrlMapper = null,
5760
IPositionalNavigation? positionalNavigation = null
5861
)
5962
{
63+
_markdownExporters = markdownExporters ?? [];
6064
_documentationFileOutputProvider = documentationFileOutputProvider;
6165
_conversionCollector = conversionCollector;
6266
_writeFileSystem = docSet.Context.WriteFileSystem;
@@ -100,7 +104,7 @@ public async Task<GenerationResult> GenerateAll(Cancel ctx)
100104

101105
var generationState = Context.SkipDocumentationState ? null : GetPreviousGenerationState();
102106

103-
// clear output directory if force is true but never for assembler builds since these build multiple times to the output.
107+
// clear the output directory if force is true but never for assembler builds since these build multiple times to the output.
104108
if (Context is { AssemblerBuild: false, Force: true }
105109
// clear the output directory if force is false but generation state is null, except for assembler builds.
106110
|| (Context is { AssemblerBuild: false, Force: false } && generationState == null))
@@ -209,7 +213,7 @@ private async Task ExtractEmbeddedStaticResources(Cancel ctx)
209213
}
210214
}
211215

212-
private async Task ProcessFile(HashSet<string> offendingFiles, DocumentationFile file, DateTimeOffset outputSeenChanges, Cancel token)
216+
private async Task ProcessFile(HashSet<string> offendingFiles, DocumentationFile file, DateTimeOffset outputSeenChanges, Cancel ctx)
213217
{
214218
if (!Context.Force)
215219
{
@@ -220,10 +224,27 @@ private async Task ProcessFile(HashSet<string> offendingFiles, DocumentationFile
220224
}
221225

222226
_logger.LogTrace("--> {FileFullPath}", file.SourceFile.FullName);
223-
//TODO send file to OutputFile() so we can validate its scope is defined in navigation.yml
224227
var outputFile = OutputFile(file.RelativePath);
225228
if (outputFile is not null)
226-
await _documentationFileExporter.ProcessFile(Context, file, outputFile, HtmlWriter, _conversionCollector, token);
229+
{
230+
var context = new ProcessingFileContext
231+
{
232+
BuildContext = Context,
233+
OutputFile = outputFile,
234+
ConversionCollector = _conversionCollector,
235+
File = file,
236+
HtmlWriter = HtmlWriter
237+
};
238+
await _documentationFileExporter.ProcessFile(context, ctx);
239+
if (file is MarkdownFile markdown)
240+
{
241+
foreach (var exporter in _markdownExporters)
242+
{
243+
var document = context.MarkdownDocument ??= await markdown.ParseFullAsync(ctx);
244+
_ = await exporter.ExportAsync(new MarkdownExportContext { Document = document, File = markdown }, ctx);
245+
}
246+
}
247+
}
227248
}
228249

229250
private IFileInfo? OutputFile(string relativePath)

0 commit comments

Comments
 (0)