Skip to content

Commit 0ce76c5

Browse files
authored
Merge branch 'main' into fix/forward-nested-layout-sections
2 parents a654fef + c245d33 commit 0ce76c5

File tree

26 files changed

+456
-151
lines changed

26 files changed

+456
-151
lines changed

.github/CODEOWNERS

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
* @elastic/docs-engineering
1+
* @elastic/docs-engineering
2+
/docs/ @elastic/docs

README.md

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,9 @@ Options:
2525
--force <bool?> Force a full rebuild of the destination folder (Default: null)
2626

2727
Commands:
28-
generate Converts a source markdown folder or file to an output folder
29-
serve Continuously serve a documentation folder at http://localhost:3000.
28+
generate Converts a source markdown folder or file to an output folder
29+
serve Continuously serve a documentation folder at http://localhost:3000.
30+
diff validate Validates redirect rules have been applied to the current branch.
3031
File systems changes will be reflected without having to restart the server.
3132
```
3233

@@ -118,6 +119,16 @@ https://github.com/elastic/{your-repository}/settings/pages
118119
119120
---
120121
122+
## Validating redirection rules
123+
124+
If documentation is moved, renamed or deleted, `docs-builder` can verify if changes in the working branch in relation to the default branch are reflected in the repository's `redirects.yml`. Verification in the local machine is currently supported.
125+
126+
`docs-builder diff validate <path>`
127+
128+
`<path>` is an optional parameter to customize the documentation folder path. It defaults to `docs`.
129+
130+
---
131+
121132
## Run without docker
122133

123134
You can use the .NET CLI to publish a self-contained `docs-builder` native code
@@ -140,7 +151,7 @@ existing surveyed tools
140151

141152
# Local Development
142153

143-
## Preqrequisites
154+
## Prerequisites
144155

145156
- [.NET 9.0 SDK](https://dotnet.microsoft.com/en-us/download/dotnet/9.0)
146157
- [Node.js 22.13.1 (LTS)](https://nodejs.org/en/blog/release/v22.13.1)

docs/contribute/index.md

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,29 @@ To contribute to earlier versions of the Elastic Stack, you must work with our [
2424
* For **simple bugfixes and enhancements** --> [contribute on the web](on-the-web.md)
2525
* For **complex or multi-page updates** --> [Contribute locally](locally.md)
2626

27+
Starting with Elastic Stack version 9.0, ECE 4.0, and ECK 3.0, a new set of docs is no longer published for every minor release. Instead, each page stays valid over time and incorporates version-specific changes directly within the content using a [cumulative approach](#cumulative-docs).
28+
29+
#### Write cumulative documentation [#cumulative-docs]
30+
31+
Cumulative documentation means that one page can cover multiple product versions, deployment types, and release stages. Instead of creating separate pages for each release, we update the same page with version-specific details.
32+
33+
This helps readers understand which parts of the content apply to their own ecosystem and product versions, without needing to switch between different versions of a page.
34+
35+
Following this approach, information for supported versions must not be removed unless it was never accurate. Instead, refactor the content to improve clarity or to include details for other products, deployment types, or versions.
36+
37+
In order to achieve this, the markdown source files integrate a **tagging system** meant to identify:
38+
39+
* Which Elastic products and deployment models the content applies to.
40+
* When a feature goes into a new state as compared to the established base version.
41+
42+
This [tagging system](#applies-to) is mandatory for all of the public-facing documentation.
43+
44+
##### The `applies_to` tag [#applies-to]
45+
46+
Use the [`applies_to`](../syntax/applies.md) tag to indicate which versions, deployment types, or release stages each part of the content is relevant to.
47+
48+
You must always use the `applies_to` tag at the [page](../syntax/applies.md#page-annotations) level. Optionally, you can also use it at the [section](../syntax/applies.md#sections) or [inline](../syntax/applies.md#inline-applies-to) level if certain parts of the content apply only to specific versions, deployment types, or release stages.
49+
2750
## Report a bug
2851

2952
* It's a **documentation** problem --> [Open a docs issue](https://github.com/elastic/docs-content/issues/new?template=internal-request.yaml) *or* [Fix it myself](locally.md)
@@ -36,4 +59,4 @@ To contribute to earlier versions of the Elastic Stack, you must work with our [
3659

3760
## Work on docs-builder
3861

39-
That sounds great! See [development](../development/index.md) to learn how to contribute to our documentation build system.
62+
That sounds great! See [development](../development/index.md) to learn how to contribute to our documentation build system.

src/Elastic.Documentation.LegacyDocs/BloomFilter.cs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -141,14 +141,16 @@ public void Save(string filePath)
141141
}
142142

143143
/// <summary>
144-
/// Loads a Bloom Filter from a binary file.
144+
/// Loads a Bloom Filter from a stream.
145+
/// The stream is expected to contain data in the same format as Save() produces.
145146
/// </summary>
146-
/// <param name="filePath">The path to the file containing the filter data.</param>
147+
/// <param name="stream">The stream containing the filter data.</param>
147148
/// <returns>A new BloomFilter instance.</returns>
148-
public static BloomFilter Load(string filePath)
149+
public static BloomFilter Load(Stream stream)
149150
{
150-
using var stream = File.OpenRead(filePath);
151-
using var reader = new BinaryReader(stream);
151+
// Use a BinaryReader, but leave the stream open as it's managed externally.
152+
using var reader = new BinaryReader(stream, Encoding.UTF8, leaveOpen: true);
153+
152154
// 1. Read metadata (Size and HashCount)
153155
var size = reader.ReadInt32();
154156
var hashCount = reader.ReadInt32();

src/Elastic.Documentation.LegacyDocs/LegacyPageChecker.cs

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,17 @@
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.IO.Abstractions;
65
using Elastic.Documentation.Configuration;
76

87
namespace Elastic.Documentation.LegacyDocs;
98

10-
public class LegacyPageChecker(IFileSystem fs)
9+
public class LegacyPageChecker
1110
{
1211
private BloomFilter? _bloomFilter;
13-
private readonly string _bloomFilterBinaryPath = Path.Combine(Paths.WorkingDirectoryRoot.FullName, "src", "Elastic.Documentation.LegacyDocs", "legacy-pages.bloom.bin");
12+
private const string RootNamespace = "Elastic.Documentation.LegacyDocs";
13+
private const string FileName = "legacy-pages.bloom.bin";
14+
private const string ResourceName = $"{RootNamespace}.{FileName}";
15+
private readonly string _bloomFilterBinaryPath = Path.Combine(Paths.WorkingDirectoryRoot.FullName, "src", RootNamespace, FileName);
1416

1517

1618
public bool PathExists(string path)
@@ -19,11 +21,13 @@ public bool PathExists(string path)
1921
return _bloomFilter.Check(path);
2022
}
2123

22-
private BloomFilter LoadBloomFilter()
24+
private static BloomFilter LoadBloomFilter()
2325
{
24-
var bloomFilterBinaryInfo = fs.FileInfo.New(_bloomFilterBinaryPath);
25-
_bloomFilter ??= BloomFilter.Load(bloomFilterBinaryInfo.FullName);
26-
return _bloomFilter;
26+
var assembly = typeof(LegacyPageChecker).Assembly;
27+
using var stream = assembly.GetManifestResourceStream(ResourceName) ?? throw new FileNotFoundException(
28+
$"Embedded resource '{ResourceName}' not found in assembly '{assembly.FullName}'. " +
29+
"Ensure the Build Action for 'legacy-pages.bloom.bin' is 'Embedded Resource' and the path/name is correct.");
30+
return BloomFilter.Load(stream);
2731
}
2832

2933
public void GenerateBloomFilterBinary(IPagesProvider pagesProvider)

src/Elastic.Documentation.Site/package-lock.json

Lines changed: 26 additions & 39 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Elastic.Documentation.Site/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
"@r2wc/react-to-web-component": "^2.0.4",
3737
"@tailwindcss/postcss": "4.1.10",
3838
"@trivago/prettier-plugin-sort-imports": "5.2.2",
39-
"eslint": "9.28.0",
39+
"eslint": "9.29.0",
4040
"globals": "16.2.0",
4141
"moment": "^2.30.1",
4242
"parcel": "2.15.2",

src/Elastic.Documentation/Legacy/ILegacyUrlMapper.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ public record LegacyPageMapping(string RawUrl, string Version, bool Exists)
1111

1212
public interface ILegacyUrlMapper
1313
{
14-
IReadOnlyCollection<LegacyPageMapping> MapLegacyUrl(IReadOnlyCollection<string>? mappedPages);
14+
IReadOnlyCollection<LegacyPageMapping>? MapLegacyUrl(IReadOnlyCollection<string>? mappedPages);
1515
}
1616

1717
public record NoopLegacyUrlMapper : ILegacyUrlMapper

src/Elastic.Markdown/Slices/HtmlWriter.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,9 @@ private async Task<string> RenderLayout(MarkdownFile markdown, MarkdownDocument
110110
Features = DocumentationSet.Configuration.Features,
111111
StaticFileContentHashProvider = StaticFileContentHashProvider,
112112
ReportIssueUrl = reportUrl,
113-
CurrentVersion = legacyPages.Count > 0 ? legacyPages.ElementAt(0).Version : "9.0+",
114-
LegacyPages = legacyPages.Skip(1).ToArray(),
115-
VersionDropdownItems = VersionDrownDownItemViewModel.FromLegacyPageMappings(legacyPages.Skip(1).ToArray()),
113+
CurrentVersion = legacyPages?.Count > 0 ? legacyPages.ElementAt(0).Version : "9.0+",
114+
LegacyPages = legacyPages?.Skip(1).ToArray(),
115+
VersionDropdownItems = VersionDrownDownItemViewModel.FromLegacyPageMappings(legacyPages?.Skip(1).ToArray()),
116116
Products = allProducts
117117
});
118118
return await slice.RenderAsync(cancellationToken: ctx);

src/Elastic.Markdown/Slices/IndexViewModel.cs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ public class IndexViewModel
3333
public required INavigationItem[] Parents { get; init; }
3434

3535
public required string NavigationHtml { get; init; }
36-
public required string? CurrentVersion { get; init; }
37-
public required LegacyPageMapping[] LegacyPages { get; init; }
38-
public required VersionDrownDownItemViewModel[] VersionDropdownItems { get; init; }
36+
public required string CurrentVersion { get; init; }
37+
public required LegacyPageMapping[]? LegacyPages { get; init; }
38+
public required VersionDrownDownItemViewModel[]? VersionDropdownItems { get; init; }
3939
public required string? UrlPathPrefix { get; init; }
4040
public required string? GithubEditUrl { get; init; }
4141
public required string? ReportIssueUrl { get; init; }
@@ -63,8 +63,12 @@ public class VersionDrownDownItemViewModel
6363
public required VersionDrownDownItemViewModel[]? Children { get; init; }
6464

6565
// This logic currently only handles one level of children. Although the model supports multiple levels, it is not currently used.
66-
public static VersionDrownDownItemViewModel[] FromLegacyPageMappings(LegacyPageMapping[] legacyPageMappings)
66+
public static VersionDrownDownItemViewModel[]? FromLegacyPageMappings(LegacyPageMapping[]? legacyPageMappings)
6767
{
68+
if (legacyPageMappings is null)
69+
{
70+
return null;
71+
}
6872
var groupedVersions = GroupByMajorVersion(legacyPageMappings);
6973
return groupedVersions.Select(m =>
7074
{

0 commit comments

Comments
 (0)