Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 22 additions & 3 deletions examples/Demo/Shared/Components/ApiDocumentation.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ private IEnumerable<MemberDescription> GetMembers(MemberTypes type)
Type = propertyInfo.ToTypeNameString(),
EnumValues = GetEnumValues(propertyInfo),
Default = defaultVaue,
Description = CodeComments.GetSummary(Component.Name + "." + propertyInfo.Name) ?? CodeComments.GetSummary(Component.BaseType?.Name + "." + propertyInfo.Name),
Description = GetMembersDescription(Component, propertyInfo),
IsParameter = isParameter,
Icon = icon
});
Expand All @@ -156,7 +156,7 @@ private IEnumerable<MemberDescription> GetMembers(MemberTypes type)
MemberType = MemberTypes.Event,
Name = propertyInfo.Name,
Type = propertyInfo.ToTypeNameString(),
Description = CodeComments.GetSummary(Component.Name + "." + propertyInfo.Name) ?? CodeComments.GetSummary(Component.BaseType?.Name + "." + propertyInfo.Name)
Description = GetMembersDescription(Component, propertyInfo)
});
}
}
Expand All @@ -176,7 +176,7 @@ private IEnumerable<MemberDescription> GetMembers(MemberTypes type)
Name = methodInfo.Name + genericArguments,
Parameters = methodInfo.GetParameters().Select(i => $"{i.ToTypeNameString()} {i.Name}").ToArray(),
Type = methodInfo.ToTypeNameString(),
Description = CodeComments.GetSummary(Component.Name + "." + methodInfo.Name) ?? CodeComments.GetSummary(Component.BaseType?.Name + "." + methodInfo.Name)
Description = GetMembersDescription(Component, methodInfo)
});
}
}
Expand All @@ -194,6 +194,25 @@ private IEnumerable<MemberDescription> GetMembers(MemberTypes type)
return _allMembers.Where(i => i.MemberType == type);
}

/// <summary>
/// Gets member description. If none provided, base member description is returned.
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="component"></param>
/// <param name="memberInfo"></param>
/// <returns>member description</returns>
private static string GetMembersDescription<T>(Type component, T memberInfo) where T : MemberInfo
{
var description = CodeComments.GetSummary(component.Name + "." + memberInfo.Name);

if (description == null && component.BaseType != null)
{
description = GetMembersDescription(component.BaseType, memberInfo);
}

return description ?? string.Empty;
}

private static string[] GetEnumValues(PropertyInfo? propertyInfo)
{
if (propertyInfo != null)
Expand Down