Skip to content

Commit 403faab

Browse files
authored
Merge branch 'main' into patch-2
2 parents b3686ca + 236e61e commit 403faab

File tree

13 files changed

+744
-78
lines changed

13 files changed

+744
-78
lines changed

Directory.Packages.props

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,30 +5,32 @@
55
<MinVerSkip Condition="'$(Configuration)' == 'Debug'">true</MinVerSkip>
66
<ImplicitUsings>enable</ImplicitUsings>
77
<Nullable>enable</Nullable>
8+
<CentralPackageTransitivePinningEnabled>true</CentralPackageTransitivePinningEnabled>
89
</PropertyGroup>
910
<ItemGroup>
1011
<GlobalPackageReference Include="MinVer" Version="6.0.0" PrivateAssets="All" />
1112
</ItemGroup>
1213
<!-- AWS -->
1314
<ItemGroup>
1415
<PackageVersion Include="Amazon.Lambda.AspNetCoreServer.Hosting" Version="1.9.0" />
15-
<PackageVersion Include="Amazon.Lambda.RuntimeSupport" Version="1.13.0" />
16-
<PackageVersion Include="Amazon.Lambda.Core" Version="2.5.1" />
16+
<PackageVersion Include="Amazon.Lambda.RuntimeSupport" Version="1.13.1" />
17+
<PackageVersion Include="Amazon.Lambda.Core" Version="2.7.0" />
1718
<PackageVersion Include="Amazon.Lambda.S3Events" Version="3.1.0" />
1819
<PackageVersion Include="Amazon.Lambda.Serialization.SystemTextJson" Version="2.4.4" />
1920
<PackageVersion Include="Amazon.Lambda.SQSEvents" Version="2.2.0" />
20-
<PackageVersion Include="Aspire.Hosting" Version="9.4.0" />
21-
<PackageVersion Include="Aspire.Hosting.Testing" Version="9.4.0" />
21+
<PackageVersion Include="Aspire.Hosting" Version="9.4.2" />
22+
<PackageVersion Include="Aspire.Hosting.Testing" Version="9.4.2" />
2223
<PackageVersion Include="AWSSDK.Core" Version="4.0.0.2" />
2324
<PackageVersion Include="AWSSDK.SQS" Version="4.0.0.1" />
2425
<PackageVersion Include="AWSSDK.S3" Version="4.0.0.1" />
26+
<PackageVersion Include="KubernetesClient" Version="17.0.14" />
2527
<PackageVersion Include="Elastic.Aspire.Hosting.Elasticsearch" Version="9.3.0" />
2628
<PackageVersion Include="Elastic.Clients.Elasticsearch" Version="9.1.4" />
2729
<PackageVersion Include="FakeItEasy" Version="8.3.0" />
2830
<PackageVersion Include="Elastic.Ingest.Elasticsearch" Version="0.14.0" />
2931
<PackageVersion Include="InMemoryLogger" Version="1.0.66" />
3032
<PackageVersion Include="MartinCostello.Logging.XUnit.v3" Version="0.6.0" />
31-
<PackageVersion Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="9.0.4" />
33+
<PackageVersion Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="9.0.7" />
3234
<PackageVersion Include="Microsoft.OpenApi" Version="2.0.0-preview9" />
3335
<PackageVersion Include="System.Text.Json" Version="9.0.5" />
3436
<PackageVersion Include="TUnit" Version="0.25.21" />
@@ -61,7 +63,7 @@
6163
<PackageVersion Include="Slugify.Core" Version="4.0.1" />
6264
<PackageVersion Include="SoftCircuits.IniFileParser" Version="2.7.0" />
6365
<PackageVersion Include="System.IO.Abstractions" Version="22.0.16" />
64-
<PackageVersion Include="Microsoft.Extensions.Hosting.Abstractions" Version="9.0.4" />
66+
<PackageVersion Include="Microsoft.Extensions.Hosting.Abstractions" Version="9.0.7" />
6567
<PackageVersion Include="Utf8StreamReader" Version="1.3.2" />
6668
<PackageVersion Include="Vecc.YamlDotNet.Analyzers.StaticGenerator" Version="16.1.3" PrivateAssets="All" />
6769
<PackageVersion Include="Westwind.AspNetCore.LiveReload" Version="0.5.2" />
@@ -79,7 +81,7 @@
7981
</ItemGroup>
8082
<!-- Test packages -->
8183
<ItemGroup>
82-
<PackageVersion Include="Aspire.Hosting.AppHost" Version="9.4.0" />
84+
<PackageVersion Include="Aspire.Hosting.AppHost" Version="9.4.2" />
8385
<PackageVersion Include="AngleSharp.Diffing" Version="1.0.0" />
8486
<PackageVersion Include="DiffPlex" Version="1.7.2" />
8587
<PackageVersion Include="FluentAssertions" Version="7.2.0" />
@@ -95,4 +97,4 @@
9597
</PackageVersion>
9698
<PackageVersion Include="xunit.v3" Version="2.0.2" />
9799
</ItemGroup>
98-
</Project>
100+
</Project>

NOTICE.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -555,5 +555,3 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
555555
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
556556
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
557557
SOFTWARE.
558-
559-

docs/syntax/code.md

Lines changed: 48 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -267,10 +267,6 @@ project:
267267

268268
### Console code blocks
269269

270-
:::{note}
271-
This feature is still being developed.
272-
:::
273-
274270
We document a lot of API endpoints at Elastic. For these endpoints, we support `console` as a language. The term console relates to the dev console in kibana which users can link to directly from these code snippets.
275271

276272
In a console code block, the first line is highlighted as a dev console string and the remainder as json:
@@ -309,6 +305,54 @@ GET /mydocuments/_search
309305

310306
::::
311307

308+
Console code blocks now support multiple API calls within a single code block. When you have multiple console commands, they are displayed as separate sections within the same block with proper visual separation:
309+
310+
::::{tab-set}
311+
312+
:::{tab-item} Output
313+
314+
```console
315+
GET /mydocuments/_search
316+
{
317+
"from": 1,
318+
"query": {
319+
"match_all" {}
320+
}
321+
}
322+
323+
POST /mydocuments/_doc
324+
{
325+
"title": "New Document",
326+
"content": "This is a sample document"
327+
}
328+
```
329+
330+
:::
331+
332+
:::{tab-item} Markdown
333+
334+
````markdown
335+
```console
336+
GET /mydocuments/_search
337+
{
338+
"from": 1,
339+
"query": {
340+
"match_all" {}
341+
}
342+
}
343+
344+
POST /mydocuments/_doc
345+
{
346+
"title": "New Document",
347+
"content": "This is a sample document"
348+
}
349+
```
350+
````
351+
352+
:::
353+
354+
::::
355+
312356
### Code block substitutions
313357

314358
You can use substitutions to insert reusable values into your code block examples.

docs/testing/index.md

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,70 @@ The files in this directory are used for testing purposes. Do not edit these fil
3131
"key": "value"
3232
}
3333
```
34+
35+
```console
36+
PUT metricbeat-2016.05.30/_doc/1?refresh <1>
37+
{"system.cpu.idle.pct": 0.908}
38+
PUT metricbeat-2016.05.31/_doc/1?refresh <2>
39+
{"system.cpu.idle.pct": 0.105}
40+
```
41+
1. test 1
42+
2. test 2
43+
44+
```console
45+
POST _reindex
46+
{
47+
"max_docs": 10,
48+
"source": {
49+
"index": "my-index-000001",
50+
"query": {
51+
"function_score" : {
52+
"random_score" : {},
53+
"min_score" : 0.9
54+
}
55+
}
56+
},
57+
"dest": {
58+
"index": "my-new-index-000001"
59+
}
60+
}
61+
```
62+
63+
```console
64+
GET metricbeat-2016.05.30-1/_doc/1
65+
GET metricbeat-2016.05.31-1/_doc/1
66+
```
67+
68+
```console
69+
PUT my-index-000001
70+
{
71+
"mappings": {
72+
"enabled": false <1>
73+
}
74+
}
75+
76+
PUT my-index-000001/_doc/session_1
77+
{
78+
"user_id": "kimchy",
79+
"session_data": {
80+
"arbitrary_object": {
81+
"some_array": [ "foo", "bar", { "baz": 2 } ]
82+
}
83+
},
84+
"last_updated": "2015-12-06T18:20:22"
85+
}
86+
87+
GET my-index-000001/_doc/session_1 <2>
88+
89+
GET my-index-000001/_mapping <3>
90+
```
91+
92+
1. The entire mapping is disabled.
93+
2. The document can be retrieved.
94+
3. Checking the mapping reveals that no fields have been added.
95+
96+
```javascript
97+
const foo = "bar"; <1>
98+
```
99+
100+
1. This is a JavaScript code block.

src/Elastic.Documentation.Site/Assets/markdown/code.css

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,13 @@
1919
code:last-child {
2020
@apply rounded-b-sm;
2121
}
22-
code.language-apiheader {
23-
@apply border-b-grey-80 border-b-1;
22+
code.language-apiheader + code.language-json {
23+
@apply -mt-6 pt-0!;
24+
}
25+
26+
code.language-json + code.language-apiheader,
27+
code.language-apiheader + code.language-apiheader {
28+
@apply border-t-grey-100 border-t-1 border-dotted;
2429
}
2530
}
2631

src/Elastic.Markdown/Myst/CodeBlocks/Code.cshtml

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,22 @@
88
<a class="headerlink" href="@Model.CrossReferenceName" title="Link to this code">¶</a>
99
</div>
1010
}
11-
<pre>@if (!string.IsNullOrEmpty(Model.ApiCallHeader)) { <code class="language-apiheader">@Model.ApiCallHeader</code> }@(Model.RenderBlock())</pre>
11+
<pre>
12+
@if (Model.ApiSegments.Count > 0)
13+
{
14+
@foreach (var segment in Model.ApiSegments)
15+
{
16+
<code class="language-apiheader">@(Model.RenderLineWithCallouts(segment.Header, segment.LineNumber))</code>
17+
@if (segment.ContentLinesWithNumbers.Count > 0)
18+
{
19+
<code class="language-json">@(Model.RenderContentLinesWithCallouts(segment.ContentLinesWithNumbers))</code>
20+
}
21+
}
22+
}
23+
else
24+
{
25+
@(Model.RenderBlock())
26+
}
27+
</pre>
1228
</div>
1329
</div>

src/Elastic.Markdown/Myst/CodeBlocks/CodeViewModel.cs

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ namespace Elastic.Markdown.Myst.CodeBlocks;
99

1010
public class CodeViewModel
1111
{
12-
public required string? ApiCallHeader { get; init; }
12+
public required List<ApiSegment> ApiSegments { get; init; }
1313
public required string? Caption { get; init; }
1414
public required string Language { get; init; }
1515
public required string? CrossReferenceName { get; init; }
@@ -29,4 +29,53 @@ public HtmlString RenderBlock()
2929
DocumentationObjectPoolProvider.HtmlRendererPool.Return(subscription);
3030
return new HtmlString(result);
3131
}
32+
33+
public HtmlString RenderLineWithCallouts(string content, int lineNumber)
34+
{
35+
if (EnhancedCodeBlock?.CallOuts == null)
36+
return new HtmlString(content);
37+
38+
var callouts = EnhancedCodeBlock.CallOuts.Where(c => c.Line == lineNumber);
39+
if (!callouts.Any())
40+
return new HtmlString(content);
41+
42+
var line = content;
43+
var html = new System.Text.StringBuilder();
44+
45+
// Remove callout markers from the line
46+
foreach (var callout in callouts)
47+
{
48+
var calloutPattern = $"<{callout.Index}>";
49+
line = line.Replace(calloutPattern, "");
50+
}
51+
line = line.TrimEnd();
52+
53+
_ = html.Append(line);
54+
55+
// Add callout HTML after the line
56+
foreach (var callout in callouts)
57+
{
58+
_ = html.Append($"<span class=\"code-callout\" data-index=\"{callout.Index}\"></span>");
59+
}
60+
61+
return new HtmlString(html.ToString());
62+
}
63+
64+
public HtmlString RenderContentLinesWithCallouts(List<(string Content, int LineNumber)> contentLinesWithNumbers)
65+
{
66+
if (contentLinesWithNumbers.Count == 0)
67+
return HtmlString.Empty;
68+
69+
var html = new System.Text.StringBuilder();
70+
for (var i = 0; i < contentLinesWithNumbers.Count; i++)
71+
{
72+
var (content, lineNumber) = contentLinesWithNumbers[i];
73+
74+
if (i > 0)
75+
_ = html.Append('\n');
76+
77+
_ = html.Append(RenderLineWithCallouts(content, lineNumber));
78+
}
79+
return new HtmlString(html.ToString());
80+
}
3281
}

src/Elastic.Markdown/Myst/CodeBlocks/EnhancedCodeBlock.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,14 @@
1010

1111
namespace Elastic.Markdown.Myst.CodeBlocks;
1212

13+
public class ApiSegment
14+
{
15+
public string Header { get; set; } = "";
16+
public List<string> ContentLines { get; set; } = [];
17+
public int LineNumber { get; set; }
18+
public List<(string Content, int LineNumber)> ContentLinesWithNumbers { get; set; } = [];
19+
}
20+
1321
public class EnhancedCodeBlock(BlockParser parser, ParserContext context)
1422
: FencedCodeBlock(parser), IBlockExtension
1523
{
@@ -31,5 +39,5 @@ public class EnhancedCodeBlock(BlockParser parser, ParserContext context)
3139

3240
public string? Caption { get; set; }
3341

34-
public string? ApiCallHeader { get; set; }
42+
public List<ApiSegment> ApiSegments { get; set; } = [];
3543
}

src/Elastic.Markdown/Myst/CodeBlocks/EnhancedCodeBlockHtmlRenderer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ protected override void Write(HtmlRenderer renderer, EnhancedCodeBlock block)
128128
CrossReferenceName = string.Empty,// block.CrossReferenceName,
129129
Language = block.Language,
130130
Caption = block.Caption,
131-
ApiCallHeader = block.ApiCallHeader,
131+
ApiSegments = block.ApiSegments,
132132
EnhancedCodeBlock = block
133133
});
134134

0 commit comments

Comments
 (0)