diff --git a/src/Doki.Abstractions/DocumentationContentType.cs b/src/Doki.Abstractions/DocumentationContentType.cs index 66e8071..d2edd4b 100644 --- a/src/Doki.Abstractions/DocumentationContentType.cs +++ b/src/Doki.Abstractions/DocumentationContentType.cs @@ -5,12 +5,6 @@ /// public enum DocumentationContentType { - /// - /// An object in the documentation. This is the default content type. - /// - // ReSharper disable once UnusedMember.Global - Object, - /// /// The root of the documentation, containing all assemblies/packages. /// diff --git a/src/Doki.Abstractions/GenericTypeArgumentDocumentation.cs b/src/Doki.Abstractions/GenericTypeArgumentDocumentation.cs index 6d2740d..72ce272 100644 --- a/src/Doki.Abstractions/GenericTypeArgumentDocumentation.cs +++ b/src/Doki.Abstractions/GenericTypeArgumentDocumentation.cs @@ -8,7 +8,7 @@ public sealed record GenericTypeArgumentDocumentation : TypeDocumentationReferen /// /// Gets the description of the generic type argument. /// - public DocumentationObject? Description { get; internal set; } + public XmlDocumentation? Description { get; internal set; } /// /// Gets a value indicating whether the generic type argument is a generic parameter. @@ -17,6 +17,6 @@ public sealed record GenericTypeArgumentDocumentation : TypeDocumentationReferen public GenericTypeArgumentDocumentation() { - Content = DocumentationContentType.GenericTypeArgument; + ContentType = DocumentationContentType.GenericTypeArgument; } } \ No newline at end of file diff --git a/src/Doki.Abstractions/MemberDocumentation.cs b/src/Doki.Abstractions/MemberDocumentation.cs index b19dfc5..c883fd2 100644 --- a/src/Doki.Abstractions/MemberDocumentation.cs +++ b/src/Doki.Abstractions/MemberDocumentation.cs @@ -19,11 +19,11 @@ public record MemberDocumentation : DocumentationObject /// Gets the assembly of the member. /// public string? Assembly { get; internal init; } - + /// /// Gets the summary of the member. /// - public DocumentationObject? Summary { get; internal set; } - - public new DocumentationContentType Content { get; internal init; } + public XmlDocumentation? Summary { get; internal set; } + + public new DocumentationContentType ContentType { get; internal init; } } \ No newline at end of file diff --git a/src/Doki.Abstractions/TypeDocumentation.cs b/src/Doki.Abstractions/TypeDocumentation.cs index 6ef7f4d..40661e5 100644 --- a/src/Doki.Abstractions/TypeDocumentation.cs +++ b/src/Doki.Abstractions/TypeDocumentation.cs @@ -8,47 +8,47 @@ public sealed record TypeDocumentation : TypeDocumentationReference /// /// Gets the definition of the type. /// - public string Definition { get; internal init; } = null!; + public string Definition { get; init; } = null!; /// /// Get the examples of the type. /// - public DocumentationObject[] Examples { get; internal set; } = []; + public XmlDocumentation[] Examples { get; init; } = []; /// /// Gets the remarks of the type. /// - public DocumentationObject[] Remarks { get; internal set; } = []; + public XmlDocumentation[] Remarks { get; init; } = []; /// /// Gets the interfaces implemented by the type. /// - public TypeDocumentationReference[] Interfaces { get; internal set; } = []; + public TypeDocumentationReference[] Interfaces { get; init; } = []; /// /// Gets the derived types of the type. /// - public TypeDocumentationReference[] DerivedTypes { get; internal set; } = []; + public TypeDocumentationReference[] DerivedTypes { get; init; } = []; /// /// Gets the constructors of the type. /// - public MemberDocumentation[] Constructors { get; internal set; } = []; + public MemberDocumentation[] Constructors { get; init; } = []; /// /// Gets the fields of the type. /// - public MemberDocumentation[] Fields { get; internal set; } = []; + public MemberDocumentation[] Fields { get; init; } = []; /// /// Gets the properties of the type. /// - public MemberDocumentation[] Properties { get; internal set; } = []; + public MemberDocumentation[] Properties { get; init; } = []; /// /// Gets the methods of the type. /// - public MemberDocumentation[] Methods { get; internal set; } = []; + public MemberDocumentation[] Methods { get; init; } = []; - public new DocumentationContentType Content { get; internal init; } + public new DocumentationContentType ContentType { get; init; } } \ No newline at end of file diff --git a/src/Doki.Abstractions/TypeDocumentationReference.cs b/src/Doki.Abstractions/TypeDocumentationReference.cs index afb23ec..8ccd9ea 100644 --- a/src/Doki.Abstractions/TypeDocumentationReference.cs +++ b/src/Doki.Abstractions/TypeDocumentationReference.cs @@ -40,6 +40,6 @@ public record TypeDocumentationReference : MemberDocumentation /// public TypeDocumentationReference() { - Content = DocumentationContentType.TypeReference; + ContentType = DocumentationContentType.TypeReference; } } \ No newline at end of file diff --git a/src/Doki.Output.ClassLibrary/ClassLibraryOutput.cs b/src/Doki.Output.ClassLibrary/ClassLibraryOutput.cs index 9c548a2..714d557 100644 --- a/src/Doki.Output.ClassLibrary/ClassLibraryOutput.cs +++ b/src/Doki.Output.ClassLibrary/ClassLibraryOutput.cs @@ -111,7 +111,7 @@ private static void BuildNamespaceDocumentation(NamespaceDocumentation namespace foreach (var typeDocumentation in namespaceDocumentation.Types) { - //TODO Add type documentation + BuildTypeDocumentation(typeDocumentation, content, indent + 1); } content.AppendLine($$""" @@ -119,4 +119,32 @@ private static void BuildNamespaceDocumentation(NamespaceDocumentation namespace {{i}}}, """); } + + private static void BuildTypeDocumentation(TypeDocumentation typeDocumentation, StringBuilder content, int indent) + { + var i = new string(' ', indent * 4); + + 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}}", + """); + + // foreach (var memberDocumentation in typeDocumentation.Members) + // { + // BuildMemberDocumentation(memberDocumentation, content, indent + 1); + // } + + content.AppendLine($$""" + {{i}}}, + """); + } } \ No newline at end of file diff --git a/src/Doki.Output.Markdown/MarkdownOutput.cs b/src/Doki.Output.Markdown/MarkdownOutput.cs index 516626c..17b32c9 100644 --- a/src/Doki.Output.Markdown/MarkdownOutput.cs +++ b/src/Doki.Output.Markdown/MarkdownOutput.cs @@ -87,7 +87,7 @@ public async Task WriteAsync(TypeDocumentation typeDocumentation, CancellationTo var markdown = new MarkdownBuilder(currentPath); markdown.Add(markdown.BuildBreadcrumbs(typeDocumentation)) - .Add(new Heading(typeDocumentation.Name, 1).Append($" {Enum.GetName(typeDocumentation.Content)}")) + .Add(new Heading(typeDocumentation.Name, 1).Append($" {Enum.GetName(typeDocumentation.ContentType)}")) .Add(new Heading(nameof(TypeDocumentation.Definition), 2)); var namespaceDocumentation = diff --git a/src/Doki/DocumentationGenerator.Content.cs b/src/Doki/DocumentationGenerator.Content.cs index 46265d6..614d595 100644 --- a/src/Doki/DocumentationGenerator.Content.cs +++ b/src/Doki/DocumentationGenerator.Content.cs @@ -124,7 +124,7 @@ private IEnumerable BuildFieldDocumentation(Type type, Docu { Id = fieldId, Name = field.Name, - Content = DocumentationContentType.Field, + ContentType = DocumentationContentType.Field, Namespace = field.DeclaringType.Namespace, Assembly = fieldAssembly.Name, Parent = parent, @@ -165,7 +165,7 @@ private IEnumerable BuildConstructorDocumentation(Type type { Id = constructorId, Name = constructor.GetSanitizedName(), - Content = DocumentationContentType.Constructor, + ContentType = DocumentationContentType.Constructor, Namespace = constructor.DeclaringType.Namespace, Assembly = constructorAssembly.Name, Parent = parent, @@ -206,7 +206,7 @@ private IEnumerable BuildPropertyDocumentation(Type type, D { Id = propertyId, Name = property.Name, - Content = DocumentationContentType.Property, + ContentType = DocumentationContentType.Property, Namespace = property.DeclaringType.Namespace, Assembly = propertyAssembly.Name, Parent = parent, @@ -249,7 +249,7 @@ private IEnumerable BuildMethodDocumentation(Type type, Doc { Id = methodId, Name = method.GetSanitizedName(), - Content = DocumentationContentType.Property, + ContentType = DocumentationContentType.Property, Namespace = method.DeclaringType.Namespace, Assembly = methodAssembly.Name, Parent = parent, @@ -365,7 +365,7 @@ private TypeDocumentationReference BuildTypeDocumentationReference(Type type, Do Id = typeId, Name = type.GetSanitizedName(), FullName = type.GetSanitizedName(true), - Content = DocumentationContentType.TypeReference, + ContentType = DocumentationContentType.TypeReference, Namespace = type.Namespace, Assembly = assembly.Name, IsGeneric = type.IsGenericType, diff --git a/src/Doki/DocumentationGenerator.cs b/src/Doki/DocumentationGenerator.cs index 31fe70f..622f81c 100644 --- a/src/Doki/DocumentationGenerator.cs +++ b/src/Doki/DocumentationGenerator.cs @@ -329,7 +329,7 @@ private async Task GenerateTypeDocumentationAsync(GeneratorCo var typeDocumentation = new TypeDocumentation { Id = typeId, - Content = context.Current.IsClass + ContentType = context.Current.IsClass ? DocumentationContentType.Class : context.Current.IsEnum ? DocumentationContentType.Enum