diff --git a/docs/source/markup/applies.md b/docs/source/markup/applies.md index fece0b0..2d540cd 100644 --- a/docs/source/markup/applies.md +++ b/docs/source/markup/applies.md @@ -49,12 +49,16 @@ Are equivalent, note `all` just means we won't be rendering the version portion ## This section has its own applies annotations -```{applies} +:::{applies} :stack: unavailable :serverless: tech-preview -``` +:cloud: ga +::: -This section describes a feature that's unavailable in `stack` and in tech preview on `serverless` +:::{note} +the `{applies}` directive **MUST** be preceded by a heading. +::: -the `{applies}` directive **MUST** be preceded by a heading. \ No newline at end of file +This section describes a feature that's unavailable in `stack` and `ga` in all cloud products +however its tech preview on `serverless` since it overrides what `cloud` specified. diff --git a/src/Elastic.Markdown/Myst/Directives/AppliesBlock.cs b/src/Elastic.Markdown/Myst/Directives/AppliesBlock.cs index f475034..a825c76 100644 --- a/src/Elastic.Markdown/Myst/Directives/AppliesBlock.cs +++ b/src/Elastic.Markdown/Myst/Directives/AppliesBlock.cs @@ -16,7 +16,23 @@ public class AppliesBlock(DirectiveBlockParser parser, Dictionary)); - if (x is not Dictionary { Count: > 0 } dictionary) + var deserialized = rootDeserializer.Invoke(typeof(Dictionary)); + if (deserialized is not Dictionary { Count: > 0 } dictionary) return null; var deployment = new Deployment(); - if (TryGetAvailability("stack", out var version)) + + if (TryGetAvailability("cloud", out var version)) + { + deployment.Cloud ??= new CloudManagedDeployment(); + deployment.Cloud.Serverless = version; + deployment.Cloud.Hosted = version; + } + if (TryGetAvailability("self", out version)) + { + deployment.SelfManaged ??= new SelfManagedDeployment(); + deployment.SelfManaged.Ece = version; + deployment.SelfManaged.Eck = version; + deployment.SelfManaged.Stack = version; + } + + if (TryGetAvailability("stack", out version)) { deployment.SelfManaged ??= new SelfManagedDeployment(); deployment.SelfManaged.Stack = version; diff --git a/tests/Elastic.Markdown.Tests/FrontMatter/ProductConstraintTests.cs b/tests/Elastic.Markdown.Tests/FrontMatter/ProductConstraintTests.cs index 63bbc2a..dd6a1b9 100644 --- a/tests/Elastic.Markdown.Tests/FrontMatter/ProductConstraintTests.cs +++ b/tests/Elastic.Markdown.Tests/FrontMatter/ProductConstraintTests.cs @@ -111,13 +111,13 @@ public void Assert() => File.YamlFrontMatter!.AppliesTo!.SelfManaged!.Stack.Should().BeEquivalentTo(ProductAvailability.GenerallyAvailable); } -public class EmptyCloudSetsAllProductsToAll(ITestOutputHelper output) : DirectiveTest(output, +public class EmptyCloudSetsAllCloudProductsToAll(ITestOutputHelper output) : DirectiveTest(output, """ --- title: Elastic Docs v3 navigation_title: "Documentation Guide" applies: - hosted: + cloud: --- """ ) @@ -126,3 +126,42 @@ public class EmptyCloudSetsAllProductsToAll(ITestOutputHelper output) : Directiv public void Assert() => File.YamlFrontMatter!.AppliesTo!.Cloud!.Hosted.Should().BeEquivalentTo(ProductAvailability.GenerallyAvailable); } + +public class EmptySelfSetsAllSelfManagedProductsToAll(ITestOutputHelper output) : DirectiveTest(output, +""" +--- +title: Elastic Docs v3 +navigation_title: "Documentation Guide" +applies: + self: + stack: deprecated 9.0.0 +--- +""" +) +{ + [Fact] + public void Assert() + { + File.YamlFrontMatter!.AppliesTo!.SelfManaged!.Eck.Should() + .BeEquivalentTo(ProductAvailability.GenerallyAvailable); + File.YamlFrontMatter!.AppliesTo!.SelfManaged!.Stack.Should() + .BeEquivalentTo(new ProductAvailability { Lifecycle = Deprecated, Version = new (9,0,0) }); + } +} + +public class CloudProductsOverwriteDeploymentType(ITestOutputHelper output) : DirectiveTest(output, +""" +--- +title: Elastic Docs v3 +navigation_title: "Documentation Guide" +applies: + cloud: +--- +""" +) +{ + [Fact] + public void Assert() => + File.YamlFrontMatter!.AppliesTo!.Cloud!.Hosted.Should().BeEquivalentTo(ProductAvailability.GenerallyAvailable); +} +