Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[doc] HxCalendar doc link to HxInputDate leads to non-generic type instead of component #614 #636

Merged
merged 1 commit into from
Oct 26, 2023
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
18 changes: 17 additions & 1 deletion Havit.Blazor.Documentation/Model/MemberModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ public abstract class MemberModel
private Type enclosingType;

private bool generic;
private string genericTypeSuffix;

protected string TryFormatComment(string comment, Type enclosingType = null)
{
Expand Down Expand Up @@ -66,6 +67,9 @@ private string PrepareLinkForFullLinkGeneration(string link)
generic = IsGeneric(link); // this information is used later to generate a Microsoft documentation link

Regex regex = new("`\\d");
var match = regex.Match(link);
genericTypeSuffix = match.Value;

return regex.Replace(link, "");
}

Expand Down Expand Up @@ -143,7 +147,8 @@ private string GenerateHavitDocumentationLink(string[] splitLink)
}
}

isComponent = ApiTypeHelper.GetType(splitLink[^1])?.IsSubclassOf(typeof(ComponentBase)) ?? false;
string className = GetFullGenericTypeName(splitLink[^1]);
isComponent = ApiTypeHelper.GetType(className)?.IsSubclassOf(typeof(ComponentBase)) ?? false;
}
else if (isProperty)
{
Expand Down Expand Up @@ -227,6 +232,17 @@ private bool IsGeneric(string link)
return link.Contains('`');
}

/// <returns>The type name including the <c>`1</c> or <c>`2</c> suffix if the type is generic.</returns>
private string GetFullGenericTypeName(string typeName)
{
if (!generic)
{
return typeName;
}

return $"{typeName}{genericTypeSuffix}";
}

private string ConcatenateStringArray(string[] stringArray)
{
StringBuilder sb = new StringBuilder();
Expand Down
Loading