Skip to content

Commit 835f52a

Browse files
authored
Refactor domain model out of Elastic.Markdown.csproj (#1176)
* Move models out of assembler * Rename to Elastic.Documentation for now * Refactor domain model out of Elastic.Markdown.csproj
1 parent a28829d commit 835f52a

File tree

85 files changed

+383
-268
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

85 files changed

+383
-268
lines changed

Directory.Packages.props

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
<PackageVersion Include="Slugify.Core" Version="4.0.1" />
4343
<PackageVersion Include="SoftCircuits.IniFileParser" Version="2.7.0" />
4444
<PackageVersion Include="System.IO.Abstractions" Version="21.0.29" />
45+
<PackageVersion Include="Microsoft.Extensions.Hosting.Abstractions" Version="9.0.4" />
4546
<PackageVersion Include="Utf8StreamReader" Version="1.3.2" />
4647
<PackageVersion Include="Vecc.YamlDotNet.Analyzers.StaticGenerator" Version="16.1.3" PrivateAssets="All" />
4748
<PackageVersion Include="Westwind.AspNetCore.LiveReload" Version="0.5.2" />

src/docs-assembler/Configuration/AssemblyConfiguration.cs renamed to Elastic.Documentation/Configuration/Assembler/AssemblyConfiguration.cs

Lines changed: 2 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
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 Elastic.Markdown.IO.State;
5+
using Elastic.Documentation.Serialization;
66
using YamlDotNet.Serialization;
77

8-
namespace Documentation.Assembler.Configuration;
8+
namespace Elastic.Documentation.Configuration.Assembler;
99

1010
public record AssemblyConfiguration
1111
{
@@ -78,53 +78,3 @@ private static TRepository RepositoryDefaults<TRepository>(TRepository r, string
7878
[YamlMember(Alias = "named_git_references")]
7979
public Dictionary<string, string> NamedGitReferences { get; set; } = [];
8080
}
81-
82-
public record PublishEnvironment
83-
{
84-
[YamlIgnore]
85-
public string Name { get; set; } = string.Empty;
86-
87-
[YamlMember(Alias = "uri")]
88-
public string Uri { get; set; } = string.Empty;
89-
90-
[YamlMember(Alias = "path_prefix")]
91-
public string? PathPrefix { get; set; } = string.Empty;
92-
93-
[YamlMember(Alias = "allow_indexing")]
94-
public bool AllowIndexing { get; set; }
95-
96-
[YamlMember(Alias = "content_source")]
97-
public ContentSource ContentSource { get; set; }
98-
99-
[YamlMember(Alias = "google_tag_manager")]
100-
public GoogleTagManager GoogleTagManager { get; set; } = new();
101-
}
102-
103-
public record GoogleTagManager
104-
{
105-
[YamlMember(Alias = "enabled")]
106-
public bool Enabled { get; set; }
107-
108-
private string _id = string.Empty;
109-
110-
[YamlMember(Alias = "id")]
111-
public string Id
112-
{
113-
get => _id;
114-
set
115-
{
116-
if (Enabled && string.IsNullOrEmpty(value))
117-
throw new ArgumentException("Id is required when Enabled is true.");
118-
_id = value;
119-
}
120-
}
121-
122-
[YamlMember(Alias = "auth")]
123-
public string? Auth { get; set; }
124-
125-
[YamlMember(Alias = "preview")]
126-
public string? Preview { get; set; }
127-
128-
[YamlMember(Alias = "cookies_win")]
129-
public string? CookiesWin { get; set; }
130-
}

src/Elastic.Markdown/IO/State/ContentSource.cs renamed to Elastic.Documentation/Configuration/Assembler/ContentSource.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
using System.Text.Json.Serialization;
77
using NetEscapades.EnumGenerators;
88

9-
namespace Elastic.Markdown.IO.State;
9+
namespace Elastic.Documentation.Configuration.Assembler;
1010

1111
[EnumExtensions]
1212
public enum ContentSource
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
// Licensed to Elasticsearch B.V under one or more agreements.
2+
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
3+
// See the LICENSE file in the project root for more information
4+
5+
using YamlDotNet.Serialization;
6+
7+
namespace Elastic.Documentation.Configuration.Assembler;
8+
9+
public record GoogleTagManager
10+
{
11+
[YamlMember(Alias = "enabled")]
12+
public bool Enabled { get; set; }
13+
14+
private string _id = string.Empty;
15+
16+
[YamlMember(Alias = "id")]
17+
public string Id
18+
{
19+
get => _id;
20+
set
21+
{
22+
if (Enabled && string.IsNullOrEmpty(value))
23+
throw new ArgumentException("Id is required when Enabled is true.");
24+
_id = value;
25+
}
26+
}
27+
28+
[YamlMember(Alias = "auth")]
29+
public string? Auth { get; set; }
30+
31+
[YamlMember(Alias = "preview")]
32+
public string? Preview { get; set; }
33+
34+
[YamlMember(Alias = "cookies_win")]
35+
public string? CookiesWin { get; set; }
36+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// Licensed to Elasticsearch B.V under one or more agreements.
2+
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
3+
// See the LICENSE file in the project root for more information
4+
5+
using System.Diagnostics.CodeAnalysis;
6+
using System.Web;
7+
8+
namespace Elastic.Documentation.Configuration.Assembler;
9+
10+
public record GoogleTagManagerConfiguration
11+
{
12+
public bool Enabled { get; init; }
13+
[MemberNotNullWhen(returnValue: true, nameof(Enabled))]
14+
public string? Id { get; init; }
15+
public string? Auth { get; init; }
16+
public string? Preview { get; init; }
17+
public string? CookiesWin { get; init; }
18+
19+
public string QueryString()
20+
{
21+
var queryString = HttpUtility.ParseQueryString(string.Empty);
22+
if (Auth is not null)
23+
queryString.Add("gtm_auth", Auth);
24+
25+
if (Preview is not null)
26+
queryString.Add("gtm_preview", Preview);
27+
28+
if (CookiesWin is not null)
29+
queryString.Add("gtm_cookies_win", CookiesWin);
30+
31+
return queryString.Count > 0 ? $"&{queryString}" : string.Empty;
32+
}
33+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// Licensed to Elasticsearch B.V under one or more agreements.
2+
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
3+
// See the LICENSE file in the project root for more information
4+
5+
using YamlDotNet.Serialization;
6+
7+
namespace Elastic.Documentation.Configuration.Assembler;
8+
9+
public record PublishEnvironment
10+
{
11+
[YamlIgnore]
12+
public string Name { get; set; } = string.Empty;
13+
14+
[YamlMember(Alias = "uri")]
15+
public string Uri { get; set; } = string.Empty;
16+
17+
[YamlMember(Alias = "path_prefix")]
18+
public string? PathPrefix { get; set; } = string.Empty;
19+
20+
[YamlMember(Alias = "allow_indexing")]
21+
public bool AllowIndexing { get; set; }
22+
23+
[YamlMember(Alias = "content_source")]
24+
public ContentSource ContentSource { get; set; }
25+
26+
[YamlMember(Alias = "google_tag_manager")]
27+
public GoogleTagManager GoogleTagManager { get; set; } = new();
28+
}

src/docs-assembler/Configuration/Repository.cs renamed to Elastic.Documentation/Configuration/Assembler/Repository.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,9 @@
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 Elastic.Markdown.IO.State;
65
using YamlDotNet.Serialization;
76

8-
namespace Documentation.Assembler.Configuration;
7+
namespace Elastic.Documentation.Configuration.Assembler;
98

109
public record NarrativeRepository : Repository
1110
{

src/Elastic.Markdown/IO/Configuration/EnabledExtensions.cs renamed to Elastic.Documentation/Configuration/Builder/EnabledExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +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-
namespace Elastic.Markdown.IO.Configuration;
5+
namespace Elastic.Documentation.Configuration.Builder;
66

77
public class EnabledExtensions(IReadOnlyCollection<string> extensions)
88
{

src/Elastic.Markdown/IO/Configuration/FeatureFlags.cs renamed to Elastic.Documentation/Configuration/Builder/FeatureFlags.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +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-
namespace Elastic.Markdown.IO.Configuration;
5+
namespace Elastic.Documentation.Configuration.Builder;
66

77
public class FeatureFlags(Dictionary<string, bool> featureFlags)
88
{

src/Elastic.Markdown/IO/Configuration/ITocItem.cs renamed to Elastic.Documentation/Configuration/TableOfContents/ITocItem.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
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-
namespace Elastic.Markdown.IO.Configuration;
5+
using Elastic.Documentation.Navigation;
6+
7+
namespace Elastic.Documentation.Configuration.TableOfContents;
68

79
public interface ITocItem
810
{

0 commit comments

Comments
 (0)