Skip to content

Commit e6d710f

Browse files
committed
Show base version if we don't get a specified version for a versioned product
1 parent 73e8dd7 commit e6d710f

File tree

3 files changed

+29
-8
lines changed

3 files changed

+29
-8
lines changed

src/Elastic.Documentation/AppliesTo/ApplicableToYamlConverter.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ private static void ValidateApplicabilityCollection(string key, AppliesCollectio
284284

285285
// Rule: Only one item per key can use greater-than syntax
286286
var greaterThanItems = items.Where(a =>
287-
a.Version is VersionSpec spec && spec.Kind == VersionSpecKind.GreaterThanOrEqual &&
287+
a.Version is { Kind: VersionSpecKind.GreaterThanOrEqual } &&
288288
a.Version != AllVersionsSpec.Instance).ToList();
289289

290290
if (greaterThanItems.Count > 1)
@@ -335,8 +335,8 @@ private static bool CheckVersionOverlap(VersionSpec v1, VersionSpec v2, out stri
335335
var (v1Min, v1Max) = GetEffectiveRange(v1);
336336
var (v2Min, v2Max) = GetEffectiveRange(v2);
337337

338-
var overlaps = v1Min.CompareTo(v2Max ?? new SemVersion(9999, 9999, 9999)) <= 0 &&
339-
v2Min.CompareTo(v1Max ?? new SemVersion(9999, 9999, 9999)) <= 0;
338+
var overlaps = v1Min.CompareTo(v2Max ?? new SemVersion(99999, 99999, 99999)) <= 0 &&
339+
v2Min.CompareTo(v1Max ?? new SemVersion(99999, 99999, 99999)) <= 0;
340340

341341
if (overlaps)
342342
message = $"Version ranges overlap.";

src/Elastic.Documentation/SemVersion.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
namespace Elastic.Documentation;
1010

11-
public class AllVersions() : SemVersion(9999, 9999, 9999)
11+
public class AllVersions() : SemVersion(99999, 99999, 99999)
1212
{
1313
public static AllVersions Instance { get; } = new();
1414
}

src/Elastic.Markdown/Myst/Components/ApplicabilityRenderer.cs

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
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;
65
using Elastic.Documentation;
76
using Elastic.Documentation.AppliesTo;
87
using Elastic.Documentation.Configuration.Versions;
@@ -159,8 +158,10 @@ private static string BuildTooltipText(
159158
{
160159
var tooltipText = "";
161160

162-
tooltipText = applicability.Version is not null && applicability.Version != AllVersionsSpec.Instance
163-
? applicability.Version.Min <= versioningSystem.Current
161+
// Check if a specific version is provided
162+
if (applicability.Version is not null && applicability.Version != AllVersionsSpec.Instance)
163+
{
164+
tooltipText = applicability.Version.Min <= versioningSystem.Current
164165
? $"{lifecycleFull} on {applicabilityDefinition.DisplayName} version {applicability.Version.Min} and later unless otherwise specified."
165166
: applicability.Lifecycle switch
166167
{
@@ -174,8 +175,21 @@ or ProductLifecycle.TechnicalPreview
174175
ProductLifecycle.Removed =>
175176
$"We plan to remove this functionality in a future {applicabilityDefinition.DisplayName} update. Subject to change.",
176177
_ => tooltipText
178+
};
179+
}
180+
else
181+
{
182+
// No version specified - check if we should show base version
183+
tooltipText = versioningSystem.Base.Major != AllVersionsSpec.Instance.Min.Major
184+
? applicability.Lifecycle switch
185+
{
186+
ProductLifecycle.Removed =>
187+
$"Removed in {applicabilityDefinition.DisplayName} {versioningSystem.Base.Major}.{versioningSystem.Base.Minor}.",
188+
_ =>
189+
$"{lifecycleFull} since {versioningSystem.Base.Major}.{versioningSystem.Base.Minor}."
177190
}
178-
: $"{lifecycleFull} on {applicabilityDefinition.DisplayName} unless otherwise specified.";
191+
: $"{lifecycleFull} on {applicabilityDefinition.DisplayName} unless otherwise specified.";
192+
}
179193

180194
var disclaimer = GetDisclaimer(applicability.Lifecycle, versioningSystem.Id);
181195
if (disclaimer is not null)
@@ -246,8 +260,15 @@ private static string BuildBadgeLifecycleText(
246260
/// </summary>
247261
private static string GetBadgeVersionText(VersionSpec? versionSpec, VersioningSystem versioningSystem)
248262
{
263+
// When no version is specified, check if we should show the base version
249264
if (versionSpec is null || versionSpec == AllVersionsSpec.Instance)
265+
{
266+
if (versioningSystem.Base.Major != AllVersionsSpec.Instance.Min.Major)
267+
return $"{versioningSystem.Base.Major}.{versioningSystem.Base.Minor}+";
268+
269+
// Otherwise, this is an unversioned product, show no version
250270
return string.Empty;
271+
}
251272

252273
var kind = versionSpec.Kind;
253274
var min = versionSpec.Min;

0 commit comments

Comments
 (0)