are missing In my source code documentation, I often use: Get a for the sp...">

Web Api Help Page - 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 that translates well to the bottom line in XmlDocument.xml, which contains the compiled api help pages.

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

But for some reason, all of these links are not displayed. We get the following:

 Get a for the specified object 

We found several sources, but nothing works. Does not help:
Api webpage page - don't avoid html in xml documentation

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

Any ideas?

+6
source share
1 answer

WebAPI 2 Help has a class called XmlDocumentationProvider . This class has a method called GetTagValue that processes the Summary and Returns tags. There is also a method called GetDocumentation (there are multiples, but it is one that has an HttpParameterDescriptor parameter) that processes Param tags.

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

RegEx:

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

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); 
+3
source

Source: https://habr.com/ru/post/970956/


All Articles