Skip to content

Commit

Permalink
generate class lib concept
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidVollmers committed May 5, 2024
1 parent 4f10981 commit 70f08ff
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 9 deletions.
3 changes: 2 additions & 1 deletion doki.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
"$schema": "src/Doki.CommandLine/doki.config.schema.json",
"input": [
"src/**/*.csproj",
"!src/Doki.CommandLine/Doki.CommandLine.csproj"
"!src/Doki.CommandLine/Doki.CommandLine.csproj",
"!src/Doki.Documentation.Content/Doki.Documentation.Content.csproj"
],
"output": [
{
Expand Down
14 changes: 10 additions & 4 deletions src/Doki.CommandLine/Commands/GenerateCommand.Outputs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,20 @@ internal partial class GenerateCommand

var fileName = fileInfo.Name[..^fileInfo.Extension.Length];

// this is needed so we can document Doki using Doki
var buildForDoki = fileName.StartsWith("Doki.Output.");
#if DEBUG
const bool buildForDoki = true;
const string buildConfiguration = "Debug";
#else
const bool buildForDoki = false;
const string buildConfiguration = "Release";
#endif

var buildResult =
await BuildProjectAsync(fileInfo, "Release", buildForDoki, cancellationToken);
await BuildProjectAsync(fileInfo, buildConfiguration, buildForDoki, cancellationToken);
if (buildResult != 0) return null;

var assemblyPath = Path.Combine(fileInfo.DirectoryName!, "bin", "Release", "net8.0", $"{fileName}.dll");
var assemblyPath =
Path.Combine(fileInfo.DirectoryName!, "bin", buildConfiguration, "net8.0", $"{fileName}.dll");

return LoadOutputRegistrationFromAssembly(assemblyPath);
}
Expand Down
11 changes: 11 additions & 0 deletions src/Doki.Output.ClassLibrary/ClassLibraryOutput.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@ public Task BeginAsync(CancellationToken cancellationToken = default)

var projectFilePath = Path.Combine(options.OutputDirectory.FullName, $"{options.Namespace}.csproj");

#if DEBUG
const string dokiReference = "<ProjectReference Include=\"..\\Doki.Abstractions\\Doki.Abstractions.csproj\" />";
#else
var dokiVersion = typeof(DocumentationObject).Assembly.GetName().Version!.ToString();
var dokiReference = $"<PackageReference Include=\"Doki.Abstractions\" Version=\"{dokiVersion}\" />";
#endif

var projectFileContent = $"""
<Project Sdk="Microsoft.NET.Sdk">
Expand All @@ -19,6 +26,10 @@ public Task BeginAsync(CancellationToken cancellationToken = default)
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
{dokiReference}
</ItemGroup>
</Project>
""";
Expand Down
3 changes: 1 addition & 2 deletions src/Doki.Output.ClassLibrary/Doki.Output.ClassLibrary.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\Doki.Output.Abstractions\Doki.Output.Abstractions.csproj"/>
<ProjectReference Include="..\Doki.Output.Extensions\Doki.Output.Extensions.csproj" />
<ProjectReference Include="..\Doki.Output.Extensions\Doki.Output.Extensions.csproj"/>
</ItemGroup>

<ItemGroup>
Expand Down
3 changes: 1 addition & 2 deletions src/Doki.Output.Markdown/Doki.Output.Markdown.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\Doki.Output.Abstractions\Doki.Output.Abstractions.csproj"/>
<ProjectReference Include="..\Doki.Output.Extensions\Doki.Output.Extensions.csproj" />
<ProjectReference Include="..\Doki.Output.Extensions\Doki.Output.Extensions.csproj"/>
</ItemGroup>

<ItemGroup>
Expand Down

0 comments on commit 70f08ff

Please sign in to comment.