Skip to content

Commit eaa39b2

Browse files
committed
Naming refactor, cleanup and docs
1 parent abef44d commit eaa39b2

File tree

12 files changed

+38
-26
lines changed

12 files changed

+38
-26
lines changed

src/Elastic.Documentation.LegacyDocs/BloomFilter.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
using System.Security.Cryptography;
77
using System.Text;
88

9-
namespace Elastic.Documentation.LegacyPageLookup;
9+
namespace Elastic.Documentation.LegacyDocs;
1010

11-
public class BloomFilter
11+
internal sealed class BloomFilter
1212
{
1313
/// <summary>
1414
/// The bit array for the filter.

src/Elastic.Documentation.LegacyDocs/Elastic.Documentation.LegacyDocs.csproj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22

33
<PropertyGroup>
44
<TargetFramework>net9.0</TargetFramework>
5+
<OutputType>Library</OutputType>
56
<ImplicitUsings>enable</ImplicitUsings>
67
<Nullable>enable</Nullable>
7-
<RootNamespace>Elastic.Documentation.LegacyPageLookup</RootNamespace>
8+
<RootNamespace>Elastic.Documentation.LegacyDocs</RootNamespace>
89
</PropertyGroup>
910

1011
<ItemGroup>

src/Elastic.Documentation.LegacyDocs/LegacyPageChecker.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
using System.IO.Abstractions;
66
using Elastic.Documentation.Configuration;
77

8-
namespace Elastic.Documentation.LegacyPageLookup;
8+
namespace Elastic.Documentation.LegacyDocs;
99

10-
public class LegacyPageLookup(IFileSystem fs)
10+
public class LegacyPageChecker(IFileSystem fs)
1111
{
1212
private BloomFilter? _bloomFilter;
1313
private readonly string _bloomFilterBinaryPath = Path.Combine(Paths.WorkingDirectoryRoot.FullName, "src", "Elastic.Documentation.LegacyDocs", "legacy-pages.bloom.bin");

src/Elastic.Documentation.LegacyDocs/PagesProvider.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +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-
6-
using Elastic.Documentation.Configuration;
7-
8-
namespace Elastic.Documentation.LegacyPageLookup;
5+
namespace Elastic.Documentation.LegacyDocs;
96

107
public interface IPagesProvider
118
{
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Legacy Docs
2+
3+
## Legacy Page Checker
4+
5+
The legacy page checker is a tool that checks if an URL exists in the legacy docs system (https://www.elastic.co/guide).
6+
It uses a checked-in bloom filter file loaded into memory to check if an URL exists.
7+
8+
### How to create or update the bloom filter file
9+
10+
The bloom filter file is created by running the following command:
11+
12+
```
13+
dotnet run --project src/tooling/docs-assembler -- legacy-docs create-bloom-bin --built-docs-dir /path/to/elastic/built-docs
14+
```
15+
16+
1. The `--built-docs-dir` option is the path to the locally checked-out [elastic/built-docs](https://github.com/elastic/built-docs) repository.

src/Elastic.Markdown/Slices/HtmlWriter.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
using Elastic.Documentation;
77
using Elastic.Documentation.Configuration.Builder;
88
using Elastic.Documentation.Legacy;
9-
using Elastic.Documentation.LegacyPageLookup;
109
using Elastic.Documentation.Site.FileProviders;
1110
using Elastic.Documentation.Site.Navigation;
1211
using Elastic.Markdown.Extensions.DetectionRules;

src/tooling/Elastic.Documentation.Tooling/Elastic.Documentation.Tooling.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<PackageReference Include="ConsoleAppFramework.Abstractions" />
1111
<PackageReference Include="Microsoft.Extensions.Logging" />
1212
<PackageReference Include="Microsoft.Extensions.Logging.Console" />
13-
<PackageReference Include="Github.Actions.Core" />
13+
<PackageReference Include="GitHub.Actions.Core" />
1414
<PackageReference Include="Crayon" />
1515
<PackageReference Include="Errata" />
1616
</ItemGroup>

src/tooling/docs-assembler/Cli/LegacyDocsCommands.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@
66
using System.IO.Abstractions;
77
using Actions.Core.Services;
88
using ConsoleAppFramework;
9-
using Elastic.Documentation.Configuration;
10-
using Elastic.Documentation.LegacyPageLookup;
9+
using Elastic.Documentation.LegacyDocs;
1110
using Elastic.Documentation.Tooling.Diagnostics.Console;
1211
using Microsoft.Extensions.Logging;
1312

@@ -34,7 +33,7 @@ public async Task<int> CreateBloomBin(string builtDocsDir, Cancel ctx = default)
3433
NoHints = true
3534
}.StartAsync(ctx);
3635
var pagesProvider = new LocalPagesProvider(builtDocsDir);
37-
var legacyPageLookup = new LegacyPageLookup(new FileSystem());
36+
var legacyPageLookup = new LegacyPageChecker(new FileSystem());
3837
legacyPageLookup.GenerateBloomFilterBinary(pagesProvider);
3938
await collector.StopAsync(ctx);
4039
return collector.Errors;
@@ -49,7 +48,7 @@ public async Task<int> PageExists(string path, Cancel ctx = default)
4948
{
5049
NoHints = true
5150
}.StartAsync(ctx);
52-
var legacyPageLookup = new LegacyPageLookup(new FileSystem());
51+
var legacyPageLookup = new LegacyPageChecker(new FileSystem());
5352
var result = legacyPageLookup.PathExists(path);
5453
Console.WriteLine(result ? "exists" : "does not exist");
5554
await collector.StopAsync(ctx);

src/tooling/docs-assembler/Cli/RepositoryCommands.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
using Documentation.Assembler.Sourcing;
1616
using Elastic.Documentation.Configuration;
1717
using Elastic.Documentation.Configuration.Assembler;
18-
using Elastic.Documentation.LegacyPageLookup;
18+
using Elastic.Documentation.LegacyDocs;
1919
using Elastic.Documentation.Tooling.Diagnostics.Console;
2020
using Elastic.Markdown;
2121
using Elastic.Markdown.Exporters;
@@ -129,7 +129,7 @@ public async Task<int> BuildAll(
129129
var pathProvider = new GlobalNavigationPathProvider(navigationFile, assembleSources, assembleContext);
130130
var htmlWriter = new GlobalNavigationHtmlWriter(navigationFile, assembleContext, navigation, assembleSources);
131131

132-
var historyMapper = new PageLegacyUrlMapper(new LegacyPageLookup(new FileSystem()), assembleSources.HistoryMappings);
132+
var historyMapper = new PageLegacyUrlMapper(new LegacyPageChecker(new FileSystem()), assembleSources.HistoryMappings);
133133

134134
var builder = new AssemblerBuilder(logger, assembleContext, navigation, htmlWriter, pathProvider, historyMapper);
135135
await builder.BuildAllAsync(assembleSources.AssembleSets, exporters, ctx);

src/tooling/docs-assembler/Legacy/PageLegacyUrlMapper.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,18 @@
44

55
using System.IO.Abstractions;
66
using Elastic.Documentation.Legacy;
7-
using Elastic.Documentation.LegacyPageLookup;
7+
using Elastic.Documentation.LegacyDocs;
88

99
namespace Documentation.Assembler.Legacy;
1010

1111
public record PageLegacyUrlMapper : ILegacyUrlMapper
1212
{
1313
private IReadOnlyDictionary<string, IReadOnlyCollection<string>> PreviousUrls { get; }
14-
private LegacyPageLookup LegacyPageLookup { get; }
15-
public PageLegacyUrlMapper(LegacyPageLookup legacyPageLookup, IReadOnlyDictionary<string, IReadOnlyCollection<string>> previousUrls)
14+
private LegacyPageChecker LegacyPageChecker { get; }
15+
public PageLegacyUrlMapper(LegacyPageChecker legacyPageChecker, IReadOnlyDictionary<string, IReadOnlyCollection<string>> previousUrls)
1616
{
1717
PreviousUrls = previousUrls;
18-
LegacyPageLookup = legacyPageLookup;
18+
LegacyPageChecker = legacyPageChecker;
1919
}
2020

2121
public IReadOnlyCollection<LegacyPageMapping> MapLegacyUrl(IReadOnlyCollection<string>? mappedPages)
@@ -41,7 +41,7 @@ public IReadOnlyCollection<LegacyPageMapping> MapLegacyUrl(IReadOnlyCollection<s
4141
{
4242
var legacyPageMapping = new LegacyPageMapping(mappedPage, v, true);
4343
var path = Uri.TryCreate(legacyPageMapping.ToString(), UriKind.Absolute, out var uri) ? uri : null;
44-
var exists = LegacyPageLookup.PathExists(path?.AbsolutePath!);
44+
var exists = LegacyPageChecker.PathExists(path?.AbsolutePath!);
4545
return legacyPageMapping with { Exists = exists };
4646
}
4747
).ToArray();

0 commit comments

Comments
 (0)