Skip to content

Commit

Permalink
class library output generation
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidVollmers committed May 7, 2024
1 parent d2c97f0 commit 03ed7fd
Show file tree
Hide file tree
Showing 3 changed files with 125 additions and 36 deletions.
1 change: 0 additions & 1 deletion docs/api/Doki.Abstractions/Doki/Doki.XmlDocumentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ Implements: [System.IEquatable<Doki.XmlDocumentation>](https://learn.micro
|---|---|
|EqualityContract||
|Name||
|Description||
|Contents||


Expand Down
2 changes: 0 additions & 2 deletions src/Doki.Abstractions/XmlDocumentation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ public sealed record XmlDocumentation : DocumentationObject
{
public string Name { get; init; } = null!;

public string? Description { get; init; }

internal DocumentationObject[] InternalContents = [];

public DocumentationObject[] Contents
Expand Down
158 changes: 125 additions & 33 deletions src/Doki.Output.ClassLibrary/ClassLibraryOutput.cs
Original file line number Diff line number Diff line change
Expand Up @@ -127,57 +127,149 @@ private static void BuildTypeDocumentation(TypeDocumentation typeDocumentation,
content.AppendLine($$"""
{{i}}new TypeDocumentation
{{i}}{
{{i}} Name = "{{typeDocumentation.Name}}",
{{i}} ContentType = DocumentationContentType.{{Enum.GetName(typeDocumentation.ContentType)}},
{{i}} Definition = "{{typeDocumentation.Definition}}",
{{i}} IsGeneric = {{typeDocumentation.IsGeneric.ToString().ToLowerInvariant()}},
{{i}} FullName = "{{typeDocumentation.FullName}}",
{{i}} IsDocumented = {{typeDocumentation.IsDocumented.ToString().ToLowerInvariant()}},
{{i}} IsMicrosoft = {{typeDocumentation.IsMicrosoft.ToString().ToLowerInvariant()}},
{{i}} Namespace = "{{typeDocumentation.Namespace}}",
{{i}} Assembly = "{{typeDocumentation.Assembly}}",
{{i}} Summary =
{{i}} Examples =
{{i}} [
""");

BuildXmlDocumentation(typeDocumentation.Summary, content, indent + 1);
//TODO Examples

content.AppendLine($$"""
{{i}} BaseType =
""");
content.AppendLine($"""
{i} ],
{i} Remarks =
{i} [
""");

//TODO Remarks

content.AppendLine($"""
{i} ],
{i} Interfaces =
{i} [
""");

//TODO Interfaces

content.AppendLine($"""
{i} ],
{i} DerivedTypes =
{i} [
""");

//TODO DerivedTypes

BuildTypeDocumentationReference(typeDocumentation.BaseType, content, indent + 1);
content.AppendLine($"""
{i} ],
{i} Constructors =
{i} [
""");

//TODO Constructors

content.AppendLine($"""
{i} ],
{i} Fields =
{i} [
""");

//TODO Fields

content.AppendLine($"""
{i} ],
{i} Properties =
{i} [
""");

//TODO Properties

content.AppendLine($"""
{i} ],
{i} Methods =
{i} [
""");

//TODO Methods

content.AppendLine($"{i} ],");

BuildTypeDocumentationReferenceProperties(typeDocumentation, content, indent);

content.AppendLine($$"""
{{i}} GenericArguments =
{{i}} [
{{i}}},
""");
}

private static void BuildTypeDocumentationReferenceProperties(TypeDocumentationReference typeDocumentationReference,
StringBuilder content, int indent)
{
var i = new string(' ', indent * 4);

content.Append($"""
{i} IsGeneric = {typeDocumentationReference.IsGeneric.ToString().ToLowerInvariant()},
{i} FullName = "{typeDocumentationReference.FullName}",
{i} IsDocumented = {typeDocumentationReference.IsDocumented.ToString().ToLowerInvariant()},
{i} IsMicrosoft = {typeDocumentationReference.IsMicrosoft.ToString().ToLowerInvariant()},
{i} BaseType =
""");

if (typeDocumentationReference.BaseType == null) content.AppendLine(" null,");
//TODO BuildTypeDocumentationReference(typeDocumentation.BaseType, content, indent + 1);
else content.AppendLine(" null,");

content.AppendLine($"""
{i} GenericArguments =
{i} [
""");

foreach (var genericTypeArgumentDocumentation in typeDocumentation.GenericArguments)
foreach (var genericTypeArgumentDocumentation in typeDocumentationReference.GenericArguments)
{
BuildGenericTypeArgumentDocumentation(genericTypeArgumentDocumentation, content, indent + 1);
//TODO BuildGenericTypeArgumentDocumentation(genericTypeArgumentDocumentation, content, indent + 1);
}

content.AppendLine($"{i} ],");

BuildMemberDocumentationProperties(typeDocumentationReference, content, indent);
}

private static void BuildMemberDocumentationProperties(MemberDocumentation memberDocumentation,
StringBuilder content, int indent)
{
var i = new string(' ', indent * 4);

content.Append($"""
{i} Name = "{memberDocumentation.Name}",
{i} Namespace = "{memberDocumentation.Namespace}",
{i} Assembly = "{memberDocumentation.Assembly}",
{i} Summary =
""");

if (memberDocumentation.Summary == null) content.AppendLine(" null,");
else BuildXmlDocumentation(memberDocumentation.Summary, content, indent + 1, true);
}

private static void BuildXmlDocumentation(XmlDocumentation xmlDocumentation, StringBuilder content, int indent,
bool startInline = false)
{
var i = new string(' ', indent * 4);

content.Append(startInline ? " " : i);

content.AppendLine($$"""
{{i}} ],
new XmlDocumentation
{{i}}{
{{i}} Name = "{{xmlDocumentation.Name}}",
{{i}} Contents =
{{i}} [
""");

//TODO Examples

//TODO Remarks

//TODO Interfaces

//TODO DerivedTypes

//TODO Constructors

//TODO Fields

//TODO Properties

//TODO Methods
foreach (var documentationObject in xmlDocumentation.Contents)
{
//TODO BuildDocumentationObject(documentationObject, content, indent + 1);
}

content.AppendLine($$"""
{{i}} ]
{{i}}},
""");
}
Expand Down

0 comments on commit 03ed7fd

Please sign in to comment.