Skip to content

Add products frontmatter #1226

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

Merged
merged 10 commits into from
May 8, 2025
Merged

Add products frontmatter #1226

merged 10 commits into from
May 8, 2025

Conversation

reakaleek
Copy link
Member

@reakaleek reakaleek commented May 7, 2025

Part of #1200

Changes

Add products frontmatter. A list of product IDs.

Example

---
products:
  - apm-java-agent
  - edot-java
---

You can find the full list of available product IDs at https://docs-v3-preview.elastic.dev/elastic/docs-builder/pull/1226/syntax/frontmatter#products

@reakaleek reakaleek requested a review from a team as a code owner May 7, 2025 17:16
@reakaleek reakaleek self-assigned this May 7, 2025
@reakaleek reakaleek marked this pull request as draft May 7, 2025 17:52
@reakaleek reakaleek marked this pull request as ready for review May 7, 2025 20:18
Copy link
Member

@Mpdreamz Mpdreamz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some nits but overall LGTM!

return displayAttr?.Name ?? product.ToString();
}

public static string? GetEnumMemberValue(this Product product)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We depend on a source generator package that allows us to do this without reflection :)

Using that we can also implement the writeyaml method as a oneliner. That way we can roundtrip serialize yamlfrontmatter.

Reviewing on my phone, let me know if I need to provide more targeted pointers!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.Select(value => value!)
.ToList();

public static string Suggestion(string input) =>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Love this, all good compilers have this :)

Maybe add it as a more general extension method in Elastic.Documentation? One taking a list of candidates.

Again using the enim source generator package that list can be queried without using reflection.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Mpdreamz
Copy link
Member

Mpdreamz commented May 7, 2025

https://github.com/andrewlock/NetEscapades.EnumGenerators is the alluded package.

@reakaleek reakaleek requested review from Mpdreamz, a team and Copilot May 8, 2025 10:25
Copy link
Contributor

@Copilot Copilot AI left a 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 support for a new frontmatter property, products, which holds a list of product IDs. Key changes include new tests for products frontmatter, updates to YAML parsing and serialization with a new ProductConverter, and modifications to the layout and documentation files to render and document the products metadata.

Reviewed Changes

Copilot reviewed 11 out of 13 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
tests/Elastic.Markdown.Tests/FrontMatter/YamlFrontMatterTests.cs Adds tests for single/multiple products and suggestions for spelling/casing errors.
src/Elastic.Markdown/Suggestions/Suggestions.cs Introduces a new Suggestion class using a primary constructor for product name suggestions.
src/Elastic.Markdown/Slices/_ViewModels.cs, Layout/_Head.cshtml, Index.cshtml Updates view models and templates to include products metadata.
src/Elastic.Markdown/Myst/YamlSerialization.cs, FrontMatter/Products.cs, FrontMatter/FrontMatterParser.cs Adds new YAML type converter and products enum definitions to support products frontmatter.
src/Elastic.Markdown/IO/MarkdownFile.cs Adds error handling for invalid product values during YAML frontmatter parsing.
docs/syntax/frontmatter.md Updates documentation to include the new products frontmatter property.
Files not reviewed (2)
  • Directory.Packages.props: Language not supported
  • src/Elastic.Markdown/Elastic.Markdown.csproj: Language not supported

@@ -15,7 +15,8 @@
<PackageVersion Include="Amazon.Lambda.SQSEvents" Version="2.2.0" />
<PackageVersion Include="AWSSDK.Core" Version="4.0.0.2" />
<PackageVersion Include="AWSSDK.SQS" Version="4.0.0.1" />
<PackageVersion Include="AWSSDK.S3" Version="4.0.0.1"/>
<PackageVersion Include="AWSSDK.S3" Version="4.0.0.1" />
<PackageVersion Include="Supernova.Enum.Generators" Version="1.0.17" />
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This ItemGroup is for AWS packages.

Could we remove NetEscapades.EnumGenerators all together in favor of Supernova.Enum.Generators or should we make that a follow up PR?

Copy link
Member Author

@reakaleek reakaleek May 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This ItemGroup is for AWS packages.

Woops, installed it through the UI. 732899d

Could we remove NetEscapades.EnumGenerators all together in favor of Supernova.Enum.Generators or should we make that a follow up PR?

I'd rather do it in a follow-up. Which I can do right after this is merged.

@reakaleek reakaleek merged commit e69d739 into main May 8, 2025
14 checks passed
@reakaleek reakaleek deleted the feature/tags branch May 8, 2025 11:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants