all <see cref="MyClass"/> are missing

In my source code documentation I often use:

Get a <see cref="Quote"/> for the specified <see cref="apiOrder"/> object.

And this translates nicely into the below string in the XmlDocument.xml, which contains the compiled web api help pages.

Get a <see cref="T:Supertext.API.POCO.Quote"/> for the specified <see cref="!:apiOrder"/> object.

But for some reasons, all these references are not being displayed. What we get is this:

Get a  for the specified  object

We found a few sources, but nothing seems to work. Does not help:
Web Api Help Page- don't escape html in xml documentation

Outdated:
http://thesoftwaredudeblog.wordpress.com/2014/01/04/using-microsoft-asp-net-web-api-2-help-page-part-2/

Any ideas?


In the WebAPI 2 Help, there is a class called, XmlDocumentationProvider . In this class there is a method named, GetTagValue which handles the Summary and Returns tags. There is also a method named GetDocumentation (there are multiples, but it is the one with the HttpParameterDescriptor parameter) which handles the Param tags.

I wrote a function that uses a RegEx to find all "See Cref"s and replace them with the last object name found.

The RegEx:

private static Regex SeeCodeReferenceRegEx = new Regex("<see cref="w:([w]+.)*(w+)" */>", RegexOptions.Compiled);

The function:

private static string CleanValue(string value)
{
    value = value.Trim();
    var matches = SeeCodeReferenceRegEx.Matches(value);
    foreach (Match match in matches)
        value = value.Replace(match.Groups[0].Value, match.Groups[2].Value);
    return value;
}

In GetTagValue , replace:

return node.Value.Trim();

with:

return CleanValue(node.InnerXml);

In GetDocumentation replace:

return parameterNode.Value.Trim();

with:

return CleanValue(parameterNode.InnerXml);
链接地址: http://www.djcxy.com/p/79880.html

上一篇: 使用url的路由器延迟加载状态

下一篇: 所有<see cref =“MyClass”/>都缺失