Skip to content

Commit

Permalink
update applies to syntax to include product lifecycle
Browse files Browse the repository at this point in the history
  • Loading branch information
Mpdreamz committed Dec 13, 2024
1 parent 3acc7ee commit 6c5b387
Show file tree
Hide file tree
Showing 7 changed files with 107 additions and 217 deletions.
1 change: 1 addition & 0 deletions src/Elastic.Markdown/IO/MarkdownFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using Elastic.Markdown.Diagnostics;
using Elastic.Markdown.Myst;
using Elastic.Markdown.Myst.Directives;
using Elastic.Markdown.Myst.FrontMatter;
using Elastic.Markdown.Slices;
using Markdig;
using Markdig.Extensions.Yaml;
Expand Down
1 change: 1 addition & 0 deletions src/Elastic.Markdown/Myst/Directives/IncludeBlock.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.IO.Abstractions;
using Elastic.Markdown.Diagnostics;
using Elastic.Markdown.IO;
using Elastic.Markdown.Myst.FrontMatter;

namespace Elastic.Markdown.Myst.Directives;

Expand Down
46 changes: 46 additions & 0 deletions src/Elastic.Markdown/Myst/FrontMatter/FrontMatterParser.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information

using YamlDotNet.Serialization;

namespace Elastic.Markdown.Myst.FrontMatter;

[YamlStaticContext]
public partial class YamlFrontMatterStaticContext;

[YamlSerializable]
public class YamlFrontMatter
{
[YamlMember(Alias = "title")]
public string? Title { get; set; }

[YamlMember(Alias = "navigation_title")]
public string? NavigationTitle { get; set; }

[YamlMember(Alias = "sub")]
public Dictionary<string, string>? Properties { get; set; }


[YamlMember(Alias = "applies")]
public Deployment? AppliesTo { get; set; }
}

public static class FrontMatterParser
{
public static YamlFrontMatter Deserialize(string yaml)
{
var input = new StringReader(yaml);

var deserializer = new StaticDeserializerBuilder(new YamlFrontMatterStaticContext())
.IgnoreUnmatchedProperties()
.WithTypeConverter(new SemVersionConverter())
.WithTypeConverter(new DeploymentConverter())
.Build();

var frontMatter = deserializer.Deserialize<YamlFrontMatter>(input);
return frontMatter;

}
}

195 changes: 0 additions & 195 deletions src/Elastic.Markdown/Myst/FrontMatterParser.cs

This file was deleted.

1 change: 1 addition & 0 deletions src/Elastic.Markdown/Myst/MarkdownParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using Elastic.Markdown.IO;
using Elastic.Markdown.Myst.Comments;
using Elastic.Markdown.Myst.Directives;
using Elastic.Markdown.Myst.FrontMatter;
using Elastic.Markdown.Myst.InlineParsers;
using Elastic.Markdown.Myst.Substitution;
using Markdig;
Expand Down
1 change: 1 addition & 0 deletions src/Elastic.Markdown/Myst/ParserContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

using System.IO.Abstractions;
using Elastic.Markdown.IO;
using Elastic.Markdown.Myst.FrontMatter;
using Markdig;
using Markdig.Parsers;

Expand Down
Loading

0 comments on commit 6c5b387

Please sign in to comment.