-
Notifications
You must be signed in to change notification settings - Fork 19
Add all versions in version dropdown and filter out non-existing URLs #1367
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add all versions in version dropdown and filter out non-existing URLs #1367
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds comprehensive legacy version support by wiring in a bloom-filter–backed page existence checker and updating the UI to list all historical versions while disabling links for pages that no longer exist.
- Introduces a new
Elastic.Documentation.LegacyDocs
project withLegacyPageChecker
and CLI commands to generate/check against a bloom filter. - Enhances
PageLegacyUrlMapper
to mark legacy mappings as existing or not, and updates the Razor UI (_TableOfContents.cshtml
) and HTML writer to render/disable links accordingly. - Updates version dropdown logic to include all versions (
Skip(1).ToArray()
), adjusts YAML mappings to use trailing slashes, and fixes project references.
Reviewed Changes
Copilot reviewed 22 out of 22 changed files in this pull request and generated 2 comments.
Show a summary per file
File | Description |
---|---|
src/tooling/docs-assembler/Legacy/PageLegacyUrlMapper.cs | Added existence check via LegacyPageChecker , updated mapping API |
src/tooling/docs-assembler/Cli/LegacyDocsCommands.cs | New CLI for bloom-filter creation and page-existence queries |
src/tooling/docs-assembler/Cli/RepositoryCommands.cs | Wired up PageLegacyUrlMapper with LegacyPageChecker |
src/tooling/docs-assembler/AssembleSources.cs | Adjusted YAML key handling (removed forced trailing slash) |
src/Elastic.Markdown/Slices/Layout/_TableOfContents.cshtml | Conditional rendering/disabling of legacy version links |
src/Elastic.Markdown/Slices/HtmlWriter.cs | Changed LegacyPages to include all prior versions |
src/tooling/docs-assembler/legacy-url-mappings.yml | Added trailing slashes to keys for mapping consistency |
Comments suppressed due to low confidence (3)
src/tooling/docs-assembler/Legacy/PageLegacyUrlMapper.cs:21
- There are no existing unit tests covering the new filtering logic in
MapLegacyUrl
. Adding tests for scenarios where pages exist and do not exist will help prevent regressions.
public IReadOnlyCollection<LegacyPageMapping> MapLegacyUrl(IReadOnlyCollection<string>? mappedPages)
src/tooling/docs-assembler/Cli/LegacyDocsCommands.cs:17
- [nitpick] The logger is typed as
Program
, but this class isLegacyDocsCommands
. For clarity and consistency, consider usingILogger<LegacyDocsCommands>
.
private readonly ILogger<Program> _log = logger.CreateLogger<Program>();
src/tooling/docs-assembler/AssembleSources.cs:141
- Interpolating
mappingValues
(a list) directly will call itsToString()
instead of listing items. Consider usingstring.Join(", ", mappingValues)
for a clearer warning message.
reader.EmitWarning($"'{mappingKey}' is already mapped to '{mappingValues}'");
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, just a few nitpicks.
Directory.Packages.props
Outdated
@@ -19,7 +19,9 @@ | |||
<PackageVersion Include="FakeItEasy" Version="8.3.0" /> | |||
<PackageVersion Include="Elastic.Ingest.Elasticsearch" Version="0.11.3" /> | |||
<PackageVersion Include="Microsoft.OpenApi" Version="2.0.0-preview9" /> | |||
<PackageVersion Include="Octokit" Version="14.0.0" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks unreferenced, can remove this dep?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Directory.Packages.props
Outdated
<PackageVersion Include="System.Text.Json" Version="9.0.5" /> | ||
<PackageVersion Include="TestableIO.System.IO.Abstractions.Wrappers" Version="22.0.14" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also not used (we use System.IO.Abstractions
which is the same thing).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
var itemList = new List<string>(items); | ||
var filter = new BloomFilter(itemList.Count, falsePositiveProbability); | ||
foreach (var item in itemList) | ||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Inconsistent braces style
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for (var i = 0; i < size; i++) | ||
{ | ||
if ((bitArrayBytes[i / 8] & (1 << (i % 8))) != 0) | ||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Inconsistent braces style
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/// <returns>False if the item is definitely not in the set, True if it might be.</returns> | ||
public bool Check(string item) | ||
{ | ||
var itemBytes = Encoding.UTF8.GetBytes(item.Replace("/guide/en/", "")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lets do the item.Replace("/guide/en/", "")
at the call site of Check
so the bloom filter implementation stays agnostic.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did it a little different.
I'm now building the bloom filter binary with /guide/en
instead.
Hence, the BloomFilter class itself only knows it's storing a list of strings.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In my first attempt, I thought the string size might influence the size of the bloom.bin file, which is why I removed the /guide/en prefix in the first place.
But obviously, it doesn't, since it's only storing the hashes.
This pull request introduces significant updates to the Elastic documentation ecosystem, including the addition of a Bloom filter-based legacy page checker, new tooling commands, and project restructuring. The changes aim to improve the efficiency of legacy page validation, enhance project modularity, and refine the user experience in documentation navigation.
Documentation Enhancements
BloomFilter
class insrc/Elastic.Documentation.LegacyDocs/BloomFilter.cs
to enable efficient legacy page existence checks. The filter supports persistence and optimal parameter calculation for false positive probability.LegacyPageChecker
insrc/Elastic.Documentation.LegacyDocs/LegacyPageChecker.cs
for checking legacy page existence using the Bloom filter. Includes methods for loading and generating the Bloom filter binary file.IPagesProvider
andLocalPagesProvider
insrc/Elastic.Documentation.LegacyDocs/PagesProvider.cs
to fetch pages from a local repository.src/Elastic.Documentation.LegacyDocs/README.md
.Project Restructuring
Elastic.Documentation.LegacyDocs
andElastic.Documentation.LegacyDocs.Tests
projects to the solution, along with their configurations indocs-builder.sln
. [1] [2]legacy-pages.bloom.bin
as an embedded resource inElastic.Documentation.LegacyDocs.csproj
.Elastic.Documentation.LegacyDocs
with other components, such asElastic.Markdown
.Tooling Updates
src/tooling/docs-assembler/Cli/LegacyDocsCommands.cs
for generating and validating Bloom filter binaries via CLI.BuildAll
insrc/tooling/docs-assembler/Cli/RepositoryCommands.cs
to use the newLegacyPageChecker
for page validation.UI Improvements
_TableOfContents.cshtml
to display legacy page links conditionally based on their existence. Improved styling for better visual hierarchy. [1] [2]HtmlWriter.cs
to dynamically populate version dropdown items based on legacy page mappings.Miscellaneous Fixes
Elastic.Documentation.Tooling.csproj
.docs-assembler/AssembleSources.cs
.