Skip to content

Commit 33129e7

Browse files
authored
Embedd assembler.yml in binary temporarily before its homed in docs-content (#716)
1 parent 222c41a commit 33129e7

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

src/docs-assembler/AssembleContext.cs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
// See the LICENSE file in the project root for more information
44

55
using System.IO.Abstractions;
6+
using System.Reflection;
67
using Documentation.Assembler.Configuration;
78
using Elastic.Markdown.Diagnostics;
89
using Elastic.Markdown.IO;
@@ -29,8 +30,32 @@ public AssembleContext(DiagnosticsCollector collector, IFileSystem readFileSyste
2930
WriteFileSystem = writeFileSystem;
3031

3132
var configPath = Path.Combine(Paths.Root.FullName, "src/docs-assembler/assembler.yml");
33+
// temporarily fallback to embedded assembler.yml
34+
// This will live in docs-content soon
35+
if (!ReadFileSystem.File.Exists(configPath))
36+
ExtractAssemblerConfiguration(configPath);
37+
3238
ConfigurationPath = ReadFileSystem.FileInfo.New(configPath);
3339
Configuration = AssemblyConfiguration.Deserialize(ReadFileSystem.File.ReadAllText(ConfigurationPath.FullName));
3440
OutputDirectory = ReadFileSystem.DirectoryInfo.New(output ?? ".artifacts/assembly");
3541
}
42+
43+
private void ExtractAssemblerConfiguration(string configPath)
44+
{
45+
var embeddedStaticFiles = Assembly.GetExecutingAssembly()
46+
.GetManifestResourceNames()
47+
.ToList();
48+
var configFile = embeddedStaticFiles.First(f => f.EndsWith("assembler.yml"));
49+
using var resourceStream = Assembly.GetExecutingAssembly().GetManifestResourceStream(configFile);
50+
if (resourceStream == null)
51+
return;
52+
53+
var outputFile = WriteFileSystem.FileInfo.New(configPath);
54+
if (outputFile.Directory is { Exists: false })
55+
outputFile.Directory.Create();
56+
using var stream = outputFile.OpenWrite();
57+
resourceStream.CopyTo(stream);
58+
59+
60+
}
3661
}

src/docs-assembler/docs-assembler.csproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,8 @@
2828
<ProjectReference Include="..\Elastic.Documentation.Tooling\Elastic.Documentation.Tooling.csproj" />
2929
<ProjectReference Include="..\Elastic.Markdown\Elastic.Markdown.csproj" />
3030
</ItemGroup>
31+
32+
<ItemGroup>
33+
<EmbeddedResource Include="assembler.yml" />
34+
</ItemGroup>
3135
</Project>

0 commit comments

Comments
 (0)