Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidVollmers committed May 6, 2024
1 parent f189c6b commit dfe40f7
Show file tree
Hide file tree
Showing 5 changed files with 94 additions and 32 deletions.
10 changes: 5 additions & 5 deletions src/Doki.Abstractions/MemberDocumentation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,22 @@ public record MemberDocumentation : DocumentationObject
/// <summary>
/// Gets the name of the member.
/// </summary>
public string Name { get; internal init; } = null!;
public string Name { get; init; } = null!;

/// <summary>
/// Gets the namespace of the member.
/// </summary>
public string? Namespace { get; internal init; }
public string? Namespace { get; init; }

/// <summary>
/// Gets the assembly of the member.
/// </summary>
public string? Assembly { get; internal init; }
public string? Assembly { get; init; }

/// <summary>
/// Gets the summary of the member.
/// </summary>
public XmlDocumentation? Summary { get; internal set; }
public XmlDocumentation? Summary { get; set; }

public new DocumentationContentType ContentType { get; internal init; }
public new DocumentationContentType ContentType { get; init; }
}
66 changes: 57 additions & 9 deletions src/Doki.Abstractions/TypeDocumentation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,45 +10,93 @@ public sealed record TypeDocumentation : TypeDocumentationReference
/// </summary>
public string Definition { get; init; } = null!;

internal XmlDocumentation[] InternalExamples = [];

/// <summary>
/// Get the examples of the type.
/// </summary>
public XmlDocumentation[] Examples { get; init; } = [];
public XmlDocumentation[] Examples
{
get => InternalExamples;
init => InternalExamples = value;
}

internal XmlDocumentation[] InternalRemarks = [];

/// <summary>
/// Gets the remarks of the type.
/// </summary>
public XmlDocumentation[] Remarks { get; init; } = [];
public XmlDocumentation[] Remarks
{
get => InternalRemarks;
init => InternalRemarks = value;
}

internal TypeDocumentationReference[] InternalInterfaces = [];

/// <summary>
/// Gets the interfaces implemented by the type.
/// </summary>
public TypeDocumentationReference[] Interfaces { get; init; } = [];
public TypeDocumentationReference[] Interfaces
{
get => InternalInterfaces;
init => InternalInterfaces = value;
}

internal TypeDocumentationReference[] InternalDerivedTypes = [];

/// <summary>
/// Gets the derived types of the type.
/// </summary>
public TypeDocumentationReference[] DerivedTypes { get; init; } = [];
public TypeDocumentationReference[] DerivedTypes
{
get => InternalDerivedTypes;
init => InternalDerivedTypes = value;
}

internal MemberDocumentation[] InternalConstructors = [];

/// <summary>
/// Gets the constructors of the type.
/// </summary>
public MemberDocumentation[] Constructors { get; init; } = [];
public MemberDocumentation[] Constructors
{
get => InternalConstructors;
init => InternalConstructors = value;
}

internal MemberDocumentation[] InternalFields = [];

/// <summary>
/// Gets the fields of the type.
/// </summary>
public MemberDocumentation[] Fields { get; init; } = [];
public MemberDocumentation[] Fields
{
get => InternalFields;
init => InternalFields = value;
}

internal MemberDocumentation[] InternalProperties = [];

/// <summary>
/// Gets the properties of the type.
/// </summary>
public MemberDocumentation[] Properties { get; init; } = [];
public MemberDocumentation[] Properties
{
get => InternalProperties;
init => InternalProperties = value;
}

internal MemberDocumentation[] InternalMethods = [];

/// <summary>
/// Gets the methods of the type.
/// </summary>
public MemberDocumentation[] Methods { get; init; } = [];

public MemberDocumentation[] Methods
{
get => InternalMethods;
init => InternalMethods = value;
}

public new DocumentationContentType ContentType { get; init; }
}
24 changes: 18 additions & 6 deletions src/Doki.Abstractions/TypeDocumentationReference.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,32 +8,44 @@ public record TypeDocumentationReference : MemberDocumentation
/// <summary>
/// Gets a value indicating whether the type is generic.
/// </summary>
public bool IsGeneric { get; internal init; }
public bool IsGeneric { get; init; }

/// <summary>
/// Gets the full name of the type.
/// </summary>
public string FullName { get; internal init; } = null!;
public string FullName { get; init; } = null!;

/// <summary>
/// Gets a value indicating whether the type is documented.
/// </summary>
public bool IsDocumented { get; internal init; }
public bool IsDocumented { get; init; }

/// <summary>
/// Gets a value indicating whether the type is from Microsoft.
/// </summary>
public bool IsMicrosoft { get; internal init; }
public bool IsMicrosoft { get; init; }

internal TypeDocumentationReference? InternalBaseType;

/// <summary>
/// Gets the base type of the type.
/// </summary>
public TypeDocumentationReference? BaseType { get; internal set; }
public TypeDocumentationReference? BaseType
{
get => InternalBaseType;
init => InternalBaseType = value;
}

internal GenericTypeArgumentDocumentation[] InternalGenericArguments = [];

/// <summary>
/// Gets the generic arguments of the type.
/// </summary>
public GenericTypeArgumentDocumentation[] GenericArguments { get; internal set; } = [];
public GenericTypeArgumentDocumentation[] GenericArguments
{
get => InternalGenericArguments;
init => InternalGenericArguments = value;
}

/// <summary>
/// Initializes a new instance of the <see cref="TypeDocumentationReference"/> class.
Expand Down
2 changes: 1 addition & 1 deletion src/Doki/DocumentationGenerator.Content.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public partial class DocumentationGenerator
private const BindingFlags AllMembersBindingFlags =
BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static;

private IEnumerable<DocumentationObject> BuildXmlDocumentation(string xpath, XPathNavigator? typeXml,
private IEnumerable<XmlDocumentation> BuildXmlDocumentation(string xpath, XPathNavigator? typeXml,
DocumentationObject parent)
{
var xml = typeXml?.Select(xpath);
Expand Down
24 changes: 13 additions & 11 deletions src/Doki/DocumentationGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -350,28 +350,30 @@ private async Task<TypeDocumentation> GenerateTypeDocumentationAsync(GeneratorCo

if (summary != null) typeDocumentation.Summary = BuildXmlDocumentation(summary, typeDocumentation);

typeDocumentation.GenericArguments =
typeDocumentation.InternalGenericArguments =
BuildGenericTypeArgumentDocumentation(context.Current, typeDocumentation, typeXml, context.Logger)
.ToArray();

typeDocumentation.Interfaces = BuildInterfaceDocumentation(context.Current, typeDocumentation).ToArray();
typeDocumentation.InternalInterfaces =
BuildInterfaceDocumentation(context.Current, typeDocumentation).ToArray();

typeDocumentation.DerivedTypes = BuildDerivedTypeDocumentation(context.Current, typeDocumentation).ToArray();
typeDocumentation.InternalDerivedTypes =
BuildDerivedTypeDocumentation(context.Current, typeDocumentation).ToArray();

typeDocumentation.Examples = BuildXmlDocumentation("example", typeXml, typeDocumentation).ToArray();
typeDocumentation.InternalExamples = BuildXmlDocumentation("example", typeXml, typeDocumentation).ToArray();

typeDocumentation.Remarks = BuildXmlDocumentation("remarks", typeXml, typeDocumentation).ToArray();
typeDocumentation.InternalRemarks = BuildXmlDocumentation("remarks", typeXml, typeDocumentation).ToArray();

typeDocumentation.Constructors =
typeDocumentation.InternalConstructors =
BuildConstructorDocumentation(context.Current, typeDocumentation, assemblyXml, context.Logger).ToArray();

typeDocumentation.Fields =
typeDocumentation.InternalFields =
BuildFieldDocumentation(context.Current, typeDocumentation, assemblyXml, context.Logger).ToArray();

typeDocumentation.Properties =
typeDocumentation.InternalProperties =
BuildPropertyDocumentation(context.Current, typeDocumentation, assemblyXml, context.Logger).ToArray();

typeDocumentation.Methods =
typeDocumentation.InternalMethods =
BuildMethodDocumentation(context.Current, typeDocumentation, assemblyXml, context.Logger).ToArray();

var baseType = context.Current.BaseType;
Expand All @@ -393,10 +395,10 @@ private async Task<TypeDocumentation> GenerateTypeDocumentationAsync(GeneratorCo
IsGeneric = baseType.IsGenericType
};

typeReference.GenericArguments =
typeReference.InternalGenericArguments =
BuildGenericTypeArgumentDocumentation(baseType, typeReference, null, context.Logger).ToArray();

baseParent.BaseType = typeReference;
baseParent.InternalBaseType = typeReference;

baseType = baseType.BaseType;
baseParent = typeReference;
Expand Down

0 comments on commit dfe40f7

Please sign in to comment.