Skip to content

Commit

Permalink
fixed see element with langword attribute usage
Browse files Browse the repository at this point in the history
  • Loading branch information
Doraku committed May 10, 2020
1 parent 10e5cf1 commit 02020b1
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
<Version>0.6.3</Version>
<PackageReleaseNotes>
added DefaultDocumentationNestedTypeVisibility parameter to set where nested types are displayed (possible value: Namespace, DeclaringType,Everywhere)

fixed see element with langword attribute usage
</PackageReleaseNotes>
</PropertyGroup>
</Project>
19 changes: 18 additions & 1 deletion source/DefaultDocumentation/DocumentationWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -171,14 +171,31 @@ public void WriteDocItems<T>(string title)

public void Write(string title, XElement element, DocItem item)
{
string GetSeeLink(XElement element)
{
string see = element.GetReferenceName();
if (see is null)
{
see = element.GetLangWord();
if (see is null)
{
return string.Empty;
}

return $"https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/{see}";
}

return GetLink(see);
}

string WriteNodes(IEnumerable<XNode> nodes)
{
return string.Concat(nodes.Select(node => node switch
{
XText text => string.Join(" \n", text.Value.Split('\n')),
XElement element => element.Name.ToString() switch
{
"see" => GetLink(element.GetReferenceName()),
"see" => GetSeeLink(element),
"seealso" => GetLink(element.GetReferenceName()),
"typeparamref" => item.TryGetTypeParameterDocItem(element.GetName(), out TypeParameterDocItem typeParameter) ? GetInnerLink(typeParameter) : element.GetName(),
"paramref" => item.TryGetParameterDocItem(element.GetName(), out ParameterDocItem parameter) ? GetInnerLink(parameter) : element.GetName(),
Expand Down
4 changes: 3 additions & 1 deletion source/DefaultDocumentation/Helper/XElementExtension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ internal static class XElementExtension

public static string GetName(this XElement element) => element.Attribute("name")?.Value;

public static string GetReferenceName(this XElement element) => element.Attribute("cref").Value;
public static string GetReferenceName(this XElement element) => element.Attribute("cref")?.Value;

public static string GetLangWord(this XElement element) => element.Attribute("langword")?.Value;
}
}

0 comments on commit 02020b1

Please sign in to comment.