Skip to content

Commit

Permalink
cref building for methods & fields
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidVollmers committed May 23, 2024
1 parent b721c44 commit a4f25f1
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/Doki.Abstractions/DocumentationContentType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,4 +94,9 @@ public enum DocumentationContentType
/// A property in the documentation.
/// </summary>
Property,

/// <summary>
/// A method in the documentation.
/// </summary>
Method,
}
48 changes: 47 additions & 1 deletion src/Doki/DocumentationGenerator.Content.cs
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ private IEnumerable<MemberDocumentation> BuildMethodDocumentation(Type type, Doc
{
Id = methodId,
Name = method.GetSanitizedName(),
ContentType = DocumentationContentType.Property,
ContentType = DocumentationContentType.Method,
Namespace = method.DeclaringType.Namespace,
Assembly = methodAssembly.Name,
Parent = parent,
Expand Down Expand Up @@ -390,6 +390,52 @@ private DocumentationObject BuildCRefDocumentation(string cref, DocumentationObj
IsDocumented = PropertyFilter.Expression?.Invoke(property) ?? PropertyFilter.Default(property)
};
}
case "F":
{
var field = type.GetField(memberName, AllMembersBindingFlags);
if (field == null)
return new TextContent
{
Id = "text",
Parent = parent,
Text = memberName
};

return new MemberDocumentation
{
Id = field.GetXmlDocumentationId(),
Name = field.Name,
ContentType = DocumentationContentType.Field,
Namespace = type.Namespace,
Assembly = type.Assembly.GetName().Name,
Parent = typeDocumentationReference,
IsDocumented = FieldFilter.Expression?.Invoke(field) ?? FieldFilter.Default(field)
};
}
case "M":
{
var method = type.GetMethod(memberName, AllMembersBindingFlags);
if (method == null)
return new TextContent
{
Id = "text",
Parent = parent,
Text = memberName
};

return new MemberDocumentation
{
Id = method.GetXmlDocumentationId(),
Name = method.GetSanitizedName(),
ContentType = method.IsConstructor
? DocumentationContentType.Constructor
: DocumentationContentType.Method,
Namespace = type.Namespace,
Assembly = type.Assembly.GetName().Name,
Parent = typeDocumentationReference,
IsDocumented = MethodFilter.Expression?.Invoke(method) ?? MethodFilter.Default(method)
};
}
default:
throw new ArgumentOutOfRangeException(nameof(cref), cref, "Unsupported cref member type.");
}
Expand Down

0 comments on commit a4f25f1

Please sign in to comment.